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

Issue 694880 link

Starred by 2 users

Issue metadata

Status: Fixed
Owner:
Closed: Feb 2018
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Linux , Android , Windows , All , Chrome , Mac
Pri: 1
Type: Bug

Blocked on:
issue 236262



Sign in to add a comment

Loading on shadow pages should not count UseCounter

Project Member Reported by nhiroki@chromium.org, Feb 22 2017

Issue description

Copied from https://bugs.chromium.org/p/chromium/issues/detail?id=376039#c30

"WorkerGlobalScope doesn't have a frame, but the shadow page has a frame. Therefore, if loader code calls UseCounter on the shadow page, it could wrongly be recorded."
 
Cc: kinuko@chromium.org
Summary: Investigate if a shadow page affects UseCounter (was: Investigate if a shadow page affects on UseCounter)
Relevant topic: kinuko@ is now investigating how to detach loading code from Frames (issue 538751). After it's accomplished, the shadow page would be gone.
Owner: nhiroki@chromium.org
Status: Started (was: Available)
I'll confirm if this actually happens.
I confirmed service worker startup counts the UseCouter::kPageVisits as follows:

Confirmation procedure:
1) Add LOG(ERROR) to UseCounter::DidCommitLoad() to print a given url.
2) Go to chrome://serviceworker-internals.
3) Press "Start" button on one of registrations.
4) Check the stderr. A log should be printed with a service worker script url.
Summary: Loading on shadow pages should not count UseCounter (was: Investigate if a shadow page affects UseCounter)
Cc: kenjibaheux@chromium.org
Hmm... the SW update check also counts the UseCounter::kPageVisits:

Confirmation procedure:
1) Add LOG(ERROR) to UseCounter::DidCommitLoad() to print a given url.
2) Go to a page that uses a service worker.
3) Open DevTools's "Application" tab.
4) Click "Update" link on "Service Workers" section
5) Check the stderr. A log should be printed with a service worker script url.

Comment 7 by kinuko@chromium.org, Apr 21 2017

Yes it'd do. Loading code also calls various UseCounter code which hit Shadow Page.  What'd be the expected behavior here by the way?  Some usage counters would never be counted if we completely disable use counting there.

Comment 8 by kinuko@chromium.org, Apr 21 2017

Chatted offline. So all the use counter would need to be routed back to the worker context. (For context: I'm trying to remove frame dependency from the loading code, but was still thinking about the possibility to keep having a shadow 'document' in some cases, but that might still skew the use counter. I'll think about it a little more)

Comment 9 by rbyers@chromium.org, Apr 21 2017

Blockedon: 236262
Components: -Blink>Infra>Predictability Internals>FeatureControl
Cc: falken@chromium.org nhiroki@chromium.org bmcquade@chromium.org
 Issue 810429  has been merged into this issue.
Owner: ----
Status: Available (was: Started)

Comment 13 Deleted

Cc: loonyb...@chromium.org
I could work on this but I would appreciate a little bit more information given that I don't have much knowledge on workers.

Thanks
If there's a way to tell if the given document is a worker shadow page (IsWorkerShadowPage()) or something, then we can stop counting kPageVisits and other features on it.
Owner: loonyb...@chromium.org
In UseCounter::DidCommitLoad(LocalFrame* frame), 

I tried to check frame->GetDocument()->IsWorkerOrWorkletGlobalScope()

for page whose url is https://www.facebook.com/sw?s=push

Somehow I got false.

Is there other way to check if the page is a worker shadow page?

Thanks
Labels: -Pri-2 Pri-1
What if in WorkerShadowPage, I inform it's WebView to not log UseCounter, then in WebViewImpl, it can inform the Page to not log UseCounter, then in Page::DidCommitLoad, UseCounter PageVisits won't get logged.

My question is, are there other features that could be counted on the shadow page even though they are not supposed to be?
Thanks for picking this up! Reg: #18 IsWorkerOrWorkletGlobalScope returns true for the actual global space for the worker that runs on the worker thread, so it's not useful for the shadow page.  Anyways I'll take a look...
Project Member

Comment 22 by bugdroid1@chromium.org, Feb 14 2018

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/7890f24a44b6b5bf31243e87900c0192d2373697

commit 7890f24a44b6b5bf31243e87900c0192d2373697
Author: Luna Lu <loonybear@chromium.org>
Date: Wed Feb 14 16:41:48 2018

Add a flag in Settings for UseCounter to avoid measuring shadow pages.

Shadow page has a frame and upon service worker startup, UseCounter will
count page visits.
This CL adds a flag "is_shadow_page_" in Settings and sets the flag to
be true in WorkerPageShadow initialization (by default the flag's value
is false). In UseCounter it checks for shadow pages and drop counts for
shadow pages.

Note that this flag will eventually go away since browser side use
counter does not have problems with workers. So once the blink side
use counter is removed, this change can be undone.

This change has also been verified to work locally.

