🚀 [Story performance] Remove CLS from system layer when adding buttons#37929
Merged
mszylkowski merged 19 commits intoampproject:mainfrom Mar 22, 2022
Merged
🚀 [Story performance] Remove CLS from system layer when adding buttons#37929mszylkowski merged 19 commits intoampproject:mainfrom
mszylkowski merged 19 commits intoampproject:mainfrom
Conversation
|
Hey @gmajoulet, @newmuis! These files were changed: |
gmajoulet
approved these changes
Mar 21, 2022
gmajoulet
approved these changes
Mar 21, 2022
Co-authored-by: Gabriel Majoulet <gmajoulet@google.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
When the system layer gets created it toggles the icons inside vsync mutates. Adding the icons without user interaction will count as CLS to the system layer because it changes size, but we can fix it by giving it the initial size that fills the width so that adding icons will not generate CLS (tested on Chrome and the CLS disappears).
On desktop there is a CLS when on desktop panels because adding the desktop class happens on a vsync after adding the system layer to the shadow root. We need to initialize the desktop state (UI type classes) when the system layer is created, not after a vsync. Therefore we need to initialize the listener synchronously manually, and then use vsync when updating the UIType inside a vsync.
I found that these 2 fixes can improve CLS by 3% (0.03 CLS score) or more, which is 30% of the limit for CLS (0.1)