- 
                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
…resolving circular dependencies
5c38a87    to
    f550346      
    Compare
  
    …when experimentalFastVisibility is not enabled
| # Fast Visibility Algorithm Migration Guide | ||
| 
               | 
          
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 Been meaning to ask how much you see portions of this being in the https://docs.cypress.io/app/references/experiments page vs here. I was thinking there could be some basic explanation in the docs and then link to here since it's quite extensive.
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.
That doc is a placeholder/notes for a more targeted pr in the docs repo - I just wanted to keep it all in one place for now
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?