New issue
Advanced search Search tips

Issue 712809 link

Starred by 2 users

Issue metadata

Status: Fixed
Owner:
Closed: Apr 2017
Components:
EstimatedDays: ----
NextAction: ----
OS: Mac
Pri: 2
Type: Bug



Sign in to add a comment

Serviceworker performance API is missing resources when navigation preload is used

Project Member Reported by claywoolam@google.com, Apr 18 2017

Issue description

UserAgent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36

Steps to reproduce the problem:
1. Navigate to page using navigation preload. Can be with or without serviceworker started, both cases had similar effects for me.
2. In the serviceworker console execute "performance.getEntries()"
3. The primary document won't be there. Also, there seem to be a bunch of duplicate entries for other resources on occasion.

What is the expected behavior?
I can see the fetchStart, requestStart, etc, of the primary document and other key resources. In addition I'd like to understand how the serviceworker start time relates to those. I'd like to track metrics for what actually happens when navigation preload is used in our production system.

What went wrong?
Serviceworker can't see the performance timing of certain resources, including the primary document.

Did this work before? No 

Chrome version: 57.0.2987.133  Channel: stable
OS Version: OS X 10.12.4
Flash Version:
 

Comment 1 by horo@chromium.org, Apr 19 2017

Components: -Platform>DevTools Blink>ServiceWorker
Owner: horo@chromium.org
Status: Assigned (was: Unconfirmed)

Comment 2 by horo@chromium.org, Apr 25 2017

Status: Started (was: Assigned)
Project Member

Comment 3 by bugdroid1@chromium.org, Apr 27 2017

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

commit e8442e6b8cab49e5e56f24d2779ee48cce71b2d5
Author: horo <horo@chromium.org>
Date: Thu Apr 27 19:10:48 2017

Send the decoded size when response completed and stop summing in ResourceLoader::DidReceiveData()

When the size properties of PerformanceResourceTiming were introduced by
https://crrev.com/2105713002, both encodedBodySize and decodedBodySize were
summed up in ResourceLoader::DidReceiveData().
The CL https://crrev.com/2510333002 changed this to send encodedBodySize when
response completed. And currently only decodedBodySize is summed up in
ResourceLoader::DidReceiveData().

We are planning to directly pass the mojo data pipe to FetchResponseData when
fetch() API is used. If we do so, ResourceLoader::DidReceiveData() will not be
called. And it will not be guaranteed that the renderer process read the all
data before the RequestComplete IPC. This will be a problem because the size
properties are passed to the ResourceTimingInfo structure when the renderer
receives the RequestComplete IPC message.

So this cl change it to send the decodedBodySize when response completed same as
encodedBodySize.

And this is also useful to support the resource timing info for service worker
navigation preload response where we don't use ResourceLoader.

BUG= 712809 

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

