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

goto takes an increasing amount of time. #4449

Closed
knokknok opened this issue May 19, 2019 · 3 comments · Fixed by #4530
Closed

goto takes an increasing amount of time. #4449

knokknok opened this issue May 19, 2019 · 3 comments · Fixed by #4530
Labels
bug chromium Issues with Puppeteer-Chromium upstream

Comments

@knokknok
Copy link

Steps to reproduce

Tell us about your environment:

  • Puppeteer version: 1.16.0
  • Platform / OS version: macOS 10.14.4
  • URLs (if applicable):
  • Node.js version: v12.1.0

What steps will reproduce the problem?

const puppeteer = require('puppeteer');
var fs = require('fs');
fs.writeFileSync("/tmp/test.html", '<!DOCTYPE HTML>\n<HTML>\n<HEAD></HEAD>\n<BODY>\n<p>Hello World</p>\n</BODY>\n</HTML>\n');

var time=Date.now();
(async () => {
    const browser = await puppeteer.launch();
    page = await browser.newPage();
    for(var i=1; i<10000000; ++i) {
        if (i%1000==0) {
            console.log((Date.now()-time)/1000);
            time=Date.now();
        }
        await page.goto('file:///tmp/test.html');
    }
    await page.close();
    await browser.close();
})()

What is the expected result?

Time to process the page should remain stable

What happens instead?

Duration increases and it eventually times out:

10.509
10.128
12.785
14.21
13.737
21.081
12.523
17.11
15.367
19.972
21.461
15.278
28.165
23.606
26.269
29.514
26.32
35.897
45.951
(node:57740) UnhandledPromiseRejectionWarning: TimeoutError: Navigation Timeout Exceeded: 30000ms exceeded
@JoelEinbinder
Copy link
Collaborator

Awesome repro! Thanks!

@aslushnikov it looks like this is being caused by the addScriptToEvaluate on new document to ensure the secondary dom world exists. At first I thought we might be adding a new script every page load, but we only send the command once. However it takes longer to evaluate every run.

@aslushnikov aslushnikov added bug chromium Issues with Puppeteer-Chromium upstream labels May 29, 2019
@aslushnikov
Copy link
Contributor

Upstream fix is out for review: https://chromium-review.googlesource.com/c/chromium/src/+/1634416

aarongable pushed a commit to chromium/chromium that referenced this issue Jun 5, 2019
DevTools protocol exposes a few protocol methods to create isolated
worlds:
- `Page.addScriptToEvaluateOnNewDocument`
- `Page.createIsolatedWorld`

Whenever a same-process navigation happens, these worlds are not
desotryed - so instead of re-creating the worlds per se, we should
re-create just WindowProxies.

This was reported as puppeteer/puppeteer#4449

R=caseq

Change-Id: I1056f64324a8c4f3c7a9f4a1f443b39a3b48cd29
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1634416
Reviewed-by: Andrey Kosyakov <caseq@chromium.org>
Reviewed-by: Yuki Shiino <yukishiino@chromium.org>
Reviewed-by: Dmitry Gozman <dgozman@chromium.org>
Commit-Queue: Andrey Lushnikov <lushnikov@chromium.org>
Cr-Commit-Position: refs/heads/master@{#666392}
aslushnikov added a commit to aslushnikov/puppeteer that referenced this issue Jun 6, 2019
This roll includes:
- https://crrev.com/666392 - DevTools: do not re-create DOMWrapperWorlds on same-process navigation

Fix puppeteer#4449
aslushnikov added a commit that referenced this issue Jun 6, 2019
This roll includes:
- https://crrev.com/666392 - DevTools: do not re-create DOMWrapperWorlds on same-process navigation

Fix #4449
@knokknok
Copy link
Author

knokknok commented Jun 6, 2019

Awesome! Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug chromium Issues with Puppeteer-Chromium upstream
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants