New issue
Advanced search Search tips

Issue 613072 link

Starred by 2 users

Issue metadata

Status: Fixed
Owner:
Closed: May 2016
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Linux , Android , Windows , Chrome , Mac
Pri: 3
Type: Bug



Sign in to add a comment

A new DevTools window opens when multiple ServiceWorkers are launched.

Project Member Reported by horo@chromium.org, May 19 2016

Issue description

A new DevTools window opens when multiple ServiceWorkers are launched even if "Open DevTools window and pause JavaScript execution on Service Worker startup for debugging." checkbox in chrome://serviceworker-internals/ is not checked.


Version: 52.0.2740.0 canary
OS: All

What steps will reproduce the problem?
(1) Open DevTools window.
(2) Go https://horo-t.github.io/serviceworker/demo/tmp/20160519/.
  <script>
  function register() {
    navigator.serviceWorker.register("./sw.js?1", {scope: "./scope1/"});
    navigator.serviceWorker.register("./sw.js?2", {scope: "./scope2/"});
  }
  </script>
  <input type="button" onclick="register()" value="Register 2 SWs">
(3) Click the button to register two ServiceWorkers.

What is the expected output?
The both two ServiceWorkers should be attached to the existing DevTools window.

What do you see instead?
"./sw.js?2" is attached to the existing DevTools window.
And a new DevTools window for "./sw.js?1" is opened.



 

Comment 1 by horo@chromium.org, May 19 2016

Labels: OS-Android OS-Chrome OS-Linux OS-Mac OS-Windows

Comment 2 by horo@chromium.org, May 19 2016

I think this issue is caused by the logic of GetMatchingServiceWorkers().

1. When the first worker "sw.js?1" is created:
   ServiceWorkerHandler::WorkerCreated() calls PauseForDebugOnStart().
2. When the second worker "sw.js?2" is created:
   ServiceWorkerHandler::WorkerCreated() calls PauseForDebugOnStart().
3. When the first worker "sw.js?1" is ready for inspection:
   ServiceWorkerHandler::WorkerReadyForInspection() calls UpdateHosts(),
   but "sw.js?1" is not the BEST matching SW now. So ServiceWorkerHandler
   doesn't call DevToolsAgentHostImpl::AttachClient().
   And so ServiceWorkerDevToolsManager::WorkerReadyForInspection() calls
   DevToolsAgentHostImpl::Inspect() to open a new DevTools window.
4. When the second worker "sw.js?2" is ready for inspection:
   ServiceWorkerHandler::WorkerReadyForInspection() calls UpdateHosts(),
   and the second worker is attached to the existing DevTools window.
What is BEST matching SW these days? I am now thinking that we should attach to everything that matches the scope. And, actually, I think we could go further than that and attach to everything that matches the origin. That might be the most pragmatic way of surfacing SWs.
(welcome back!)

Comment 5 by horo@chromium.org, May 19 2016

I think we should attach all SWs in the origin.

For example:
- Imagine example.com which provides multiple web applications.
  example.com/excel, example.com/word and example.com/ppt
- When a user logins to example.com/, the site registers three SWs for each applications.

In this case, even if the page URL is still example.com/, the DevTools should attach all three SWs.

Comment 6 by falken@chromium.org, May 20 2016

Status: Assigned (was: Untriaged)
owner exists -> Assigned

Comment 7 by horo@chromium.org, May 20 2016

Status: Started (was: Assigned)
Project Member

Comment 8 by bugdroid1@chromium.org, May 20 2016

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

commit f4215d06fb2c4f27e3ba81a7089c4816ecc8dab1
Author: horo <horo@chromium.org>
Date: Fri May 20 16:12:07 2016

[DevTools] Attach all ServiceWorkers that match the origin.

BUG= 613072 

Review-Url: https://codereview.chromium.org/2000563002
Cr-Commit-Position: refs/heads/master@{#395085}

[modify] https://crrev.com/f4215d06fb2c4f27e3ba81a7089c4816ecc8dab1/content/browser/devtools/protocol/service_worker_handler.cc

Comment 9 by horo@chromium.org, May 23 2016

Labels: M-53
Status: Fixed (was: Started)
$ git find-releases f4215d06fb2c4f27e3ba81a7089c4816ecc8dab1
commit f4215d06fb2c4f27e3ba81a7089c4816ecc8dab1 was:
  initially in 53.0.2744.0

Fixed in M53
Project Member

Comment 10 by bugdroid1@chromium.org, Jun 9 2016

Labels: merge-merged-2743
The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/2993964d2ab0ec7aa82e12fa0e4cb5c6d3077516

commit 2993964d2ab0ec7aa82e12fa0e4cb5c6d3077516
Author: Tsuyoshi Horo <horo@chromium.org>
Date: Thu Jun 09 23:20:20 2016

[DevTools] Attach all ServiceWorkers that match the origin.

BUG= 613072 , 543104 

Review-Url: https://codereview.chromium.org/2000563002
Cr-Commit-Position: refs/heads/master@{#395085}
(cherry picked from commit f4215d06fb2c4f27e3ba81a7089c4816ecc8dab1)

Review URL: https://codereview.chromium.org/2056953002 .

Cr-Commit-Position: refs/branch-heads/2743@{#304}
Cr-Branched-From: 2b3ae3b8090361f8af5a611712fc1a5ab2de53cb-refs/heads/master@{#394939}

[modify] https://crrev.com/2993964d2ab0ec7aa82e12fa0e4cb5c6d3077516/content/browser/devtools/protocol/service_worker_handler.cc

Project Member

Comment 11 by bugdroid1@chromium.org, Jun 15 2016

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

commit 2993964d2ab0ec7aa82e12fa0e4cb5c6d3077516
Author: Tsuyoshi Horo <horo@chromium.org>
Date: Thu Jun 09 23:20:20 2016

[DevTools] Attach all ServiceWorkers that match the origin.

BUG= 613072 , 543104 

Review-Url: https://codereview.chromium.org/2000563002
Cr-Commit-Position: refs/heads/master@{#395085}
(cherry picked from commit f4215d06fb2c4f27e3ba81a7089c4816ecc8dab1)

Review URL: https://codereview.chromium.org/2056953002 .

Cr-Commit-Position: refs/branch-heads/2743@{#304}
Cr-Branched-From: 2b3ae3b8090361f8af5a611712fc1a5ab2de53cb-refs/heads/master@{#394939}

[modify] https://crrev.com/2993964d2ab0ec7aa82e12fa0e4cb5c6d3077516/content/browser/devtools/protocol/service_worker_handler.cc

Sign in to add a comment