[modify] https://crrev.com/e8442e6b8cab49e5e56f24d2779ee48cce71b2d5/chrome/renderer/extensions/extension_localization_peer.cc
[modify] https://crrev.com/e8442e6b8cab49e5e56f24d2779ee48cce71b2d5/chrome/renderer/extensions/extension_localization_peer.h
[modify] https://crrev.com/e8442e6b8cab49e5e56f24d2779ee48cce71b2d5/chrome/renderer/extensions/extension_localization_peer_unittest.cc
[modify] https://crrev.com/e8442e6b8cab49e5e56f24d2779ee48cce71b2d5/chrome/renderer/security_filter_peer.cc
[modify] https://crrev.com/e8442e6b8cab49e5e56f24d2779ee48cce71b2d5/chrome/renderer/security_filter_peer.h
[modify] https://crrev.com/e8442e6b8cab49e5e56f24d2779ee48cce71b2d5/content/browser/loader/async_resource_handler.cc
[modify] https://crrev.com/e8442e6b8cab49e5e56f24d2779ee48cce71b2d5/content/browser/loader/mojo_async_resource_handler.cc
[modify] https://crrev.com/e8442e6b8cab49e5e56f24d2779ee48cce71b2d5/content/browser/loader/mojo_async_resource_handler.h
[modify] https://crrev.com/e8442e6b8cab49e5e56f24d2779ee48cce71b2d5/content/child/resource_dispatcher.cc
[modify] https://crrev.com/e8442e6b8cab49e5e56f24d2779ee48cce71b2d5/content/child/resource_dispatcher_unittest.cc
[modify] https://crrev.com/e8442e6b8cab49e5e56f24d2779ee48cce71b2d5/content/child/test_request_peer.cc
[modify] https://crrev.com/e8442e6b8cab49e5e56f24d2779ee48cce71b2d5/content/child/test_request_peer.h
[modify] https://crrev.com/e8442e6b8cab49e5e56f24d2779ee48cce71b2d5/content/child/url_response_body_consumer_unittest.cc
[modify] https://crrev.com/e8442e6b8cab49e5e56f24d2779ee48cce71b2d5/content/child/web_url_loader_impl.cc
[modify] https://crrev.com/e8442e6b8cab49e5e56f24d2779ee48cce71b2d5/content/child/web_url_loader_impl_unittest.cc
[modify] https://crrev.com/e8442e6b8cab49e5e56f24d2779ee48cce71b2d5/content/common/resource_messages.h
[modify] https://crrev.com/e8442e6b8cab49e5e56f24d2779ee48cce71b2d5/content/common/resource_request_completion_status.h
[modify] https://crrev.com/e8442e6b8cab49e5e56f24d2779ee48cce71b2d5/content/public/child/request_peer.h
[modify] https://crrev.com/e8442e6b8cab49e5e56f24d2779ee48cce71b2d5/content/renderer/fetchers/resource_fetcher_impl.cc
[modify] https://crrev.com/e8442e6b8cab49e5e56f24d2779ee48cce71b2d5/third_party/WebKit/Source/core/loader/PingLoader.cpp
[modify] https://crrev.com/e8442e6b8cab49e5e56f24d2779ee48cce71b2d5/third_party/WebKit/Source/core/loader/resource/ImageResource.cpp
[modify] https://crrev.com/e8442e6b8cab49e5e56f24d2779ee48cce71b2d5/third_party/WebKit/Source/core/loader/resource/ImageResourceTest.cpp
[modify] https://crrev.com/e8442e6b8cab49e5e56f24d2779ee48cce71b2d5/third_party/WebKit/Source/platform/exported/WebURLLoaderTestDelegate.cpp
[modify] https://crrev.com/e8442e6b8cab49e5e56f24d2779ee48cce71b2d5/third_party/WebKit/Source/platform/exported/WebURLResponse.cpp
[modify] https://crrev.com/e8442e6b8cab49e5e56f24d2779ee48cce71b2d5/third_party/WebKit/Source/platform/loader/fetch/Resource.h
[modify] https://crrev.com/e8442e6b8cab49e5e56f24d2779ee48cce71b2d5/third_party/WebKit/Source/platform/loader/fetch/ResourceFetcherTest.cpp
[modify] https://crrev.com/e8442e6b8cab49e5e56f24d2779ee48cce71b2d5/third_party/WebKit/Source/platform/loader/fetch/ResourceLoader.cpp
[modify] https://crrev.com/e8442e6b8cab49e5e56f24d2779ee48cce71b2d5/third_party/WebKit/Source/platform/loader/fetch/ResourceLoader.h
[modify] https://crrev.com/e8442e6b8cab49e5e56f24d2779ee48cce71b2d5/third_party/WebKit/Source/platform/loader/fetch/ResourceResponse.cpp
[modify] https://crrev.com/e8442e6b8cab49e5e56f24d2779ee48cce71b2d5/third_party/WebKit/Source/platform/loader/fetch/ResourceResponse.h
[modify] https://crrev.com/e8442e6b8cab49e5e56f24d2779ee48cce71b2d5/third_party/WebKit/Source/platform/testing/weburl_loader_mock.cc
[modify] https://crrev.com/e8442e6b8cab49e5e56f24d2779ee48cce71b2d5/third_party/WebKit/Source/web/tests/sim/SimNetwork.cpp
[modify] https://crrev.com/e8442e6b8cab49e5e56f24d2779ee48cce71b2d5/third_party/WebKit/Source/web/tests/sim/SimNetwork.h
[modify] https://crrev.com/e8442e6b8cab49e5e56f24d2779ee48cce71b2d5/third_party/WebKit/Source/web/tests/sim/SimRequest.cpp
[modify] https://crrev.com/e8442e6b8cab49e5e56f24d2779ee48cce71b2d5/third_party/WebKit/public/platform/WebURLLoaderClient.h
[modify] https://crrev.com/e8442e6b8cab49e5e56f24d2779ee48cce71b2d5/third_party/WebKit/public/platform/WebURLLoaderTestDelegate.h
[modify] https://crrev.com/e8442e6b8cab49e5e56f24d2779ee48cce71b2d5/third_party/WebKit/public/platform/WebURLResponse.h

