WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
179513
Web Inspector: Include a NetworkAgent in ServiceWorkers for network debugging
https://bugs.webkit.org/show_bug.cgi?id=179513
Summary
Web Inspector: Include a NetworkAgent in ServiceWorkers for network debugging
Joseph Pecoraro
Reported
2017-11-09 16:38:57 PST
Include a NetworkAgent in ServiceWorkers for network debugging This will include all of the necessary parts on the backend (WebCore) to inform the frontend (Web Inspector window) of Network Requests created by a ServiceWorker. This doesn't include the necessary changes to the Web Inspector frontend to support showing a Network Tab when debugging a ServiceWorker. That will be a follow-up.
Attachments
[PATCH] Proposed Fix
(81.78 KB, patch)
2017-11-09 19:32 PST
,
Joseph Pecoraro
buildbot
: commit-queue-
Details
Formatted Diff
Diff
Archive of layout-test-results from ews101 for mac-elcapitan
(2.27 MB, application/zip)
2017-11-09 20:26 PST
,
Build Bot
no flags
Details
Archive of layout-test-results from ews104 for mac-elcapitan-wk2
(2.91 MB, application/zip)
2017-11-09 20:52 PST
,
Build Bot
no flags
Details
[PATCH] Proposed Fix
(83.66 KB, patch)
2017-11-10 11:06 PST
,
Joseph Pecoraro
no flags
Details
Formatted Diff
Diff
[PATCH] Proposed Fix
(83.69 KB, patch)
2017-11-10 11:43 PST
,
Joseph Pecoraro
buildbot
: commit-queue-
Details
Formatted Diff
Diff
Archive of layout-test-results from ews103 for mac-elcapitan
(2.24 MB, application/zip)
2017-11-10 12:32 PST
,
Build Bot
no flags
Details
Archive of layout-test-results from ews104 for mac-elcapitan-wk2
(3.21 MB, application/zip)
2017-11-10 12:39 PST
,
Build Bot
no flags
Details
[PATCH] Proposed Fix
(83.86 KB, patch)
2017-11-10 13:13 PST
,
Joseph Pecoraro
bburg
: review+
Details
Formatted Diff
Diff
Show Obsolete
(7)
View All
Add attachment
proposed patch, testcase, etc.
Radar WebKit Bug Importer
Comment 1
2017-11-09 16:39:19 PST
<
rdar://problem/35456402
>
Joseph Pecoraro
Comment 2
2017-11-09 19:32:09 PST
Created
attachment 326536
[details]
[PATCH] Proposed Fix
Build Bot
Comment 3
2017-11-09 19:34:20 PST
Comment hidden (obsolete)
Attachment 326536
[details]
did not pass style-queue: ERROR: Source/WebCore/workers/WorkerMessagingProxy.h:68: The parameter name "disabled" adds no information, so it should be removed. [readability/parameter_name] [5] ERROR: Source/WebCore/workers/WorkerDebuggerProxy.h:39: The parameter name "disabled" adds no information, so it should be removed. [readability/parameter_name] [5] ERROR: Source/WebCore/inspector/agents/page/PageNetworkAgent.cpp:34: Alphabetical sorting problem. [build/include_order] [4] ERROR: Source/WebCore/inspector/agents/InspectorNetworkAgent.h:121: The parameter name "disabled" adds no information, so it should be removed. [readability/parameter_name] [5] ERROR: Source/WebCore/workers/service/context/ServiceWorkerThreadProxy.h:66: The parameter name "disabled" adds no information, so it should be removed. [readability/parameter_name] [5] ERROR: Source/WebCore/inspector/agents/worker/WorkerNetworkAgent.h:42: The parameter name "disabled" adds no information, so it should be removed. [readability/parameter_name] [5] ERROR: Source/WebCore/inspector/agents/page/PageNetworkAgent.h:42: The parameter name "disabled" adds no information, so it should be removed. [readability/parameter_name] [5] ERROR: Source/WebCore/loader/WorkerThreadableLoader.cpp:110: Wrong number of spaces before statement. (expected: 8) [whitespace/indent] [4] Total errors found: 8 in 27 files If any of these errors are false positives, please file a bug against check-webkit-style.
Build Bot
Comment 4
2017-11-09 20:25:59 PST
Comment hidden (obsolete)
Comment on
attachment 326536
[details]
[PATCH] Proposed Fix
Attachment 326536
[details]
did not pass mac-ews (mac): Output:
http://webkit-queues.webkit.org/results/5172800
New failing tests: inspector/codemirror/prettyprinting-javascript.html http/tests/websocket/tests/hybi/inspector/resolveWebSocket.html inspector/codemirror/prettyprinting-css.html http/tests/inspector/network/loadResource-insecure-resource.html
Build Bot
Comment 5
2017-11-09 20:26:01 PST
Comment hidden (obsolete)
Created
attachment 326541
[details]
Archive of layout-test-results from ews101 for mac-elcapitan The attached test failures were seen while running run-webkit-tests on the mac-ews. Bot: ews101 Port: mac-elcapitan Platform: Mac OS X 10.11.6
Build Bot
Comment 6
2017-11-09 20:52:23 PST
Comment hidden (obsolete)
Comment on
attachment 326536
[details]
[PATCH] Proposed Fix
Attachment 326536
[details]
did not pass mac-wk2-ews (mac-wk2): Output:
http://webkit-queues.webkit.org/results/5172927
New failing tests: inspector/codemirror/prettyprinting-javascript.html http/tests/websocket/tests/hybi/inspector/resolveWebSocket.html inspector/codemirror/prettyprinting-css.html http/tests/inspector/network/loadResource-insecure-resource.html
Build Bot
Comment 7
2017-11-09 20:52:25 PST
Comment hidden (obsolete)
Created
attachment 326546
[details]
Archive of layout-test-results from ews104 for mac-elcapitan-wk2 The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews. Bot: ews104 Port: mac-elcapitan-wk2 Platform: Mac OS X 10.11.6
Joseph Pecoraro
Comment 8
2017-11-10 11:06:44 PST
Comment hidden (obsolete)
Created
attachment 326607
[details]
[PATCH] Proposed Fix
Build Bot
Comment 9
2017-11-10 11:08:28 PST
Comment hidden (obsolete)
Attachment 326607
[details]
did not pass style-queue: ERROR: Source/WebCore/loader/WorkerThreadableLoader.cpp:110: Wrong number of spaces before statement. (expected: 8) [whitespace/indent] [4] Total errors found: 1 in 27 files If any of these errors are false positives, please file a bug against check-webkit-style.
Joseph Pecoraro
Comment 10
2017-11-10 11:43:55 PST
Comment hidden (obsolete)
Created
attachment 326610
[details]
[PATCH] Proposed Fix
Build Bot
Comment 11
2017-11-10 11:47:28 PST
Comment hidden (obsolete)
Attachment 326610
[details]
did not pass style-queue: ERROR: Source/WebCore/loader/WorkerThreadableLoader.cpp:110: Wrong number of spaces before statement. (expected: 8) [whitespace/indent] [4] Total errors found: 1 in 27 files If any of these errors are false positives, please file a bug against check-webkit-style.
Blaze Burg
Comment 12
2017-11-10 12:04:26 PST
Comment on
attachment 326536
[details]
[PATCH] Proposed Fix View in context:
https://bugs.webkit.org/attachment.cgi?id=326536&action=review
> Source/WebCore/inspector/InspectorInstrumentation.h:181 > + static void willSendRequest(WorkerGlobalScope&, unsigned long identifier, ResourceRequest&);
Might want to comment here that these are for SW, not for web workers that have a page. If these are truly only for SW and we don't intend to reroute web workers through this code path, then these new things should be guarded with ENABLE(SERVICE_WORKER) so that's obvious.
> Source/WebCore/inspector/WorkerInspectorController.cpp:171 > + auto workerContext = workerAgentContext();
This local can go inside the branch.
> Source/WebCore/inspector/WorkerInspectorController.h:75 > + void createLazyAgents();
I find this name a little weird. Wouldn't we normally call this createAgentsIfNeeded or ensureAgents() ?
> Source/WebCore/inspector/agents/InspectorNetworkAgent.cpp:619 > + // FIXME: Worker support.
What would the initiator be once this is finished? A new type?
> Source/WebCore/inspector/agents/InspectorNetworkAgent.cpp:721 > + ASSERT(is<WebSocketChannel>(webSocket->channel().get()));
This seems more strict about the subtype. Is that okay?
> Source/WebCore/inspector/agents/InspectorNetworkAgent.cpp:-708 > - Document* document = downcast<Document>(webSocket->scriptExecutionContext());
It took me a while to figure out that activeWebSockets was the new point of page vs worker differentiation.
> Source/WebCore/inspector/agents/InspectorNetworkAgent.cpp:853 > + // FIXME: <
https://webkit.org/b/168475
> Web Inspector: Correctly display iframe's and worker's WebSockets
Why would this not work for iframe websockets? an iframe has a document..?
> Source/WebCore/inspector/agents/page/PageNetworkAgent.cpp:77 > + if (document->page() != &m_pageAgent->page())
This comment makes more sense given this condition. It is horrifying we don't support this, though.
> Source/WebCore/loader/WorkerThreadableLoader.cpp:211 > Vector<char> vector(dataLength);
Perhaps this is better named 'buffer', at the least?
> Source/WebCore/loader/WorkerThreadableLoader.cpp:216 > + InspectorInstrumentation::didReceiveData(downcast<WorkerGlobalScope>(context), workerRequestIdentifier, vector.data(), vector.size());
,...because this reads poorly with 'vector'
> Source/WebCore/loader/WorkerThreadableLoader.h:120 > + unsigned long m_workerRequestIdentifier;
Nit: { 0 } or make it std::optional?
> Source/WebCore/loader/WorkerThreadableLoader.h:121 > + NetworkLoadMetrics m_networkLoadMetrics;
Ditto.
Build Bot
Comment 13
2017-11-10 12:32:32 PST
Comment hidden (obsolete)
Comment on
attachment 326610
[details]
[PATCH] Proposed Fix
Attachment 326610
[details]
did not pass mac-ews (mac): Output:
http://webkit-queues.webkit.org/results/5180637
New failing tests: http/tests/websocket/tests/hybi/inspector/resolveWebSocket.html
Build Bot
Comment 14
2017-11-10 12:32:34 PST
Comment hidden (obsolete)
Created
attachment 326615
[details]
Archive of layout-test-results from ews103 for mac-elcapitan The attached test failures were seen while running run-webkit-tests on the mac-ews. Bot: ews103 Port: mac-elcapitan Platform: Mac OS X 10.11.6
Build Bot
Comment 15
2017-11-10 12:39:42 PST
Comment hidden (obsolete)
Comment on
attachment 326610
[details]
[PATCH] Proposed Fix
Attachment 326610
[details]
did not pass mac-wk2-ews (mac-wk2): Output:
http://webkit-queues.webkit.org/results/5180626
New failing tests: http/tests/websocket/tests/hybi/inspector/resolveWebSocket.html svg/wicd/test-rightsizing-a.xhtml
Build Bot
Comment 16
2017-11-10 12:39:43 PST
Comment hidden (obsolete)
Created
attachment 326616
[details]
Archive of layout-test-results from ews104 for mac-elcapitan-wk2 The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews. Bot: ews104 Port: mac-elcapitan-wk2 Platform: Mac OS X 10.11.6
Joseph Pecoraro
Comment 17
2017-11-10 13:03:09 PST
Comment on
attachment 326610
[details]
[PATCH] Proposed Fix View in context:
https://bugs.webkit.org/attachment.cgi?id=326610&action=review
> Source/WebCore/inspector/agents/InspectorNetworkAgent.cpp:832 > if (IdentifiersFactory::requestId(channel->identifier()) != requestId)
Oops this should be `==` now to fix the test.
Joseph Pecoraro
Comment 18
2017-11-10 13:11:17 PST
Comment on
attachment 326536
[details]
[PATCH] Proposed Fix View in context:
https://bugs.webkit.org/attachment.cgi?id=326536&action=review
>> Source/WebCore/inspector/InspectorInstrumentation.h:181 >> + static void willSendRequest(WorkerGlobalScope&, unsigned long identifier, ResourceRequest&); > > Might want to comment here that these are for SW, not for web workers that have a page. > > If these are truly only for SW and we don't intend to reroute web workers through this code path, then these new things should be guarded with ENABLE(SERVICE_WORKER) so that's obvious.
These can be used for a DedicatedWorker and we may transition to that eventually. Right now its harmless for a DedicatedWorker since there will never be an active NetworkAgent in the InstrumentingAgents for a DedicatedWorker, only a ServiceWorker. That said, this would allow us to log console warnings for failed loads in DedicatedWorkers via didFailLoading.
>> Source/WebCore/inspector/WorkerInspectorController.h:75 >> + void createLazyAgents(); > > I find this name a little weird. Wouldn't we normally call this createAgentsIfNeeded or ensureAgents() ?
Hmm, I'll move in that direction in a follow-up. Right now we share the same names as the Page's InspectorController and I can move them all at once and try to make a few more lazy.
>> Source/WebCore/inspector/agents/InspectorNetworkAgent.cpp:619 >> + // FIXME: Worker support. > > What would the initiator be once this is finished? A new type?
We just need to be able to get a JavaScript backtrace from a WorkerThread instead of assuming the MainThread (`JSMainThreadExecState::currentState()` below).
>> Source/WebCore/inspector/agents/InspectorNetworkAgent.cpp:721 >> + ASSERT(is<WebSocketChannel>(webSocket->channel().get())); > > This seems more strict about the subtype. Is that okay?
We expect activeWebSockets() to return us a list of WebSockets that have channels. This is just asserting that.
>> Source/WebCore/inspector/agents/InspectorNetworkAgent.cpp:853 >> + // FIXME: <
https://webkit.org/b/168475
> Web Inspector: Correctly display iframe's and worker's WebSockets > > Why would this not work for iframe websockets? an iframe has a document..?
The frontend doesn't properly associate an iframe's WebSocket with the iframe.
>> Source/WebCore/inspector/agents/page/PageNetworkAgent.cpp:77 >> + if (document->page() != &m_pageAgent->page()) > > This comment makes more sense given this condition. It is horrifying we don't support this, though.
We show WebSockets in iframe, but we don't associate it with the frame. I believe the frontend just thinks its top level.
>> Source/WebCore/loader/WorkerThreadableLoader.cpp:216 >> + InspectorInstrumentation::didReceiveData(downcast<WorkerGlobalScope>(context), workerRequestIdentifier, vector.data(), vector.size()); > > ,...because this reads poorly with 'vector'
Agreed.
>> Source/WebCore/loader/WorkerThreadableLoader.h:120 >> + unsigned long m_workerRequestIdentifier; > > Nit: { 0 } or make it std::optional?
This always gets initialized in the constructor, but I can put a 0 here.
Joseph Pecoraro
Comment 19
2017-11-10 13:13:51 PST
Created
attachment 326621
[details]
[PATCH] Proposed Fix
Build Bot
Comment 20
2017-11-10 13:16:02 PST
Comment hidden (obsolete)
Attachment 326621
[details]
did not pass style-queue: ERROR: Source/WebCore/loader/WorkerThreadableLoader.cpp:110: Wrong number of spaces before statement. (expected: 8) [whitespace/indent] [4] Total errors found: 1 in 27 files If any of these errors are false positives, please file a bug against check-webkit-style.
Blaze Burg
Comment 21
2017-11-13 11:34:38 PST
Comment on
attachment 326621
[details]
[PATCH] Proposed Fix r=me
youenn fablet
Comment 22
2017-11-13 12:20:07 PST
LGTM too. Some potential nits below. View in context:
https://bugs.webkit.org/attachment.cgi?id=326621&action=review
> Source/WebCore/inspector/agents/page/PageNetworkAgent.h:39 > + String loaderIdentifier(DocumentLoader*) override;
I believe style says to use final in that case.
> Source/WebCore/inspector/agents/worker/WorkerNetworkAgent.h:35 > + WorkerNetworkAgent(WorkerAgentContext&);
explicit?
> Source/WebCore/inspector/agents/worker/WorkerNetworkAgent.h:43 > + ScriptExecutionContext* scriptExecutionContext(ErrorString&, const String& frameId) override;
final as well?
> Source/WebCore/loader/WorkerThreadableLoader.cpp:202 > + ASSERT(context.isWorkerGlobalScope());
Probably somehow redundant with the downcast below, maybe put the downcast upfront would be better? Ditto in other places.
> Source/WebCore/workers/WorkerGlobalScope.h:67 > + String identifier() const { return m_identifier; }
const String&
Devin Rousso
Comment 23
2017-11-13 12:48:54 PST
Comment on
attachment 326621
[details]
[PATCH] Proposed Fix View in context:
https://bugs.webkit.org/attachment.cgi?id=326621&action=review
Looks good! My only general comment is that I would prefer using std::optional<DocumentLoader&> instead of DocumentLoader* (or even a Ref<DocumentLoader>. The reason for this is based on what was discussed at the WebKit Contributors Meeting, and that we should try to avoid adding more raw pointers and use our own controllers where able. I think this is fine as it is, as we don't save the DocumentLoader, but if we need to in the future it would help avoid potential memory leaks or null-dereferences.
> Source/WebCore/ChangeLog:19 > + This patch add InspectorInstrumentation networking hooks for workers inside
Typo: adds
> Source/WebCore/ChangeLog:97 > + Drive-by use a move.
Drive-by: use a move.
> Source/WebCore/ChangeLog:142 > + Add some assertions for all Worker agents for clarify.
Typo: clarity.
> Source/WebCore/ChangeLog:154 > + * workers/WorkerMessagingProxy.h:
NIT: I typically move the *.h above the *.cpp so it's easier to read.
> Source/WebCore/ChangeLog:157 > + * workers/service/context/ServiceWorkerThreadProxy.h:
Ditto (154).
> Source/WebCore/inspector/WorkerInspectorController.cpp:129 > + InspectorInstrumentation::frontendDeleted();
Do we also want to stop the m_executionStopwatch, or is that not a problem?
> Source/WebCore/inspector/agents/InspectorNetworkAgent.h:117 > + // Subclasses.
Is this comment necessary?
youenn fablet
Comment 24
2017-11-13 14:36:57 PST
> Looks good! My only general comment is that I would prefer using > std::optional<DocumentLoader&> instead of DocumentLoader* (or even a > Ref<DocumentLoader>. The reason for this is based on what was discussed at > the WebKit Contributors Meeting, and that we should try to avoid adding more > raw pointers and use our own controllers where able. I think this is fine > as it is, as we don't save the DocumentLoader, but if we need to in the > future it would help avoid potential memory leaks or null-dereferences.
I am not sure of this. There also was some discussion on the mailing list, going in the direction of keeping raw pointers here. To me, references and raw pointers have the same security risks, it is just that one may be null and not the other.
Joseph Pecoraro
Comment 25
2017-11-13 14:43:42 PST
Comment on
attachment 326621
[details]
[PATCH] Proposed Fix View in context:
https://bugs.webkit.org/attachment.cgi?id=326621&action=review
>> Source/WebCore/ChangeLog:154 >> + * workers/WorkerMessagingProxy.h: > > NIT: I typically move the *.h above the *.cpp so it's easier to read.
I do as well, but normally only when I move things around (like I did with pageNetworkAgent WorkerNetworkAgent above). I'll do it here and try to do more in the future. Maybe we should tweak prepare-ChangeLog (or make it an option).
>> Source/WebCore/inspector/WorkerInspectorController.cpp:129 >> + InspectorInstrumentation::frontendDeleted(); > > Do we also want to stop the m_executionStopwatch, or is that not a problem?
Not a problem. A Stopwatch is just a few numbers so there isn't any active work that we need to stop and we know that the next time we get a frontend we will restart the stopwatch so it'll be good then.
Joseph Pecoraro
Comment 26
2017-11-13 15:18:02 PST
<
https://trac.webkit.org/r224788
>
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug