-
Notifications
You must be signed in to change notification settings - Fork 3.4k
feat: experimental "fast mode" for visibility checks #32801
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
Draft
cacieprins
wants to merge
21
commits into
develop
Choose a base branch
from
visibility-performance
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
+2,358
−1,122
Conversation
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
…resolving circular dependencies
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.
Additional details
This is a DRAFT proposal
In order to verify performance improvements, this adds a "stress test" e2e test to the driver that simulates interacting with extremely large virtual scrolling lists. This test should probably not be run with "legacy" visibility, as it immediately causes the browser to eat up all available memory and crash. This fixture works perfectly fine outside of Cypress.
This introduces an
experimentalFastVisibilityoption, that switches our visibility detections to an alternative algorithm. This algorithm has some caveats, but it is much faster than the current visibility algorithm.Cypress uses this visibility algorithm not just for visibility assertions, but also for every interaction that requires "interactability." It's memory intensive and can cause unnecessary layout thrashing due to repeated access of CSS properties that require layout recaulcation.
The "fast" visibility algorithm:
bodyandhtmlare always visible; this is in line with current visibility behaviorcheckVisibilitymethod as first pass, with all options enabled. The following states are considered hidden by this method:content-visibilityto `hiddenvisibilityproperty makes it invisiblecontent-visibilityCSS value is auto, and its derived value prevents the element from being rendered<option>or<optgroup>, it defers to the visibility of the parent<select>element. If there is no parent<select>element (an invalid DOM tree state), the element is considered hidden.The point sampling algorithm:
visibleAtPointcheck, which usesdocument.elementFromPointto determine which element is at the top of the render context at that point. If the element at that point is the subject element or a child of the subject element, the subject element is considered visible at that point.Benefits over the legacy algorithm:
Caveats:
pointer-events:noneeither explicit or inherited will always be considered hidden<option>elements that are not a direct child of<select>or<optgroup>elements are not considered visible<optgroup>elements that are not a direct child of<select>or<optgroup>elements are not considered visiblevisibility.cy.tstests fail because the subject element is either off-screen, or covered by an absolute/fixed element that is not an ancestor.Future performance improvements:
requestAnimationFrameto measure theBoundingClientRectof the subject element; this is difficult due to how the visibility & interactability checks are currently wired through jquery selectors, which prevents this method from being asyncSteps to test
How has the user experience changed?
PR Tasks
cypress-documentation?type definitions?