Project Member

Comment 4 by bugdroid1@chromium.org, Apr 28 2017

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

commit 99d003caf2d7876a7e402a07caa94a5c24ccb922
Author: horo <horo@chromium.org>
Date: Fri Apr 28 05:22:21 2017

Use completion_time to call LoadingFinished of DevTools's Network event for navigation preload

Currently NetworkHandler::NavigationPreloadCompleted() is using TimeTicks::Now()
to call LoadingFinished() of DevTools's Network event. But for normal requests
from the renderer, FrameFetchContext::DispatchDidFinishLoading() is using the
|finish_time| which is originated from ResourceRequestCompletionStatus's
completion_time.

NetworkHandler::NavigationPreloadCompleted() should use the same timing
information.

I found this difference while investigating the  issue 712809 . |completion_time|
is set when the request finished but, NavigationPreloadCompleted() isn't called
before the service worker finishes starting up.

BUG= 712809 

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

[modify] https://crrev.com/99d003caf2d7876a7e402a07caa94a5c24ccb922/content/browser/devtools/protocol/network_handler.cc

Project Member

Comment 5 by bugdroid1@chromium.org, Apr 28 2017

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

commit 1b2b965b6d7588243a28803a4f5253f737e393e0
Author: horo <horo@chromium.org>
Date: Fri Apr 28 13:34:12 2017

Support PerformanceResourceTiming for Service Worker Navigation Preload

BUG= 712809 

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

