-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
[Feature] Restore polling: 'mutation' for the same level of waitForSelector efficiency as Puppeteer #24578
Comments
Your test is measuring time from the browser |
@yury-s, thanks for checking this out, I think your concern about potential issue of using time in browser and Node.js is valid.
This is very intentional, the performance difference happens only when we do enough sleep, which is coming to the hard coded retry intervals in Playwright
I would like to clarify that, even if we cannot trust my benchmark, I think we know |
@naruaway Thank you for the clarifications. Playwright uses a backoff strategy for slow pages and does not retry your selector in a loop or upon every DOM mutation. This way, your tests can better utilize CPU and run in parallel, instead of a single test pretty much fully occupying a single core. We believe this is a better strategy, because it only marginally affects the amortized time of the test suite, while allowing for better parallelism. |
Yeah I see that there is interesting trade offs here (pull or push reactivity!) and your reasoning makes sense 👍 Playwright might be more efficient for some tests and Puppeteer might be more efficient for other tests but I can imagine the backoff strategy will not slow down tests for typical E2E test cases scenario since when multiple retries are happening, that part is already slow in app side anyway. Thanks for the clarification |
I realized that Puppeteer has much faster waitForSelector than Playwright since Puppeteer utilizes MutationObserver.
I created a repro here, which demonstrates that Puppeteer is around 20x faster than Playwright in this case.
This repro also includes some description about why Playwright is slow in this case.
Is there any plan to get back
polling: 'mutation'
removed in this PR? It's really unfortunate to see this inefficiency just to deal with Shadow DOM, which is not used everywhere.I haven't investigated why Puppeteer can use MutationObserver but we might steal their strategy if they properly also support Shadow DOM with MutationObserver somehow.
The text was updated successfully, but these errors were encountered: