-
Notifications
You must be signed in to change notification settings - Fork 3.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
fix: remove offscreen mode from headless Electron windows #8351
Conversation
Offscreen rendering: https://www.electronjs.org/docs/tutorial/offscreen-rendering passes every frame to a 'paint' event, which cypress does not listen too. In electron 8.2.1 it was fixed and switched back on, so when cypress upgraded from 8.2.0 to 8.2.3, it caused a performance regression. The performance regression on slow computers is about 8x slower. On fast computers you don't see a difference - I expect the multi-process nature of electron and cypress means that more cores mitigate the extra cpu needed. The option was introduced here, 3 years ago: cypress-io@5bde862 My guess is it was a mistake. @brian-mann do you remember?
Thanks for taking the time to open a PR!
|
Would be nice to have a test for this. Performance tests are really challenging though. 🤔 |
I hoped I could see a marked difference in your test runs, but perhaps down to whatever hardware used, there’s no big time difference there. Given the difficulty of performance tests and that this is removing bad code from 3 years ago I’d ask that be done as a separate feature. |
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.
interesting, I wonder how we can qualify and test this to prevent regressions from this happening
Question: the test run videos are still captured though? |
how do I test videos? I can verify windows but it would be good to double check Mac and Linux too - this Pr has no link to a dashboard like other prs I see. |
I can confirm that videos still work on windows. |
Video recording seems fine on Mac |
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 got some notes from @brian-mann on why this option was originally added:
- hiding would leak elements like select drop downs to the screen
- we used to only be able to record and control the FPS this way
- we used to control the screen size and DPI consistently at 1x DPI
- performance
- did not use the GPU to render which prevented display issues
Hopefully he can comment with some more detailed thoughts, but we may want to look into removing this more closely. I remember the dropdown issue anyway and could look at that.
Adding to my notes that @jennifer-shehane listed... With offscreen we get the monitor DPI controlled for and normalized everywhere. If we take off offscreen we have to use the RDP protocol to normalize it for all users. In our e2e tests we manually do that, but that will not be available to other users, so we'll have to do it for them. |
In addition to the reasons that @jennifer-shehane mentioned, Cypress /was/ using the The issue where dropdowns and other elements would appear on screen during As long as we can ensure that issue is fixed, and that 1x DPI is still enforced somehow with Here is the code @brian-mann is referring to that forces 1x DPI in our e2e tests: cypress/packages/server/test/support/fixtures/projects/e2e/cypress/support/index.js Lines 4 to 25 in ee60b01
We don't force the 1x override in Electron or Firefox though, so I'm not sure what that says for how important this is... |
Remember also that electron 8 - 8.2.0 had offscreen disabled so the option did nothing: |
What do you want to do? Make it an option or spend more time testing it? |
@jennifer-shehane and I paired earlier on this and she's testing out the various scenarios. Once we can confirm everything behaves the same and there are no gaps we can merge this in. |
I don't see the weird I'm also not seeing the behavior of the video change based on the DPI of my screen. |
User facing changelog
Switch off offscreen rendering which can cause a 8x performance slowdown for headless electron runs on slow computers. Problem last introduced in cypress 4.5.0.
Additional details
Offscreen rendering:
https://www.electronjs.org/docs/tutorial/offscreen-rendering
passes every frame to a 'paint' event, which cypress does not listen too.
In electron 8.2.1 it was fixed and switched back on, so when cypress upgraded from 8.2.0 to 8.2.3, it caused a performance regression.
The performance regression on slow computers is about 8x slower. On fast computers you don't see a difference - I expect the multi-process nature of electron and cypress means that more cores mitigate the extra cpu needed.
The option was introduced here, 3 years ago:
5bde862
My guess is it was a mistake. @brian-mann do you remember?