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

page.queryObjects doesn't work as expected #4545

Closed
aslushnikov opened this issue Jun 8, 2019 · 3 comments

Comments

Projects
None yet
1 participant
@aslushnikov
Copy link
Contributor

commented Jun 8, 2019

Puppeteer: v1.17.0

Consider the following code snippet:

const puppeteer = require('puppeteer');

async function logRetainedArrays(page) {
  const prototypeHandle = await page.evaluateHandle(() => Array.prototype);
  const instancesHandle = await page.queryObjects(prototypeHandle);
  const retainedArrays = await page.evaluate(instances => instances, instancesHandle);
  console.log(retainedArrays);
  await instancesHandle.dispose();
}

(async() => {
  const browser = await puppeteer.launch();
  const page = await browser.newPage();
  await page.evaluate(() => {
    window.returnAnArray = () => [42];
    returnAnArray();
  });
  await logRetainedArrays(page);  // [ [ 42 ] ]
  await logRetainedArrays(page);  // [ [ 42 ] ]
  await logRetainedArrays(page);  // [ ]
  await browser.close();
})();
@aslushnikov

This comment has been minimized.

Copy link
Contributor Author

commented Jun 8, 2019

As @ak239 pointed out - looks like this has something to do with Array and Object literals.

@aslushnikov

This comment has been minimized.

Copy link
Contributor Author

commented Jun 8, 2019

For the record: here's the retain chain:

image

@aslushnikov

This comment has been minimized.

Copy link
Contributor Author

commented Jun 8, 2019

aslushnikov added a commit to aslushnikov/puppeteer that referenced this issue Jun 13, 2019

feat(chromium): roll Chromium to r668716
This roll includes:
- https://crrev.com/c/1652559 - inspector: fix queryObjects when page contains JSModuleNamespace
- https://crrev.com/c/1649473 - [heapprofiler] QueryObjects: do not return objects retained by feedback information
- https://crrev.com/c/1652155 - DevTools: teach page.printToPDF to return IO::Stream

References GoogleChrome#4563
Fix GoogleChrome#4545

aslushnikov added a commit that referenced this issue Jun 14, 2019

feat(chromium): roll Chromium to r668716 (#4581)
This roll includes:
- https://crrev.com/c/1652559 - inspector: fix queryObjects when page contains JSModuleNamespace
- https://crrev.com/c/1649473 - [heapprofiler] QueryObjects: do not return objects retained by feedback information
- https://crrev.com/c/1652155 - DevTools: teach page.printToPDF to return IO::Stream

References #4563
Fix #4545

leo-lb pushed a commit to leo-lb/chromium_v8 that referenced this issue Jun 16, 2019

[heapprofiler] QueryObjects: do not return objects retained by feedba…
…ck information

This was originally reported at GoogleChrome/puppeteer#4545

R=ulan, alph

Change-Id: I5134506e56cd40e49b358cd47590913b81013b6d
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1649473
Commit-Queue: Andrey Lushnikov <lushnikov@chromium.org>
Reviewed-by: Alexei Filippov <alph@chromium.org>
Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#62129}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.