RESOLVED FIXED 217153
Add basic infrastructure for AudioWorklet
https://bugs.webkit.org/show_bug.cgi?id=217153
Summary Add basic infrastructure for AudioWorklet
Chris Dumez
Reported 2020-09-30 16:16:34 PDT
Attachments
Patch (150.26 KB, patch)
2020-09-30 17:20 PDT, Chris Dumez
no flags
Patch (150.32 KB, patch)
2020-09-30 17:24 PDT, Chris Dumez
no flags
Patch (158.59 KB, patch)
2020-09-30 17:41 PDT, Chris Dumez
ews-feeder: commit-queue-
Patch (159.68 KB, patch)
2020-09-30 17:49 PDT, Chris Dumez
ews-feeder: commit-queue-
Patch (159.87 KB, patch)
2020-09-30 18:09 PDT, Chris Dumez
ews-feeder: commit-queue-
Patch (160.92 KB, patch)
2020-09-30 19:00 PDT, Chris Dumez
ews-feeder: commit-queue-
Patch (160.74 KB, patch)
2020-09-30 19:46 PDT, Chris Dumez
no flags
Patch (160.73 KB, patch)
2020-09-30 19:49 PDT, Chris Dumez
ews-feeder: commit-queue-
Patch (162.11 KB, patch)
2020-09-30 20:42 PDT, Chris Dumez
no flags
Patch (162.65 KB, patch)
2020-10-01 08:24 PDT, Chris Dumez
ews-feeder: commit-queue-
Patch (164.01 KB, patch)
2020-10-01 09:07 PDT, Chris Dumez
ews-feeder: commit-queue-
Patch (165.93 KB, patch)
2020-10-01 09:45 PDT, Chris Dumez
no flags
Patch (165.95 KB, patch)
2020-10-01 09:52 PDT, Chris Dumez
no flags
Patch (159.62 KB, patch)
2020-10-01 12:30 PDT, Chris Dumez
no flags
Patch (163.84 KB, patch)
2020-10-01 14:43 PDT, Chris Dumez
no flags
Chris Dumez
Comment 1 2020-09-30 17:20:24 PDT
Chris Dumez
Comment 2 2020-09-30 17:24:38 PDT
Chris Dumez
Comment 3 2020-09-30 17:41:33 PDT
Chris Dumez
Comment 4 2020-09-30 17:49:00 PDT
Chris Dumez
Comment 5 2020-09-30 18:09:58 PDT
Chris Dumez
Comment 6 2020-09-30 19:00:57 PDT
Chris Dumez
Comment 7 2020-09-30 19:46:21 PDT
Chris Dumez
Comment 8 2020-09-30 19:49:10 PDT
Chris Dumez
Comment 9 2020-09-30 20:42:36 PDT
Chris Dumez
Comment 10 2020-10-01 08:24:18 PDT
Chris Dumez
Comment 11 2020-10-01 09:07:38 PDT
Chris Dumez
Comment 12 2020-10-01 09:45:43 PDT
Chris Dumez
Comment 13 2020-10-01 09:52:18 PDT
Sam Weinig
Comment 14 2020-10-01 12:12:07 PDT
Comment on attachment 410240 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=410240&action=review > Source/WebCore/Modules/webaudio/AudioWorkletGlobalScope.idl:31 > + EnabledAtRuntime=AudioWorklet, Given that you can't actually created a AudioWorklet unless this is true, I don't think this is necessary. > Source/WebCore/Modules/webaudio/AudioWorkletNode.idl:31 > Conditional=WEB_AUDIO, > - EnabledBySetting=AudioWorklet, > + EnabledAtRuntime=AudioWorklet, Why is this needed? Seems like this should only ever called on the main thread.
Chris Dumez
Comment 15 2020-10-01 12:17:52 PDT
Comment on attachment 410240 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=410240&action=review >> Source/WebCore/Modules/webaudio/AudioWorkletGlobalScope.idl:31 >> + EnabledAtRuntime=AudioWorklet, > > Given that you can't actually created a AudioWorklet unless this is true, I don't think this is necessary. Oh, I think you are right. If so, I can probably keep using a setting. Let me give it a try.
Chris Dumez
Comment 16 2020-10-01 12:30:32 PDT
Sam Weinig
Comment 17 2020-10-01 14:19:28 PDT
Comment on attachment 410258 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=410258&action=review > Source/WebCore/Modules/webaudio/AudioWorkletMessagingProxy.cpp:46 > + auto* document = worklet.document(); > + auto* frame = document->frame(); > + auto jsRuntimeFlags = frame ? frame->settings().javaScriptRuntimeFlags() : JSC::RuntimeFlags(); You can get settings directly from Document, and it is guaranteed to be non-null. > Source/WebCore/Modules/webaudio/AudioWorkletMessagingProxy.h:57 > + WeakPtr<AudioWorklet> m_worklet; Is this used? > Source/WebCore/Modules/webaudio/AudioWorkletThread.cpp:96 > + scriptController->scheduleExecutionTermination(); > + scriptController->forbidExecution(); What ensures scriptController is non-null here? > Source/WebCore/Modules/webaudio/AudioWorkletThread.h:48 > +struct WorkletParameters { > +public: > + URL windowURL; > + JSC::RuntimeFlags jsRuntimeFlags; > + > + WorkletParameters isolatedCopy() const; > +}; This should get its own file, also no need for the explicit public:. > Source/WebCore/Modules/webaudio/OfflineAudioDestinationNode.cpp:129 > + // FIXME: We should probably limit the number of threads we create for offline audio. > + m_renderThread = Thread::create("offline renderer", WTFMove(offThreadRendering), ThreadType::Audio); > return { }; Should we be using explicit threads at all here? Seems like a WorkQueue style option might work better (especially if these don't need to be "realish-time". > Source/WebCore/bindings/scripts/preprocess-idls.pl:101 > +$audioWorkletGlobalScopeConstructorsFile = CygwinPathIfNeeded($audioWorkletGlobalScopeConstructorsFile); If we are going to keep adding new types of global scopes, we really need to work out a better model than this copy and paste silliness.
Chris Dumez
Comment 18 2020-10-01 14:27:48 PDT
Comment on attachment 410258 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=410258&action=review >> Source/WebCore/Modules/webaudio/AudioWorkletMessagingProxy.cpp:46 >> + auto jsRuntimeFlags = frame ? frame->settings().javaScriptRuntimeFlags() : JSC::RuntimeFlags(); > > You can get settings directly from Document, and it is guaranteed to be non-null. Nice, will fix. >> Source/WebCore/Modules/webaudio/AudioWorkletMessagingProxy.h:57 >> + WeakPtr<AudioWorklet> m_worklet; > > Is this used? Hmm, maybe not yet. I guess I can omit it until it is actually needed. >> Source/WebCore/Modules/webaudio/AudioWorkletThread.cpp:96 >> + scriptController->forbidExecution(); > > What ensures scriptController is non-null here? The AudioWorkletGlobalScope constructs it unconditionally and we literally just constructed the AudioWorkletGlobalScope. The script only gets nulled out when prepareForDestruction() gets called. >> Source/WebCore/Modules/webaudio/AudioWorkletThread.h:48 >> +}; > > This should get its own file, also no need for the explicit public:. Ok. >> Source/WebCore/Modules/webaudio/OfflineAudioDestinationNode.cpp:129 >> return { }; > > Should we be using explicit threads at all here? Seems like a WorkQueue style option might work better (especially if these don't need to be "realish-time". This is pre-existing code so I'd rather not change this at this point. Switching to a WorkQueue would also not be a trivial effort I believe because the WorkQueue's backing thread can change and we have assertions everywhere to make sure we are on the audio rendering thread. >> Source/WebCore/bindings/scripts/preprocess-idls.pl:101 >> +$audioWorkletGlobalScopeConstructorsFile = CygwinPathIfNeeded($audioWorkletGlobalScopeConstructorsFile); > > If we are going to keep adding new types of global scopes, we really need to work out a better model than this copy and paste silliness. Agreed. I did not anticipate we would add so many new ones :)
Chris Dumez
Comment 19 2020-10-01 14:43:30 PDT
Sam Weinig
Comment 20 2020-10-01 14:47:48 PDT
(In reply to Chris Dumez from comment #18) > > >> Source/WebCore/Modules/webaudio/OfflineAudioDestinationNode.cpp:129 > >> return { }; > > > > Should we be using explicit threads at all here? Seems like a WorkQueue style option might work better (especially if these don't need to be "realish-time". > > This is pre-existing code so I'd rather not change this at this point. > Switching to a WorkQueue would also not be a trivial effort I believe > because the WorkQueue's backing thread can change and we have assertions > everywhere to make sure we are on the audio rendering thread. > My comment was only in relation to the comment you added, not about making a code change now.
Chris Dumez
Comment 21 2020-10-01 14:49:55 PDT
Comment on attachment 410258 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=410258&action=review > Source/WebCore/Modules/webaudio/OfflineAudioDestinationNode.cpp:-100 > - // FIXME: We should probably limit the number of threads we create for offline audio. I did not add the comment, it was already here. As I said, this is pre-existing code that I moved :)
Sam Weinig
Comment 22 2020-10-01 14:51:30 PDT
(In reply to Chris Dumez from comment #21) > Comment on attachment 410258 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=410258&action=review > > > Source/WebCore/Modules/webaudio/OfflineAudioDestinationNode.cpp:-100 > > - // FIXME: We should probably limit the number of threads we create for offline audio. > > I did not add the comment, it was already here. As I said, this is > pre-existing code that I moved :) Ah, ok.
Chris Dumez
Comment 23 2020-10-01 16:21:15 PDT
Comment on attachment 410270 [details] Patch Clearing flags on attachment: 410270 Committed r267859: <https://trac.webkit.org/changeset/267859>
Chris Dumez
Comment 24 2020-10-01 16:21:18 PDT
All reviewed patches have been landed. Closing bug.
Radar WebKit Bug Importer
Comment 25 2020-10-01 16:22:23 PDT
Note You need to log in before you can comment on or make changes to this bug.