[modify] https://crrev.com/1b2b965b6d7588243a28803a4f5253f737e393e0/content/renderer/service_worker/service_worker_context_client.cc
[modify] https://crrev.com/1b2b965b6d7588243a28803a4f5253f737e393e0/content/renderer/service_worker/service_worker_context_client.h
[add] https://crrev.com/1b2b965b6d7588243a28803a4f5253f737e393e0/third_party/WebKit/LayoutTests/external/wpt/service-workers/service-worker/navigation-preload/resource-timing.https.html
[add] https://crrev.com/1b2b965b6d7588243a28803a4f5253f737e393e0/third_party/WebKit/LayoutTests/external/wpt/service-workers/service-worker/navigation-preload/resources/resource-timing-scope.py
[add] https://crrev.com/1b2b965b6d7588243a28803a4f5253f737e393e0/third_party/WebKit/LayoutTests/external/wpt/service-workers/service-worker/navigation-preload/resources/resource-timing-worker.js
[add] https://crrev.com/1b2b965b6d7588243a28803a4f5253f737e393e0/third_party/WebKit/LayoutTests/http/tests/serviceworker/navigation-preload/chromium/navigation-preload-resource-timing.html
[add] https://crrev.com/1b2b965b6d7588243a28803a4f5253f737e393e0/third_party/WebKit/LayoutTests/http/tests/serviceworker/navigation-preload/chromium/resources/navigation-preload-resource-timing-scope.html
[add] https://crrev.com/1b2b965b6d7588243a28803a4f5253f737e393e0/third_party/WebKit/LayoutTests/http/tests/serviceworker/navigation-preload/chromium/resources/navigation-preload-resource-timing-worker.js
[modify] https://crrev.com/1b2b965b6d7588243a28803a4f5253f737e393e0/third_party/WebKit/Source/core/timing/PerformanceBase.cpp
[modify] https://crrev.com/1b2b965b6d7588243a28803a4f5253f737e393e0/third_party/WebKit/Source/core/timing/PerformanceBase.h
[modify] https://crrev.com/1b2b965b6d7588243a28803a4f5253f737e393e0/third_party/WebKit/Source/core/timing/PerformanceNavigationTiming.cpp
[modify] https://crrev.com/1b2b965b6d7588243a28803a4f5253f737e393e0/third_party/WebKit/Source/core/timing/PerformanceResourceTiming.cpp
[modify] https://crrev.com/1b2b965b6d7588243a28803a4f5253f737e393e0/third_party/WebKit/Source/core/timing/PerformanceResourceTiming.h
[modify] https://crrev.com/1b2b965b6d7588243a28803a4f5253f737e393e0/third_party/WebKit/Source/core/timing/WorkerGlobalScopePerformance.h
[modify] https://crrev.com/1b2b965b6d7588243a28803a4f5253f737e393e0/third_party/WebKit/Source/modules/serviceworkers/FetchEvent.cpp
[modify] https://crrev.com/1b2b965b6d7588243a28803a4f5253f737e393e0/third_party/WebKit/Source/modules/serviceworkers/FetchEvent.h
[modify] https://crrev.com/1b2b965b6d7588243a28803a4f5253f737e393e0/third_party/WebKit/Source/platform/loader/fetch/ResourceTimingInfo.cpp
[modify] https://crrev.com/1b2b965b6d7588243a28803a4f5253f737e393e0/third_party/WebKit/Source/platform/loader/fetch/ResourceTimingInfo.h
[modify] https://crrev.com/1b2b965b6d7588243a28803a4f5253f737e393e0/third_party/WebKit/Source/web/ServiceWorkerGlobalScopeProxy.cpp
[modify] https://crrev.com/1b2b965b6d7588243a28803a4f5253f737e393e0/third_party/WebKit/Source/web/ServiceWorkerGlobalScopeProxy.h
[modify] https://crrev.com/1b2b965b6d7588243a28803a4f5253f737e393e0/third_party/WebKit/public/web/modules/serviceworker/WebServiceWorkerContextProxy.h

Comment 6 by horo@chromium.org, Apr 28 2017

Status: Fixed (was: Started)
Which version of Chrome will these changes go in?
Labels: M-60
These changes all landed for Chrome 60.
I tried the same flow described in the initial report, calling into performance.getEntries() in the devtools console after a navigation preload request, and I got the same output. The timing information on the primary document isn't in there. Am I doing something wrong?
Forgot to mention, I'm using the latest chrome canary v60.0.3087.0 which has the above two changes.

Comment 11 by horo@chromium.org, May 8 2017

The patch 99d003caf2d7876a7e402a07caa94a5c24ccb922 is in 60.0.3084.0.
> $ git find-releases 99d003caf2d7876a7e402a07caa94a5c24ccb922
> commit 99d003caf2d7876a7e402a07caa94a5c24ccb922 was:
>   initially in 60.0.3084.0

The performance information of navigation preload requests are exposed to the service worker context. So please call performance.getEntries() in the service worker.
Awesome, I verified that it works as expected in Version 60.0.3091.0. Thanks!

Comment 13 by horo@chromium.org, May 19 2017

I created a demo page of the performance information of navigation preload.
 
https://horo-t.github.io/serviceworker/demo/tmp/20170519/

Sign in to add a comment