Bug:  694880 
Change-Id: I1cbe857d776591098bbbbf256ef8aa546c399af5
Reviewed-on: https://chromium-review.googlesource.com/917028
Commit-Queue: Luna Lu <loonybear@chromium.org>
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Reviewed-by: Kinuko Yasuda <kinuko@chromium.org>
Cr-Commit-Position: refs/heads/master@{#536736}
[modify] https://crrev.com/7890f24a44b6b5bf31243e87900c0192d2373697/content/browser/service_worker/service_worker_browsertest.cc
[modify] https://crrev.com/7890f24a44b6b5bf31243e87900c0192d2373697/third_party/WebKit/Source/core/exported/WorkerShadowPage.cpp
[modify] https://crrev.com/7890f24a44b6b5bf31243e87900c0192d2373697/third_party/WebKit/Source/core/frame/Settings.cpp
[modify] https://crrev.com/7890f24a44b6b5bf31243e87900c0192d2373697/third_party/WebKit/Source/core/frame/Settings.h
[modify] https://crrev.com/7890f24a44b6b5bf31243e87900c0192d2373697/third_party/WebKit/Source/core/frame/UseCounter.cpp

Labels: Merge-Request-65 OS-Android OS-Chrome OS-Linux OS-Mac OS-Windows
Status: Started (was: Available)
This is an internal feature that doesn't affect the web.

This feature touches UseCounter, which collects feature usage in the web (please see https://www.chromestatus.com/metrics/feature/popularity). The feature usage is calculated as (feature counts/ pagevisits). 

The current behaviour is wrong (pagevisits is inflated). So the public result is also wrong.

I will verify the bug tomorrow on canary tomorrow.

Thanks
Thank you Luna.

Please update the bug with canary result tomorrow. Also FYI, we've getting close to M65 stable launch so merge bar will be high going forward.
Project Member

Comment 25 by sheriffbot@chromium.org, Feb 14 2018

Labels: -Merge-Request-65 Merge-Review-65 Hotlist-Merge-Review
This bug requires manual review: M65 has already been promoted to the beta branch, so this requires manual review
Please contact the milestone owner if you have questions.
Owners: cmasso@(Android), cmasso@(iOS), bhthompson@(ChromeOS), govind@(Desktop)

For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot
Verified on 66.0.3348.0. Works as expected.
Thanks
Labels: -Merge-Review-65 Merge-Approved-65
Approving merge to M65 branch 3325 based on comments #23 and #26. Please merge ASAP. Thank you.
Project Member

Comment 28 by bugdroid1@chromium.org, Feb 15 2018

Labels: -merge-approved-65 merge-merged-3325
The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/5665233d75c6613266a70dd985e12c22aa3a6363

commit 5665233d75c6613266a70dd985e12c22aa3a6363
Author: Luna Lu <loonybear@chromium.org>
Date: Thu Feb 15 21:55:31 2018

Add a flag in Settings for UseCounter to avoid measuring shadow pages.

Shadow page has a frame and upon service worker startup, UseCounter will
count page visits.
This CL adds a flag "is_shadow_page_" in Settings and sets the flag to
be true in WorkerPageShadow initialization (by default the flag's value
is false). In UseCounter it checks for shadow pages and drop counts for
shadow pages.

Note that this flag will eventually go away since browser side use
counter does not have problems with workers. So once the blink side
use counter is removed, this change can be undone.

This change has also been verified to work locally.

Bug:  694880 
Change-Id: I1cbe857d776591098bbbbf256ef8aa546c399af5
Reviewed-on: https://chromium-review.googlesource.com/917028
Commit-Queue: Luna Lu <loonybear@chromium.org>
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Reviewed-by: Kinuko Yasuda <kinuko@chromium.org>
Cr-Original-Commit-Position: refs/heads/master@{#536736}(cherry picked from commit 7890f24a44b6b5bf31243e87900c0192d2373697)
Reviewed-on: https://chromium-review.googlesource.com/922941
Reviewed-by: Luna Lu <loonybear@chromium.org>
Cr-Commit-Position: refs/branch-heads/3325@{#482}
Cr-Branched-From: bc084a8b5afa3744a74927344e304c02ae54189f-refs/heads/master@{#530369}
[modify] https://crrev.com/5665233d75c6613266a70dd985e12c22aa3a6363/content/browser/service_worker/service_worker_browsertest.cc
[modify] https://crrev.com/5665233d75c6613266a70dd985e12c22aa3a6363/third_party/WebKit/Source/core/exported/WorkerShadowPage.cpp
[modify] https://crrev.com/5665233d75c6613266a70dd985e12c22aa3a6363/third_party/WebKit/Source/core/frame/Settings.cpp
[modify] https://crrev.com/5665233d75c6613266a70dd985e12c22aa3a6363/third_party/WebKit/Source/core/frame/Settings.h
[modify] https://crrev.com/5665233d75c6613266a70dd985e12c22aa3a6363/third_party/WebKit/Source/core/frame/UseCounter.cpp

Thanks!
Status: Fixed (was: Started)

Sign in to add a comment