-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
useScaleCanvas performance improvements #67496
Conversation
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Size Change: -57 B (0%) Total Size: 1.83 MB
ℹ️ View Unchanged
|
…f container height has changed between renders
Flaky tests detected in 39a27cd. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/12126279890
|
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.
I think we can get the clean up merged, since it used to work like that. Would prefer if the rest is changed separately, but up to you, it seems fine.
Would love if we could try to move all the CSS variable setting and scroll calc to right before the animation runs, but can be done separately.
* Rely on containerHeight resize listener instead of iframe.documentElement.clientHeight when setting the CSS variable * Only add CSS variables if we need them (scaleValue < 1) * Remove unmounting of CSS variables in useEffect return --------- Co-authored-by: Ella <[email protected]>
* Rely on containerHeight resize listener instead of iframe.documentElement.clientHeight when setting the CSS variable * Only add CSS variables if we need them (scaleValue < 1) * Remove unmounting of CSS variables in useEffect return --------- Co-authored-by: Ella <[email protected]>
Rely on
containerHeight
resize listener instead of iframe.documentElement.clientHeightWhat?
Rely on containerHeight resize listener instead of
iframe.documentElement.clientHeight
when setting the CSS variables to fix the first block metric impact caused by #66917.Why?
There was a performance hit when using
iframe.documentElement.clientHeight
.How?
Get the
containerHeight
from the existing resize listener.Testing Instructions
Testing Instructions for Keyboard
Screenshots or screencast
I ran
npm run test:performance test/performance/specs/post-editor.spec.js
locally to see the first block metric, since it was the one that was most impacted.Baseline: Without useScaleCanvas(): This is what we hope to return to
│ firstBlock │ '1825.45 ms +2.1% -2.47%' │
│ firstBlock │ '1864.6 ms +1.53% -1.81%' │
Original Perf issue: With useScaleCanvas()
│ firstBlock │ '2221.9 ms +2.6% -4.08%' │
│ firstBlock │ '2185.8 ms +2.48% -3.89%' │
Fix 1 (#67481, #67495): Mounting hook for
prevIsZoomedOut
so it doesn't run on mount│ firstBlock │ '2020.55 ms +2.43% -2.56%' │
│ firstBlock │ '2091.9 ms +0.59% -2.96%' │
Fix 2: Use containerHeight instead of iframeDocument.documentElement.clientHeight
│ firstBlock │ '1934.45 ms +2.1% -1.05%' │
│ firstBlock │ '1875.4 ms +0.83% -0.47%' │
Fix 3: Remove useEffect unmounting the CSS variables
│ firstBlock │ '1900.75 ms +2.26% -0.8%' │
│ firstBlock │ '1908.8 ms +0.67% -4.78%' │
Fix 4: Only set CSS variables on scaleValue < 1: Yay! Baseline as been achieved.
│ firstBlock │ '1795.5 ms +0.47% -0.3%' │
│ firstBlock │ '1817.4 ms +1.38% -1.02%' │
To be sure, check only set CSS variables on scaleValue < 1, but preserve unmounting all CSS variables in useEffect unmount (remove Fix 3)
│ firstBlock │ '1872.3 ms +2.85% -4.1%' │
│ firstBlock │ '1831 ms +2.21% -1.59%' │
|||