Skip to content
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: Improve Big Sur browser detection performance #17807

Merged
merged 4 commits into from
Aug 19, 2021

Conversation

chrisbreiding
Copy link
Contributor

@chrisbreiding chrisbreiding commented Aug 19, 2021

User facing changelog

  • Projects will now open much faster on MacOS Big Sur with improved browser detection performance.

Additional details

The root of the issue is this bug in Electron, which causes spawning child processes to take 300-1000ms instead of the usual <30ms when using MacOS Big Sur and Electron 12+. We spawn a child process for each binary of each browser, plus potential fallback lookups if any of the standard ones fail. This causes the browser detection on Big Sur to take upwards of 10 seconds.

We considered using the Electron patch in that issue, but it's not a perfect solution (it was reverted in libuv due to failing tests), and would require us to build Electron ourselves, which is a large amount of work and responsibility.

As a workaround, we spawn a single child process (only incurring the performance penalty once instead of N+ times), and use it to call into our browser detection code from the user's Node.js. Since it's outside Electron, it doesn't suffer from the same bug and performs quickly. This reduces the time taken for browser detection from ~10s to ~1s.

How has the user experience changed?

Users on Big Sur will see projects open much quicker.

PR Tasks

  • Have tests been added/updated?
  • Has the original issue or this PR been tagged with a release in ZenHub?
  • N/A Has a PR for user-facing changes been opened in cypress-documentation?
  • N/A Have API changes been updated in the type definitions?
  • N/A Have new configuration options been added to the cypress.schema.json?

@chrisbreiding chrisbreiding requested a review from a team as a code owner August 19, 2021 14:16
@chrisbreiding chrisbreiding requested review from flotwig and kuceb and removed request for a team August 19, 2021 14:16
@cypress-bot
Copy link
Contributor

cypress-bot bot commented Aug 19, 2021

Thanks for taking the time to open a PR!

@chrisbreiding chrisbreiding requested review from jennifer-shehane and removed request for kuceb August 19, 2021 14:17
@chrisbreiding chrisbreiding changed the title fix: Add workaround for big sur browser detection performance issue fix: Improve Big Sur browser detection performance Aug 19, 2021
@bahmutov
Copy link
Contributor

bahmutov commented Aug 19, 2021 via email

@cypress
Copy link

cypress bot commented Aug 19, 2021



Test summary

18458 0 214 7Flakiness 8


Run details

Project cypress
Status Passed
Commit 891f2ec
Started Aug 19, 2021 6:20 PM
Ended Aug 19, 2021 6:31 PM
Duration 10:47 💡
OS Linux Debian - 10.9
Browser Multiple

View run in Cypress Dashboard ➡️


Flakiness

commands/net_stubbing_spec.ts Flakiness
1 network stubbing > intercepting request > can intercept utf-8 request bodies without crashing
commands/xhr_spec.js Flakiness
1 ... > can alias a route without stubbing it
2 src/cy/commands/xhr > abort > aborts xhrs currently in flight
dom/visibility_spec.ts Flakiness
1 ... > has `opacity: 0`
cypress/proxy-logging-spec.ts Flakiness
1 Proxy Logging > request logging > fetch log shows resource type, url, method, and status code and has expected snapshots and consoleProps
This comment includes only the first 5 flaky tests. See all 8 flaky tests in the Cypress Dashboard.

This comment has been generated by cypress-bot as a result of this project's GitHub integration settings. You can manage this integration in this project's settings in the Cypress Dashboard

@JessicaSachs
Copy link
Contributor

Nice. Thank you!

Copy link
Contributor

@flotwig flotwig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do what we can because we must. LGTM

@flotwig
Copy link
Contributor

flotwig commented Aug 19, 2021

BTW, was not able to test this on an actual Big Sur install as part of my review, my VM is stuck on Catalina.

@flotwig
Copy link
Contributor

flotwig commented Mar 3, 2022

An upstream fix is coming: electron/electron#26143 (comment)

@chrisbreiding chrisbreiding deleted the issue-17773-slow-browser-detection branch April 5, 2022 18:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Detection of browsers take a long time on Mac OS Big Sur
4 participants