-
Notifications
You must be signed in to change notification settings - Fork 47k
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
Refactor progressed work model #9695
Commits on Jun 6, 2017
-
Configuration menu - View commit details
-
Copy full SHA for 624d5b5 - Browse repository at this point
Copy the full SHA 624d5b5View commit details -
Make sure we resume on progressed hidden children. I split these out into their own functions so that it doesn't distract from the normal, non-hidden code path. Will also make it easier to reuse later if/when we apply the offscreen children feature to other types of components.
Configuration menu - View commit details
-
Copy full SHA for 21eb29f - Browse repository at this point
Copy the full SHA 21eb29fView commit details -
Configuration menu - View commit details
-
Copy full SHA for 83ff51c - Browse repository at this point
Copy the full SHA 83ff51cView commit details -
Re-implement begin phase for classes
There was some unnecessary abstraction in ReactFiberClassComponent that was making it difficult to maintain and, ironically, causing some duplication. I've moved most of that module into the begin phase, and consolidated the separate mount, resume mount, and update functions into a single function that's easier to reason about.
Configuration menu - View commit details
-
Copy full SHA for 3c4718f - Browse repository at this point
Copy the full SHA 3c4718fView commit details -
Better naming for resuming/resetting work
A resume is where we continue working on an already existing work-in- progress. A reset is where we create a new work-in-progress by cloning values from current.
Configuration menu - View commit details
-
Copy full SHA for c45954d - Browse repository at this point
Copy the full SHA c45954dView commit details -
Configuration menu - View commit details
-
Copy full SHA for 020e7a2 - Browse repository at this point
Copy the full SHA 020e7a2View commit details -
Before processing an update queue, clone from current if necessary
It's fine for the work-in-progress and current fiber to have the same update queue, until we begin work on that fiber. At that point, we need to clone the current queue to create a work-in-progress queue. Works pretty much just like fibers.
Configuration menu - View commit details
-
Copy full SHA for b14433a - Browse repository at this point
Copy the full SHA b14433aView commit details -
Fix arguments passed to componentWillUpdate
I'd accidentally reversed which ones were passed to the method and which ones were set on the instance. D'oh.
Configuration menu - View commit details
-
Copy full SHA for c05987c - Browse repository at this point
Copy the full SHA c05987cView commit details -
Configuration menu - View commit details
-
Copy full SHA for 17fa02e - Browse repository at this point
Copy the full SHA 17fa02eView commit details -
Avoid "previous current" work-in-progress scenario
It's possible for a work-in-progress fiber to be the most progressed work (last fiber whose children were reconciled) but be older than the current fiber. This scenario, where the work-in-progress fiber is really the "previous current," happens after a bailout. To avoid, in addition to keeping track of the most progressed fiber, we also keep track of the most recent fiber to enter the begin phase, regardless of whether it bailed out. Then we only resume on the work- in-progress if its the most recent fiber. It'd be nice to come up with a heuristic here that didn't require an additional fiber field. Also, the naming of "progressedWork" versus "newestWork" is not great. Maybe "lastUpdatedWork" and "lastUpdatedOrBailedOutWork"? We can bikeshed later.
Configuration menu - View commit details
-
Copy full SHA for 7d64b2e - Browse repository at this point
Copy the full SHA 7d64b2eView commit details -
Pass pending props as an argument to createWorkInProgress
Helps ensure we don't accidentally reuse props from the current tree, or from an invalid work-in-progress ("previous current").
Configuration menu - View commit details
-
Copy full SHA for 75e8c04 - Browse repository at this point
Copy the full SHA 75e8c04View commit details -
Fix wrong priority being reset in bailoutOnHiddenChildren
The pendingWorkPriority should be reset, not the progressedPriority.
Configuration menu - View commit details
-
Copy full SHA for 0a62806 - Browse repository at this point
Copy the full SHA 0a62806View commit details -
Don't bubble work priority from the current tree
Only bubble work priority from the work-in-progress tree. Otherwise you could fall into an infinite loop because the current tree's priority is never reset. However, update priority should always be bubbled up from the children, even after a bailout, because there might be low priority updates.
Configuration menu - View commit details
-
Copy full SHA for b7d7ad7 - Browse repository at this point
Copy the full SHA b7d7ad7View commit details -
Don't stash work-in-progress as progressed work if it's no longer valid
When resetting a work-in-progress to current, if the progressed priority is the render priority, then the progressed work must be invalid. Otherwise we would have resumed instead of resetting. So don't stash it, just throw it out.
Configuration menu - View commit details
-
Copy full SHA for c400969 - Browse repository at this point
Copy the full SHA c400969View commit details -
Allocate a single progressed work object per fiber pair
There's only ever one progressed work object per fiber pair. Reuse the same object every time instead of allocating. The first time a high- priority update interrupts a low one, we'll still have to allocate a ProgressedWork object per fiber. But not for subsequent interruptions.
Configuration menu - View commit details
-
Copy full SHA for c0f6cf9 - Browse repository at this point
Copy the full SHA c0f6cf9View commit details -
Configuration menu - View commit details
-
Copy full SHA for 62b64c7 - Browse repository at this point
Copy the full SHA 62b64c7View commit details -
Don't schedule an update effect when shouldComponentUpdate returns false
...unless there was already an update scheduled. Need to compare the memoized props to current, not the next props. TODO: this will fail if we bailout with shouldComponentUpdate twice before committing, because the props and state are updated after the first bailout. Only observable in async mode. Need to find a better heuristic. We can't read from the effectTag because it may have been reset during reconciliation.
Configuration menu - View commit details
-
Copy full SHA for 9e3768a - Browse repository at this point
Copy the full SHA 9e3768aView commit details -
Deprioritize setState inside hidden subtrees
Don't bubble up priority inside deprioritized trees.
Configuration menu - View commit details
-
Copy full SHA for b0dc149 - Browse repository at this point
Copy the full SHA b0dc149View commit details -
Set current owner before calling render method
Also, throw an error if an element with a string ref does not have an error. Fiber was throwing, but not until the commit phase, and with a bad error message.
Configuration menu - View commit details
-
Copy full SHA for a191962 - Browse repository at this point
Copy the full SHA a191962View commit details -
Begin failed work at the same priority that the error was thrown
Mistake caused by poor naming. Renamed priorityLevel -> minPriorityLevel to avoid confusion with nextPriorityLevel.
Configuration menu - View commit details
-
Copy full SHA for 299ff8f - Browse repository at this point
Copy the full SHA 299ff8fView commit details -
Configuration menu - View commit details
-
Copy full SHA for 19a33f3 - Browse repository at this point
Copy the full SHA 19a33f3View commit details -
Make the fiber root an effect list
This lets us reuse the logic in transferEffectsToParent. Requires adding two fields to the FiberRoot type, but I figure those are fairly inexpensive. Otherwise I'll revert and duplicate that code, instead.
Configuration menu - View commit details
-
Copy full SHA for 6c5af09 - Browse repository at this point
Copy the full SHA 6c5af09View commit details -
Check if object is extensible instead of comparing to emptyObject
Don't know why this stopped working. Is it related to bundling? If so, I wouldn't expect it to happen in a Jest environment. Take another look at this before landing.
Configuration menu - View commit details
-
Copy full SHA for 0175d3a - Browse repository at this point
Copy the full SHA 0175d3aView commit details -
Configuration menu - View commit details
-
Copy full SHA for 303641b - Browse repository at this point
Copy the full SHA 303641bView commit details -
Configuration menu - View commit details
-
Copy full SHA for b2d3f7a - Browse repository at this point
Copy the full SHA b2d3f7aView commit details -
Configuration menu - View commit details
-
Copy full SHA for f4fa99a - Browse repository at this point
Copy the full SHA f4fa99aView commit details -
Configuration menu - View commit details
-
Copy full SHA for 5e7c2fc - Browse repository at this point
Copy the full SHA 5e7c2fcView commit details -
Configuration menu - View commit details
-
Copy full SHA for b5c980b - Browse repository at this point
Copy the full SHA b5c980bView commit details -
Schedule class component effects after lifecycles are called
...in case the lifecycles contain updates
Configuration menu - View commit details
-
Copy full SHA for 1b8c460 - Browse repository at this point
Copy the full SHA 1b8c460View commit details -
Configuration menu - View commit details
-
Copy full SHA for b85724b - Browse repository at this point
Copy the full SHA b85724bView commit details -
Extract body of reconcile function into a separate function
We can reuse it for coroutines, which reconcile children stored on the stateNode.
Configuration menu - View commit details
-
Copy full SHA for 6971d79 - Browse repository at this point
Copy the full SHA 6971d79View commit details -
Move pure begin phase functions out of constructor
Pretty much anything that isn't component-specific can be moved out. Then we can reuse them in the complete phase.
Configuration menu - View commit details
-
Copy full SHA for 4424615 - Browse repository at this point
Copy the full SHA 4424615View commit details -
Configuration menu - View commit details
-
Copy full SHA for 20caa40 - Browse repository at this point
Copy the full SHA 20caa40View commit details -
Configuration menu - View commit details
-
Copy full SHA for 5a34910 - Browse repository at this point
Copy the full SHA 5a34910View commit details -
Configuration menu - View commit details
-
Copy full SHA for bf2d145 - Browse repository at this point
Copy the full SHA bf2d145View commit details -
Configuration menu - View commit details
-
Copy full SHA for 7aefa2d - Browse repository at this point
Copy the full SHA 7aefa2dView commit details -
Configuration menu - View commit details
-
Copy full SHA for 0e54237 - Browse repository at this point
Copy the full SHA 0e54237View commit details -
Configuration menu - View commit details
-
Copy full SHA for 1d04ebe - Browse repository at this point
Copy the full SHA 1d04ebeView commit details -
Configuration menu - View commit details
-
Copy full SHA for 4174480 - Browse repository at this point
Copy the full SHA 4174480View commit details -
Configuration menu - View commit details
-
Copy full SHA for 9940c8a - Browse repository at this point
Copy the full SHA 9940c8aView commit details -
Configuration menu - View commit details
-
Copy full SHA for 53d9e0f - Browse repository at this point
Copy the full SHA 53d9e0fView commit details -
Configuration menu - View commit details
-
Copy full SHA for 7571b0c - Browse repository at this point
Copy the full SHA 7571b0cView commit details -
I would expect that whenever we resume on progressed work, the child set is a work-in-progress set.
Configuration menu - View commit details
-
Copy full SHA for b9160ba - Browse repository at this point
Copy the full SHA b9160baView commit details -
shouldReuseContent should return false for text nodes
Without this guard, the function throws
Configuration menu - View commit details
-
Copy full SHA for a1a2e9e - Browse repository at this point
Copy the full SHA a1a2e9eView commit details -
Configuration menu - View commit details
-
Copy full SHA for 758aa3c - Browse repository at this point
Copy the full SHA 758aa3cView commit details -
Update newestWork at end of beginWork
...rather than in reconcile and begin. Easier to keep track of.
Configuration menu - View commit details
-
Copy full SHA for 9df490d - Browse repository at this point
Copy the full SHA 9df490dView commit details -
Configuration menu - View commit details
-
Copy full SHA for c76dacc - Browse repository at this point
Copy the full SHA c76daccView commit details -
Progressed priority could be less than work priority if there's a setState deep in the tree that's less than the current render priority but greater than the priority at which the fiber last reconciled.
Configuration menu - View commit details
-
Copy full SHA for 4577349 - Browse repository at this point
Copy the full SHA 4577349View commit details -
Configuration menu - View commit details
-
Copy full SHA for 6527bb3 - Browse repository at this point
Copy the full SHA 6527bb3View commit details -
Use a fiber to stash progressed work
ProgressedWork is a subset of Fiber. We use a separate Flow type to prevent access of extra properties, but we use a whole Fiber for monomorphism.
Configuration menu - View commit details
-
Copy full SHA for 5e20db9 - Browse repository at this point
Copy the full SHA 5e20db9View commit details -
Configuration menu - View commit details
-
Copy full SHA for bf44b5a - Browse repository at this point
Copy the full SHA bf44b5aView commit details -
I had this wrong in an earlier commit. Performing work in the work-in-progress tree should never add work to the current tree. Only state updates do. So in the complete phase, we should bubble priority up from the children even if they are current, so that we don't drop pending updates. Also realized there's no reason to check if a work-in-progress is valid during a bailout. By the time we get to that function, we already determined if the work-in-progress is valid during the resume-or-reset step.
Configuration menu - View commit details
-
Copy full SHA for aa77ecf - Browse repository at this point
Copy the full SHA aa77ecfView commit details -
Simulate Sierpinski triangle demo
New test suite simulates the triangle demo. It renders a recursive tree and flushes it unit by unit, resetting the unit of work pointer to the root after each triangle is rendered. It also simulates the hover effect by updating a target node with high priority. The test is written in such a way that we can add fuzz testing on top of it later. For now, I've "manually" fuzz tested by trying out arbitrary values.
Configuration menu - View commit details
-
Copy full SHA for 7af9eae - Browse repository at this point
Copy the full SHA 7af9eaeView commit details -
Change color of dots on each tick in triangle demo
Makes bugs more noticeable.
Configuration menu - View commit details
-
Copy full SHA for 2b38dc3 - Browse repository at this point
Copy the full SHA 2b38dc3View commit details
Commits on Jun 7, 2017
-
Add pendingWorkPriority to ProgressedWork
Avoided doing this originally because I didn't want to add a field to the fork, and figured we could infer this in other ways. But the fork is a full Fiber for monomorphism purposes, anyway, so we already have it.
Configuration menu - View commit details
-
Copy full SHA for 6e94072 - Browse repository at this point
Copy the full SHA 6e94072View commit details -
Triangle tester: Simulate multiple hovers in a single step
This allows for multiple nodes to be active at a time, which isn't possible in the demo because to hover over on node you must leave the other.
Configuration menu - View commit details
-
Copy full SHA for ec911db - Browse repository at this point
Copy the full SHA ec911dbView commit details -
Add ReactNoop.yieldBeforeNextUnitOfWork() API
Most incremental tests rely on yielding at a specific point. Using an explicit API, rather than relying on fake expiration times that rely on implementation details, should make our tests more resilient and reduce false positives.
Configuration menu - View commit details
-
Copy full SHA for 9cec000 - Browse repository at this point
Copy the full SHA 9cec000View commit details
Commits on Jun 8, 2017
-
Configuration menu - View commit details
-
Copy full SHA for e1209b2 - Browse repository at this point
Copy the full SHA e1209b2View commit details
Commits on Jun 9, 2017
-
When comparing insertion positions, only compare non-null values
If `insertAfter` is null, the insertion position is at the start of the list. Similarly, if the `insertBefore` is null, the insertion position is at the end of the list. The starting/end position of one list is not necessarily the same as the starting/end position of another. So, only compare non-null values.
Configuration menu - View commit details
-
Copy full SHA for 3a9069d - Browse repository at this point
Copy the full SHA 3a9069dView commit details -
Previous version couldn't increment the counter more than once before flushing, which meant it couldn't reproduce certain errors that occur when running the triangle demo in Firefox, where starvation is worse. The new version uses a Redux-like approach, with actions.
Configuration menu - View commit details
-
Copy full SHA for 2b72ba2 - Browse repository at this point
Copy the full SHA 2b72ba2View commit details
Commits on Jun 10, 2017
-
This actually wasn't causing an error because the arguments were flipped twice: the first time to the wrong order, and the second time back to the correct order :D
Configuration menu - View commit details
-
Copy full SHA for 0959584 - Browse repository at this point
Copy the full SHA 0959584View commit details -
This bug illustrates that our `progressedPriority` model is wrong. When deciding whether to resume work, we should compare the priority at which the parent reconciled its children, not the priority at which the fiber itself reconciled.
Configuration menu - View commit details
-
Copy full SHA for 32cb894 - Browse repository at this point
Copy the full SHA 32cb894View commit details