ASSIGNED 217724
Hook AudioWorklets up to WebInspector
https://bugs.webkit.org/show_bug.cgi?id=217724
Summary Hook AudioWorklets up to WebInspector
Chris Dumez
Reported 2020-10-14 12:11:59 PDT
Hook AudioWorklets to WebInspector, similarly to Web Workers.
Attachments
Patch (105.67 KB, patch)
2020-10-14 12:14 PDT, Chris Dumez
no flags
Patch (105.68 KB, patch)
2020-10-14 12:18 PDT, Chris Dumez
no flags
Patch (105.69 KB, patch)
2020-10-14 12:19 PDT, Chris Dumez
no flags
Patch (105.73 KB, patch)
2020-10-14 14:06 PDT, Chris Dumez
no flags
Patch (100.82 KB, patch)
2020-10-19 17:07 PDT, Chris Dumez
no flags
Patch (84.68 KB, patch)
2020-10-21 08:19 PDT, Chris Dumez
no flags
Patch (86.39 KB, patch)
2020-10-21 08:44 PDT, Chris Dumez
no flags
Patch (84.30 KB, patch)
2020-10-21 09:03 PDT, Chris Dumez
no flags
Patch (83.49 KB, patch)
2020-10-21 10:04 PDT, Chris Dumez
no flags
Patch (82.97 KB, patch)
2020-10-21 14:44 PDT, Chris Dumez
no flags
Patch (85.67 KB, patch)
2020-10-22 16:00 PDT, Chris Dumez
no flags
Patch (42.02 KB, patch)
2020-10-23 08:05 PDT, Chris Dumez
no flags
Patch (41.92 KB, patch)
2020-10-23 12:27 PDT, Chris Dumez
no flags
Chris Dumez
Comment 1 2020-10-14 12:14:24 PDT
Chris Dumez
Comment 2 2020-10-14 12:18:28 PDT
Chris Dumez
Comment 3 2020-10-14 12:19:33 PDT
Geoffrey Garen
Comment 4 2020-10-14 13:39:48 PDT
Seems like the custom paint worklet test is crashing.
Chris Dumez
Comment 5 2020-10-14 14:06:14 PDT
Devin Rousso
Comment 6 2020-10-14 14:20:41 PDT
Comment on attachment 411370 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=411370&action=review > Source/WebCore/Modules/webaudio/AudioWorkletGlobalScope.h:86 > + std::unique_ptr<WorkerInspectorController> m_inspectorController; Would it be worth it (assuming it's possible) to move each of the subclass members/methods onto the base `WorkerOrWorkletGlobalScope`? Are there any worklets that are somehow not inspectable? Also, do worklets have `setTimeout`/`setInterval`/`requestAnimationFrame`? I ask because the `DOMDebugger` has different functionality for event/DOM breakpoints depending on whether the target is a page or a worker (e.g. DOM breakpoints and animation frame breakpoints are not supported for worker targets). > Source/WebCore/inspector/InspectorInstrumentation.cpp:1334 > + // FIXME: Add support for PaintWorklets. Why isn't this supported? > Source/WebCore/workers/WorkerInspectorProxy.cpp:49 > +#endif > + return downcast<WorkerGlobalScope>(context).inspectorController(); What about `PaintWorkletGlobalScope`?
Chris Dumez
Comment 7 2020-10-14 14:41:12 PDT
(In reply to Devin Rousso from comment #6) > Comment on attachment 411370 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=411370&action=review > > > Source/WebCore/Modules/webaudio/AudioWorkletGlobalScope.h:86 > > + std::unique_ptr<WorkerInspectorController> m_inspectorController; > > Would it be worth it (assuming it's possible) to move each of the subclass > members/methods onto the base `WorkerOrWorkletGlobalScope`? Yes, this is planned for a follow-up. > Are there any > worklets that are somehow not inspectable? The main issue is that some worklets (like AudioWorklets) use threading and are thus very similar to Web Workers. Other worklets (like PaintWorklets) do not use threading and are thus very different. > Also, do worklets have `setTimeout`/`setInterval`/`requestAnimationFrame`? > I ask because the `DOMDebugger` has different functionality for event/DOM > breakpoints depending on whether the target is a page or a worker (e.g. DOM > breakpoints and animation frame breakpoints are not supported for worker > targets). No, worklets do not have those AFAIK. > > > Source/WebCore/inspector/InspectorInstrumentation.cpp:1334 > > + // FIXME: Add support for PaintWorklets. > > Why isn't this supported? PaintWorklets do not use threading and are thus very different from AudioWorklets and workers. I am working on AudioWorklets not PaintWorklets so I focused on getting AudioWorklets working (not PaintWorklets). I don't believe I made things worse for PaintWorklets. > > > Source/WebCore/workers/WorkerInspectorProxy.cpp:49 > > +#endif > > + return downcast<WorkerGlobalScope>(context).inspectorController(); > > What about `PaintWorkletGlobalScope`? PaintWorkets do not use threading. Thus PaintWorkletGlobalScope does not use WorkerInspectorProxy.
Devin Rousso
Comment 8 2020-10-14 15:07:27 PDT
Comment on attachment 411370 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=411370&action=review >>> Source/WebCore/inspector/InspectorInstrumentation.cpp:1334 >>> + // FIXME: Add support for PaintWorklets. >> >> Why isn't this supported? > > PaintWorklets do not use threading and are thus very different from AudioWorklets and workers. I am working on AudioWorklets not PaintWorklets so I focused on getting AudioWorklets working (not PaintWorklets). I don't believe I made things worse for PaintWorklets. Do PaintWorklet have a separate execution context? It's fine by me to do this as a followup/FIXME, but if you do that then please make a bug and include it's URL/title here. >> Also, do worklets have `setTimeout`/`setInterval`/`requestAnimationFrame`? I ask because the `DOMDebugger` has different functionality for event/DOM breakpoints depending on whether the target is a page or a worker (e.g. DOM breakpoints and animation frame breakpoints are not supported for worker targets). > > No, worklets do not have those AFAIK. In that case, we ideally should introduce a new target type `"worklet"` (similar to the existing `"worker"`) so that we can properly annotate any protocol commands/events and so that the frontend can differentiate between workers and worklets (see r262302 for an example of how this has been done). I don't think this is required in order to make inspection work, but we should do it for correctness. I'm OK with it being a followup bug.
Chris Dumez
Comment 9 2020-10-14 15:27:06 PDT
(In reply to Devin Rousso from comment #8) > Comment on attachment 411370 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=411370&action=review > > >>> Source/WebCore/inspector/InspectorInstrumentation.cpp:1334 > >>> + // FIXME: Add support for PaintWorklets. > >> > >> Why isn't this supported? > > > > PaintWorklets do not use threading and are thus very different from AudioWorklets and workers. I am working on AudioWorklets not PaintWorklets so I focused on getting AudioWorklets working (not PaintWorklets). I don't believe I made things worse for PaintWorklets. > > Do PaintWorklet have a separate execution context? It's fine by me to do > this as a followup/FIXME, but if you do that then please make a bug and > include it's URL/title here. Yes, PaintWorklets have their own execution context. FYI, we only have a very partial implementation of PaintWorklets. It was added a while ago by an intern and never finished. The feature is not shipping. I personally don't have plans to work on paint worklets. > > >> Also, do worklets have `setTimeout`/`setInterval`/`requestAnimationFrame`? I ask because the `DOMDebugger` has different functionality for event/DOM breakpoints depending on whether the target is a page or a worker (e.g. DOM breakpoints and animation frame breakpoints are not supported for worker targets). > > > > No, worklets do not have those AFAIK. > In that case, we ideally should introduce a new target type `"worklet"` > (similar to the existing `"worker"`) so that we can properly annotate any > protocol commands/events and so that the frontend can differentiate between > workers and worklets (see r262302 for an example of how this has been done). > I don't think this is required in order to make inspection work, but we > should do it for correctness. I'm OK with it being a followup bug. I'd appreciate if this could be a follow-up. I am doing basic hook up here but I am not WebInspector expert and I will likely need help to do better.
Chris Dumez
Comment 10 2020-10-15 12:33:22 PDT
Comment on attachment 411370 [details] Patch Ping review?
Devin Rousso
Comment 11 2020-10-15 16:49:57 PDT
Comment on attachment 411370 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=411370&action=review r-, as this definitely needs tests. We need to make sure that basic JavaScript debugging works as expected. I'd suggest copying most of tests in `LayoutTests/inspector/worker` (some of them might need to be changed for `setTimeout`/`setInterval`/etc. not existing) but using a `AudioWorklet` (and `PaintWorklet` if you have the time/willpower) instead. I'd also check to make sure that the execution context for the workout appears in the execution context picker to the right of the Console Prompt <https://webkit.org/web-inspector/web-inspector-interface/#console-prompt>. > > > > Also, do worklets have `setTimeout`/`setInterval`/`requestAnimationFrame`? I ask because the `DOMDebugger` has different functionality for event/DOM breakpoints depending on whether the target is a page or a worker (e.g. DOM breakpoints and animation frame breakpoints are not supported for worker targets). > > > No, worklets do not have those AFAIK. > > In that case, we ideally should introduce a new target type `"worklet"` (similar to the existing `"worker"`) so that we can properly annotate any protocol commands/events and so that the frontend can differentiate between workers and worklets (see r262302 for an example of how this has been done). I don't think this is required in order to make inspection work, but we should do it for correctness. I'm OK with it being a followup bug. > I'd appreciate if this could be a follow-up. I am doing basic hook up here but I am not WebInspector expert and I will likely need help to do better. Followup is fine :) All I ask is that you create a bug for that change and add it's URL/title in this patch as a FIXME comment, just so that there's a record of it. > Source/WebCore/worklets/PaintWorkletGlobalScope.h:42 > +class InspectorController; So this isn't needed anymore because PaintWorklet doesn't use a separate thread, meaning that all activity should eventually go through `Page::inspectorController` right? > Source/WebCore/worklets/WorkletGlobalScope.cpp:-166 > - if (!m_document || isJSExecutionForbidden() || !message) What happened to `isJSExecutionForbidden()`? > Source/WebCore/worklets/WorkletGlobalScope.cpp:172 > + m_document->addConsoleMessage(makeUnique<Inspector::ConsoleMessage>(message->source(), message->type(), message->level(), message->message(), 0)); Odd that we're creating a new message with the same data. I wonder if this is really necessary 🤔 > Source/WebCore/worklets/WorkletGlobalScope.cpp:192 > + if (m_document) { Should this also check `isContextThread()`? > Source/WebCore/worklets/WorkletGlobalScope.cpp:193 > + m_document->addMessage(source, level, messageText, sourceURL, lineNumber, columnNumber, WTFMove(callStack), nullptr, requestIdentifier); Should this also pass `state`?
Chris Dumez
Comment 12 2020-10-15 16:52:20 PDT
(In reply to Devin Rousso from comment #11) > Comment on attachment 411370 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=411370&action=review > > r-, as this definitely needs tests. We need to make sure that basic > JavaScript debugging works as expected. I'd suggest copying most of tests > in `LayoutTests/inspector/worker` (some of them might need to be changed for > `setTimeout`/`setInterval`/etc. not existing) but using a `AudioWorklet` > (and `PaintWorklet` if you have the time/willpower) instead. I'd also check > to make sure that the execution context for the workout appears in the > execution context picker to the right of the Console Prompt > <https://webkit.org/web-inspector/web-inspector-interface/#console-prompt>. Ok, then I'd like someone with Web Inspector knowledge to take over. I did what I could to save work.
Chris Dumez
Comment 13 2020-10-19 17:07:33 PDT
Blaze Burg
Comment 14 2020-10-20 09:44:41 PDT
(In reply to Chris Dumez from comment #12) > (In reply to Devin Rousso from comment #11) > > Comment on attachment 411370 [details] > > Patch > > > > View in context: > > https://bugs.webkit.org/attachment.cgi?id=411370&action=review > > > > r-, as this definitely needs tests. We need to make sure that basic > > JavaScript debugging works as expected. I'd suggest copying most of tests > > in `LayoutTests/inspector/worker` (some of them might need to be changed for > > `setTimeout`/`setInterval`/etc. not existing) but using a `AudioWorklet` > > (and `PaintWorklet` if you have the time/willpower) instead. I'd also check > > to make sure that the execution context for the workout appears in the > > execution context picker to the right of the Console Prompt > > <https://webkit.org/web-inspector/web-inspector-interface/#console-prompt>. > > > Ok, then I'd like someone with Web Inspector knowledge to take over. I did > what I could to save work. Thank you!
Radar WebKit Bug Importer
Comment 15 2020-10-20 09:45:50 PDT
Chris Dumez
Comment 16 2020-10-21 08:19:47 PDT
Chris Dumez
Comment 17 2020-10-21 08:44:20 PDT
Chris Dumez
Comment 18 2020-10-21 09:03:12 PDT
Chris Dumez
Comment 19 2020-10-21 10:04:02 PDT
Chris Dumez
Comment 20 2020-10-21 14:44:20 PDT
Chris Dumez
Comment 21 2020-10-22 16:00:01 PDT
Chris Dumez
Comment 22 2020-10-23 08:05:45 PDT
Darin Adler
Comment 23 2020-10-23 09:31:18 PDT
Comment on attachment 412180 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=412180&action=review > Source/WebCore/workers/WorkerScriptLoader.cpp:53 > + auto& workerOrWorkletGlobalScope = downcast<WorkerOrWorkletGlobalScope>(*scriptExecutionContext); Drive-by thought: Why not just call this "globalScope"? > Source/WebCore/worklets/WorkletGlobalScope.cpp:173 > +void WorkletGlobalScope::didReceiveResponse(unsigned long identifier, const ResourceResponse&) Another drive-by: Strange that this uses "unsigned long" and not "unsigned". Do you know why?
Chris Dumez
Comment 24 2020-10-23 09:39:21 PDT
(In reply to Darin Adler from comment #23) > Comment on attachment 412180 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=412180&action=review > > > Source/WebCore/workers/WorkerScriptLoader.cpp:53 > > + auto& workerOrWorkletGlobalScope = downcast<WorkerOrWorkletGlobalScope>(*scriptExecutionContext); > > Drive-by thought: Why not just call this "globalScope"? Oh right, I updated to globalScope in the patch I landed yesterday but fail to update this patch accordingly. Will fix. > > > Source/WebCore/worklets/WorkletGlobalScope.cpp:173 > > +void WorkletGlobalScope::didReceiveResponse(unsigned long identifier, const ResourceResponse&) > > Another drive-by: Strange that this uses "unsigned long" and not "unsigned". > Do you know why? This all seems to come from the fact that CachedRawResource::identifier() returns an unsigned long. As a result, ThreadableLoader uses unsigned long for identifiers and the WorkerThreadableLoader just matches the type.
Darin Adler
Comment 25 2020-10-23 09:54:11 PDT
Comment on attachment 412180 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=412180&action=review >>> Source/WebCore/worklets/WorkletGlobalScope.cpp:173 >>> +void WorkletGlobalScope::didReceiveResponse(unsigned long identifier, const ResourceResponse&) >> >> Another drive-by: Strange that this uses "unsigned long" and not "unsigned". Do you know why? > > This all seems to come from the fact that CachedRawResource::identifier() returns an unsigned long. As a result, ThreadableLoader uses unsigned long for identifiers and the WorkerThreadableLoader just matches the type. OK. There’s no reason that I am aware of for WebKit to ever use the "unsigned long" type instead of "unsigned"—both are 32-bit unsigned integers—and there is a small downside to doing so (more overloading needed, some possible template bloat) so we should probably change CachedRawResource::identifier.
Chris Dumez
Comment 26 2020-10-23 12:27:56 PDT
Note You need to log in before you can comment on or make changes to this bug.