RESOLVED FIXED Bug 170299
We should pause silent WebAudio rendering in background tabs
https://bugs.webkit.org/show_bug.cgi?id=170299
Summary We should pause silent WebAudio rendering in background tabs
Chris Dumez
Reported 2017-03-30 13:40:13 PDT
We should pause silent WebAudio rendering in background tabs since it uses CPU and is not observable by the user.
Attachments
WIP Patch (17.51 KB, patch)
2017-03-30 14:29 PDT, Chris Dumez
no flags
WIP Patch (13.38 KB, patch)
2017-03-30 14:33 PDT, Chris Dumez
no flags
WIP Patch (16.90 KB, patch)
2017-03-30 15:47 PDT, Chris Dumez
no flags
WIP Patch (16.16 KB, patch)
2017-03-30 15:48 PDT, Chris Dumez
no flags
Patch (18.74 KB, patch)
2017-03-30 16:25 PDT, Chris Dumez
no flags
Patch (20.13 KB, patch)
2017-03-30 18:25 PDT, Chris Dumez
no flags
Chris Dumez
Comment 1 2017-03-30 13:40:25 PDT
Chris Dumez
Comment 2 2017-03-30 14:29:33 PDT
Created attachment 305902 [details] WIP Patch
Chris Dumez
Comment 3 2017-03-30 14:33:26 PDT
Created attachment 305904 [details] WIP Patch
Chris Dumez
Comment 4 2017-03-30 15:47:59 PDT
Created attachment 305915 [details] WIP Patch
Chris Dumez
Comment 5 2017-03-30 15:48:37 PDT
Created attachment 305917 [details] WIP Patch
Chris Dumez
Comment 6 2017-03-30 16:25:44 PDT
Chris Dumez
Comment 7 2017-03-30 18:25:46 PDT
Eric Carlson
Comment 8 2017-04-01 08:23:21 PDT
Comment on attachment 305933 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=305933&action=review > Source/WebCore/dom/VisibilityChangeClient.h:35 > +class VisibilityChangeClient { > +public: > + virtual ~VisibilityChangeClient() { } > + > + virtual void visibilityStateChanged() = 0; > +}; Anders recently suggested I use a lambda rather than a new "client" class for an asynch callback. Maybe you should do the same thing here as long as you have to change all of the call sites?
Chris Dumez
Comment 9 2017-04-01 09:04:47 PDT
(In reply to Eric Carlson from comment #8) > Comment on attachment 305933 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=305933&action=review > > > Source/WebCore/dom/VisibilityChangeClient.h:35 > > +class VisibilityChangeClient { > > +public: > > + virtual ~VisibilityChangeClient() { } > > + > > + virtual void visibilityStateChanged() = 0; > > +}; > > Anders recently suggested I use a lambda rather than a new "client" class > for an asynch callback. Maybe you should do the same thing here as long as > you have to change all of the call sites? Doesn't this make unregistering from the document a bit more awkward though? Previous, we did: document()->unregisterForVisibilityStateChangedCallbacks(this); But now, I think we would need to unregister the lambda, which I think would require HTMLMediaElement / AudioContext to keep the lambda they register in a member so they can unregister it later. Or am I missing something easier?
Chris Dumez
Comment 10 2017-04-01 09:06:27 PDT
(In reply to Eric Carlson from comment #8) > Comment on attachment 305933 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=305933&action=review > > > Source/WebCore/dom/VisibilityChangeClient.h:35 > > +class VisibilityChangeClient { > > +public: > > + virtual ~VisibilityChangeClient() { } > > + > > + virtual void visibilityStateChanged() = 0; > > +}; > > Anders recently suggested I use a lambda rather than a new "client" class > for an asynch callback. Maybe you should do the same thing here as long as > you have to change all of the call sites? Note that I totally agree lambdas are better for callback to async operations. But this is not exactly the case for this code. We just want to register / unregister a listener for a specific event (visibility change).
Eric Carlson
Comment 11 2017-04-01 16:51:40 PDT
Comment on attachment 305933 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=305933&action=review >>>> Source/WebCore/dom/VisibilityChangeClient.h:35 >>>> +}; >>> >>> Anders recently suggested I use a lambda rather than a new "client" class for an asynch callback. Maybe you should do the same thing here as long as you have to change all of the call sites? >> >> Doesn't this make unregistering from the document a bit more awkward though? Previous, we did: >> document()->unregisterForVisibilityStateChangedCallbacks(this); >> >> But now, I think we would need to unregister the lambda, which I think would require HTMLMediaElement / AudioContext to keep the lambda they register in a member so they can unregister it later. Or am I missing something easier? > > Note that I totally agree lambdas are better for callback to async operations. But this is not exactly the case for this code. We just want to register / unregister a listener for a specific event (visibility change). I agree, it would be more awkward to use a lambda in a case like this.
Chris Dumez
Comment 12 2017-04-01 17:55:25 PDT
Comment on attachment 305933 [details] Patch Clearing flags on attachment: 305933 Committed r214721: <http://trac.webkit.org/changeset/214721>
Chris Dumez
Comment 13 2017-04-01 17:55:26 PDT
All reviewed patches have been landed. Closing bug.
Note You need to log in before you can comment on or make changes to this bug.