Skip to content
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

[Fiber] Fix missing render times when we cancel a pending commit #31065

Merged
merged 3 commits into from
Sep 25, 2024

Conversation

eps1lon
Copy link
Collaborator

@eps1lon eps1lon commented Sep 25, 2024

Summary

Follow-up to #31016

Fixes Failed to execute 'measure' on 'Performance': If a non-empty PerformanceMeasureOptions object was passed, at least one of its 'start' or 'end' properties must be present.

Not clear why we didn't catch this in our test suite. Probably because the performance polyfill does not throw if start and end are undefined when a non-empty PerformanceMeasureOptions is passed to performance.measure?

How did you test this change?

  • Discovered when syncing latest React (Upgrade React from 5d19e1c8-20240923 to 04bd67a4-20240924 vercel/next.js#70407) where we encountered above bug. Patching the file locally made the test pass: vercel/next.js@744c429 (#70407)
  • Also enhanced type to make it clear that you fn in waitForCommitToBeReady()(fn) does not receive any further arguments. With that change, the bug would've not get passed Flow. The error message isn't as clear as possible but it gives at least a hint that arguments are missing:
    $ yarn flow dom-node
    yarn run v1.22.22
    $ node ./scripts/tasks/flow.js dom-node
    Running Flow on the dom-node renderer...
    Error ┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈ packages/react-reconciler/src/ReactFiberWorkLoop.js:1315:9
    
    Cannot call schedulePendingCommit with commitRoot.bind(...) bound to the first
    parameter because function [1] requires another argument from function type [2].
    [incompatible-call]
    
        packages/react-reconciler/src/ReactFiberWorkLoop.js
        1312│       // us that it's ready. This will be canceled if we start work on the
        1313│       // root again.
        1314│       root.cancelPendingCommit = schedulePendingCommit(
        1315│         commitRoot.bind(
        1316│           null,
        1317│           root,
        1318│           recoverableErrors,
            :
    [1] 3054│ function commitRoot(
        3055│   root: FiberRoot,
        3056│   recoverableErrors: null | Array<CapturedValue<mixed>>,
        3057│   transitions: Array<Transition> | null,
        3058│   didIncludeRenderPhaseUpdate: boolean,
        3059│   spawnedLane: Lane,
        3060│   updatedLanes: Lanes,
        3061│   suspendedRetryLanes: Lanes,
        3062│   suspendedCommitReason: SuspendedCommitReason, // Profiling-only
        3063│   completedRenderStartTime: number, // Profiling-only
        3064│   completedRenderEndTime: number, // Profiling-only
        3065│ ) {
    
        packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js
    [2] 3404│ export function waitForCommitToBeReady(): null | ((() => any) => Function) {

Copy link

vercel bot commented Sep 25, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
react-compiler-playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 25, 2024 9:20pm

@react-sizebot
Copy link

react-sizebot commented Sep 25, 2024

Comparing: 0f1856c...ed4adf3

Critical size changes

Includes critical production bundles, as well as any change greater than 2%:

Name +/- Base Current +/- gzip Base gzip Current gzip
oss-stable/react-dom/cjs/react-dom.production.js = 6.68 kB 6.68 kB = 1.83 kB 1.82 kB
oss-stable/react-dom/cjs/react-dom-client.production.js +0.01% 507.15 kB 507.20 kB +0.01% 90.79 kB 90.80 kB
oss-experimental/react-dom/cjs/react-dom.production.js = 6.69 kB 6.69 kB = 1.83 kB 1.83 kB
oss-experimental/react-dom/cjs/react-dom-client.production.js +0.01% 512.08 kB 512.13 kB = 91.52 kB 91.52 kB
facebook-www/ReactDOM-prod.classic.js = 603.67 kB 603.73 kB = 106.83 kB 106.83 kB
facebook-www/ReactDOM-prod.modern.js = 579.89 kB 579.95 kB = 102.91 kB 102.92 kB

Significant size changes

Includes any change greater than 0.2%:

(No significant changes)

Generated by 🚫 dangerJS against fd8287f

@@ -3087,8 +3089,6 @@ function commitRoot(
ReactSharedInternals.T = prevTransition;
setCurrentUpdatePriority(previousUpdateLanePriority);
}

return null;
Copy link
Collaborator Author

@eps1lon eps1lon Sep 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is unused and mostly removed to have strict types so that commitRoot is assignable to

@eps1lon eps1lon merged commit 778e1ed into facebook:main Sep 25, 2024
184 checks passed
@eps1lon eps1lon deleted the phasetracking-fix branch September 25, 2024 22:20
github-actions bot pushed a commit that referenced this pull request Sep 25, 2024
github-actions bot pushed a commit that referenced this pull request Sep 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed React Core Team Opened by a member of the React Core Team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants