-
Notifications
You must be signed in to change notification settings - Fork 3.4k
perf: 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
base: develop
Are you sure you want to change the base?
Conversation
cypress
|
||||||||||||||||||||||||||||||||||||||||
| Project |
cypress
|
| Branch Review |
visibility-performance
|
| Run status |
|
| Run duration | 19m 26s |
| Commit |
|
| Committer | Cacie Prins |
| View all properties for this run ↗︎ | |
| Test results | |
|---|---|
|
|
0
|
|
|
13
|
|
|
1098
|
|
|
4
|
|
|
26965
|
| View all changes introduced in this branch ↗︎ | |
Warning
Partial Report: The results for the Application Quality reports may be incomplete.
UI Coverage
45.48%
|
|
|---|---|
|
|
188
|
|
|
161
|
Accessibility
98%
|
|
|---|---|
|
|
4 critical
8 serious
2 moderate
2 minor
|
|
|
101
|
…resolving circular dependencies
ac255b8 to
f8b1b6f
Compare
jennifer-shehane
left a comment
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.
@cacieprins Some notes to possibly address
| if (isBody(subject) || isHTML(subject)) { | ||
| return false | ||
| } |
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.
Seems this could be moved out of both functions and ad the top of the isHidden definition. Not a big deal though
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.
While it's good DRY practice, I think it makes sense to keep them separate for now, especially if we end up removing the classic visibility codepath. Splitting the algorithm across files will make it a little more difficult to follow.
| e2e: { | ||
| experimentalFastVisibility: false // Disable fast visibility | ||
| } |
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.
again specifies as e2e
jennifer-shehane
left a comment
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.
… take in cfg/options.ts

Additional details
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-visibilitytohiddenopacityof0visibilityproperty 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? Experimental fast visibility cypress-documentation#6337type definitions?