-
Notifications
You must be signed in to change notification settings - Fork 49.9k
[Fiber] Move updatePriority tracking to renderers #28751
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
d43dd65
[Fiber] Move updatePriority tracking to renderers
gnoff 2a00183
Moves currentUpdatePriority to ReactDOMSharedInternals. While not par…
gnoff fcbb369
refactors the currentUpdatePriority apis to more clearly communicate …
gnoff 5d28591
Try shorter property name to get inlining
gnoff File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
refactors the currentUpdatePriority apis to more clearly communicate …
…when you are reading a raw value and when you are getting a resolved value. This allows requestUpdateLane to do a single call into the renderer to get the update priority while still making a reasonable stack based updating of update priorities ergonomic. I had to expose a `peekCurrentUpdatePriority` to satisfy startTransition which needs to set a new priority only if the current one is too low. I tried to stay away from get/set naming to avoid potential issues with whether you are reading the raw value or the derived one that considers window.event
- Loading branch information
commit fcbb36982d6853c672b12eac6ed851949e22e1d8
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -70,13 +70,13 @@ import { | |
| cancelTimeout, | ||
| noTimeout, | ||
| afterActiveInstanceBlur, | ||
| getCurrentEventPriority, | ||
| startSuspendingCommit, | ||
| waitForCommitToBeReady, | ||
| preloadInstance, | ||
| supportsHydration, | ||
| getCurrentUpdatePriority, | ||
| setCurrentUpdatePriority, | ||
| getCurrentUpdatePriority, | ||
| resolveUpdatePriority, | ||
| } from './ReactFiberConfig'; | ||
|
|
||
| import {createWorkInProgress, resetWorkInProgress} from './ReactFiber'; | ||
|
|
@@ -161,6 +161,7 @@ import { | |
| DefaultEventPriority, | ||
| lowerEventPriority, | ||
| lanesToEventPriority, | ||
| eventPriorityToLane, | ||
| } from './ReactEventPriorities'; | ||
| import {requestCurrentTransition} from './ReactFiberTransition'; | ||
| import { | ||
|
|
@@ -641,25 +642,7 @@ export function requestUpdateLane(fiber: Fiber): Lane { | |
| requestTransitionLane(transition); | ||
| } | ||
|
|
||
| // Updates originating inside certain React methods, like flushSync, have | ||
| // their priority set by tracking it with a context variable. | ||
| // | ||
| // The opaque type returned by the host config is internally a lane, so we can | ||
| // use that directly. | ||
| // TODO: Move this type conversion to the event priority module. | ||
| const updateLane: Lane = (getCurrentUpdatePriority(): any); | ||
| if (updateLane !== NoLane) { | ||
| return updateLane; | ||
| } | ||
|
|
||
| // This update originated outside React. Ask the host environment for an | ||
| // appropriate priority, based on the type of event. | ||
| // | ||
| // The opaque type returned by the host config is internally a lane, so we can | ||
| // use that directly. | ||
| // TODO: Move this type conversion to the event priority module. | ||
| const eventLane: Lane = (getCurrentEventPriority(): any); | ||
| return eventLane; | ||
| return eventPriorityToLane(resolveUpdatePriority()); | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should get inlined and it's type safe over a cast |
||
| } | ||
|
|
||
| function requestRetryLane(fiber: Fiber) { | ||
|
|
@@ -1446,12 +1429,12 @@ export function getExecutionContext(): ExecutionContext { | |
| } | ||
|
|
||
| export function deferredUpdates<A>(fn: () => A): A { | ||
| const previousPriority = getCurrentUpdatePriority(); | ||
| const prevTransition = ReactCurrentBatchConfig.transition; | ||
|
|
||
| const previousPriority = getCurrentUpdatePriority(); | ||
| try { | ||
| ReactCurrentBatchConfig.transition = null; | ||
| setCurrentUpdatePriority(DefaultEventPriority); | ||
| ReactCurrentBatchConfig.transition = null; | ||
| return fn(); | ||
| } finally { | ||
| setCurrentUpdatePriority(previousPriority); | ||
|
|
@@ -1492,11 +1475,11 @@ export function discreteUpdates<A, B, C, D, R>( | |
| c: C, | ||
| d: D, | ||
| ): R { | ||
| const previousPriority = getCurrentUpdatePriority(); | ||
| const prevTransition = ReactCurrentBatchConfig.transition; | ||
| const previousPriority = getCurrentUpdatePriority(); | ||
| try { | ||
| ReactCurrentBatchConfig.transition = null; | ||
| setCurrentUpdatePriority(DiscreteEventPriority); | ||
| ReactCurrentBatchConfig.transition = null; | ||
| return fn(a, b, c, d); | ||
| } finally { | ||
| setCurrentUpdatePriority(previousPriority); | ||
|
|
@@ -1533,8 +1516,8 @@ export function flushSync<R>(fn: (() => R) | void): R | void { | |
| const previousPriority = getCurrentUpdatePriority(); | ||
|
|
||
| try { | ||
| ReactCurrentBatchConfig.transition = null; | ||
| setCurrentUpdatePriority(DiscreteEventPriority); | ||
| ReactCurrentBatchConfig.transition = null; | ||
| if (fn) { | ||
| return fn(); | ||
| } else { | ||
|
|
@@ -2713,12 +2696,12 @@ function commitRoot( | |
| ) { | ||
| // TODO: This no longer makes any sense. We already wrap the mutation and | ||
| // layout phases. Should be able to remove. | ||
| const previousUpdateLanePriority = getCurrentUpdatePriority(); | ||
| const prevTransition = ReactCurrentBatchConfig.transition; | ||
|
|
||
| const previousUpdateLanePriority = getCurrentUpdatePriority(); | ||
| try { | ||
| ReactCurrentBatchConfig.transition = null; | ||
| setCurrentUpdatePriority(DiscreteEventPriority); | ||
| ReactCurrentBatchConfig.transition = null; | ||
| commitRootImpl( | ||
| root, | ||
| recoverableErrors, | ||
|
|
@@ -3187,8 +3170,8 @@ export function flushPassiveEffects(): boolean { | |
| const previousPriority = getCurrentUpdatePriority(); | ||
|
|
||
| try { | ||
| ReactCurrentBatchConfig.transition = null; | ||
| setCurrentUpdatePriority(priority); | ||
| ReactCurrentBatchConfig.transition = null; | ||
| return flushPassiveEffectsImpl(); | ||
| } finally { | ||
| setCurrentUpdatePriority(previousPriority); | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems like maybe this was kind of broken to begin with since it doesn't opt out of transitions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
well it's sorta legacy anyway. Aren't we going to remove from OSS entrypoints?