New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 757998 link

Starred by 1 user

Issue metadata

Status: Assigned
Owner:
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: All
Pri: 3
Type: Bug



Sign in to add a comment

Coverage reported for (dead) scripts of a previous page

Project Member Reported by phulce@chromium.org, Aug 22 2017

Issue description

Chrome Version: 62.0.3193.0 (Official Build) canary (64-bit)
OS: macOS 10.12.6

What steps will reproduce the problem?
(1) Using the DevTools protocol, navigate to a page with some unused JavaScript and wait for load (example code to run locally: https://codepen.io/anon/pen/rzvXKR)
(2) Navigate to about:blank
(3) Call Profiler.enable and Profiler.startPreciseCoverage
(4) Navigate back to the same page and wait for load
(5) Call Profiler.takePreciseCoverage

What is the expected result? The results contain the scripts/functions just for the loaded page.

What happens instead? The results contain duplicate scripts from the previous page load in addition to the ones loaded (its not possible from the output to distinguish which are real and which are not).
 

Comment 1 by phulce@chromium.org, Aug 22 2017

Cc: kozyatinskiy@chromium.org caseq@chromium.org
caseq/kozy could you assist in assigning to the proper party?
Cc: jgruber@chromium.org
Cc: yangguo@chromium.org
Status: Available (was: Untriaged)
Cc: -yangguo@chromium.org
Owner: yangguo@chromium.org
Status: Assigned (was: Available)
Scripts can be kept alive by precise coverage, and AFAIK we don't have a mechanism to clear old scripts on navigation.

I'm also not sure what the expectation should be. Do we really want to clear existing coverage data on navigation?

Yang, wdyt?
Cc: -caseq@chromium.org yangguo@chromium.org
Owner: caseq@chromium.org
This is working as intended from V8, we need to keep functions alive to not accidentally lose them to GC.

FWIW, V8 does not have any concept of page navigation. Maybe DevTools should stop and restart precise coverage on page navigation?

Comment 6 by phulce@chromium.org, Aug 24 2017

If I'm reading your comments right, the issue isn't that coverage has been enabled the entire time and I see coverage for a previous page (I would expect that to be the case). The issue is that I'm starting coverage while on about:blank before navigating to page B and yet I'm receiving coverage information for page A that was never touched while coverage was enabled.

Or are you saying that simply calling startPreciseCoverage, stopPreciseCoverage while on about:blank will flush out the previous page and then I can startPreciseCoverage normally as I would expect?
Cc: -yangguo@chromium.org caseq@chromium.org
Owner: yangguo@chromium.org
Let me see if I understand this correctly.

- You navigate to page A
- Then you navigate to new tab page
- You enable precise coverage
- Then you navigate to page B
- You now take coverage
- The coverage info includes scripts from A
- These coverage info from A includes coverage data from before enabling precise coverage.

Is that correct?

I think I know what the issue is... while executing, V8 always collects call counts, for other reasons than code coverage. These call counts are not always accurate. To use this data, you can use getBestEffortCoverage without enabling precise coverage upfront.

When you enable precise coverage, the existing call count data is not cleared, and "leak" into the precise coverage.

You can try one of the following to confirm this theory:

- Immediately after enabling precise coverage, call takePreciseCoverage to clear coverage info.
- Add the following code after this line:
https://cs.chromium.org/chromium/src/v8/src/debug/debug-coverage.cc?q=debug-coverage.cc&sq=package:chromium&dr&l=544

vector->clear_invocation_count();

Comment 8 by phulce@chromium.org, Aug 24 2017

That description of the issue is correct I'll give that a try thanks!
Project Member

Comment 9 by bugdroid1@chromium.org, Aug 28 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/v8/v8.git/+/6cd99b38b95abd62f85c6c7ff954a797a8a95e14

commit 6cd99b38b95abd62f85c6c7ff954a797a8a95e14
Author: Yang Guo <yangguo@chromium.org>
Date: Mon Aug 28 03:49:59 2017

[coverage] clear call counts for precise coverage.

This is so that precise coverage starts with a clean slate.
The old behavior can be emulated by calling getBestEffortCoverage
before starting precise coverage.

R=jgruber@chromium.org

Bug: chromium:757998
Change-Id: Ib3ee2316966f676456198159bdcf8ba8b9d3896f
Reviewed-on: https://chromium-review.googlesource.com/635084
Commit-Queue: Yang Guo <yangguo@chromium.org>
Reviewed-by: Jakob Gruber <jgruber@chromium.org>
Cr-Commit-Position: refs/heads/master@{#47629}
[modify] https://crrev.com/6cd99b38b95abd62f85c6c7ff954a797a8a95e14/src/debug/debug-coverage.cc
[modify] https://crrev.com/6cd99b38b95abd62f85c6c7ff954a797a8a95e14/test/inspector/cpu-profiler/coverage-block-expected.txt
[modify] https://crrev.com/6cd99b38b95abd62f85c6c7ff954a797a8a95e14/test/inspector/cpu-profiler/coverage-expected.txt

Sign in to add a comment