Intent to Implement and Ship: WebAudio: Allow user to close an AudioContext explicitly

49 views
Skip to first unread message

Raymond Toy

unread,
Jan 30, 2015, 3:39:28 PM1/30/15
to blink-dev
rt...@chromium.org,hong...@chromium.org http://webaudio.github.io/web-audio-api/ An AudioContext can be explicitly closed, thereby releasing any hardware resources associated with the AudioContext. A new method, close(), is added to allow users to close the context. Currently, users have no way of shutting down an AudioContext except by destroying the graph and waiting for GC to collect the AudioContext. This means that the audio hardware is still consuming power and CPU for no reason, which is important for battery life on mobile devices. By adding a new close() method, users can now explicitly destroy the context, saving CPU and power. This has been a common request from developers who want to save power and cpu, or intend to create and destroy many audio contexts as part of their application. (WebAudio has a hard-limit of a few active AudioContexts.) Users do not have to use this, and contexts will get collected (or not) as before. None Yes http://crbug.com/439241 https://www.chromestatus.com/features/5411681005993984 Yes


Chris Harrelson

unread,
Jan 30, 2015, 3:46:58 PM1/30/15
to Raymond Toy, blink-dev
Hi,

Seems reasonable. Is there evidence of support for this change from other browser vendors?

On Fri Jan 30 2015 at 12:39:26 PM 'Raymond Toy' via blink-dev <blin...@chromium.org> wrote:
rt...@chromium.org,hong...@chromium.org http://webaudio.github.io/web-audio-api/ An AudioContext can be explicitly closed, thereby releasing any hardware resources associated with the AudioContext. A new method, close(), is added to allow users to close the context. Currently, users have no way of shutting down an AudioContext except by destroying the graph and waiting for GC to collect the AudioContext. This means that the audio hardware is still consuming power and CPU for no reason, which is important for battery life on mobile devices. By adding a new close() method, users can now explicitly destroy the context, saving CPU and power. This has been a common request from developers who want to save power and cpu, or intend to create and destroy many audio contexts as part of their application. (WebAudio has a hard-limit of a few active AudioContexts.) Users do not have to use this, and contexts will get collected (or not) as before. None Yes http://crbug.com/439241 https://www.chromestatus.com/features/5411681005993984 Yes


To unsubscribe from this group and stop receiving emails from it, send an email to blink-dev+...@chromium.org.

Philip Rogers

unread,
Jan 30, 2015, 4:20:36 PM1/30/15
to Chris Harrelson, Raymond Toy, blink-dev
This seems reasonable to me too. LGTM

PhistucK

unread,
Jan 30, 2015, 4:50:01 PM1/30/15
to Raymond Toy, blink-dev
Looks like you are using an outdated template that does not mention Android WebView as a sixth platform. Where did you get the template from (so it could be updated)?

Just so you know, this intent was a bit confusing, you sometimes write "users" and you sometimes write "developers". At first, I thought you meant that users (that installed the browser) will be able to shut down the AudioContext (without closing a tab) in order to decrease the battery usage.
But you meant users (that use the API), so, developers only.

Anyway, this addition makes sense.


PhistucK

On Fri, Jan 30, 2015 at 10:39 PM, 'Raymond Toy' via blink-dev <blin...@chromium.org> wrote:
rt...@chromium.org,hong...@chromium.org http://webaudio.github.io/web-audio-api/ An AudioContext can be explicitly closed, thereby releasing any hardware resources associated with the AudioContext. A new method, close(), is added to allow users to close the context. Currently, users have no way of shutting down an AudioContext except by destroying the graph and waiting for GC to collect the AudioContext. This means that the audio hardware is still consuming power and CPU for no reason, which is important for battery life on mobile devices. By adding a new close() method, users can now explicitly destroy the context, saving CPU and power. This has been a common request from developers who want to save power and cpu, or intend to create and destroy many audio contexts as part of their application. (WebAudio has a hard-limit of a few active AudioContexts.) Users do not have to use this, and contexts will get collected (or not) as before. None Yes http://crbug.com/439241 https://www.chromestatus.com/features/5411681005993984 Yes


Chris Harrelson

unread,
Jan 30, 2015, 5:14:16 PM1/30/15
to PhistucK, Raymond Toy, blink-dev, Eric Bidelman
@PhistucK: I figured out the stale template issue. Eric (cc'd is going to fix the code here: 


for it.

PhistucK

unread,
Jan 30, 2015, 5:17:48 PM1/30/15
to Chris Harrelson, Raymond Toy, blink-dev, Eric Bidelman
Thank you for the link, I submitted a pull request.


PhistucK

Eric Bidelman

unread,
Jan 30, 2015, 5:22:09 PM1/30/15
to PhistucK, François Beaufort, Chris Harrelson, Raymond Toy, blink-dev
Yep, we're going to update the Intent email template on chromestatus.com:

PhistucK

unread,
Jan 30, 2015, 5:28:34 PM1/30/15
to Eric Bidelman, François Beaufort, Chris Harrelson, Raymond Toy, blink-dev
Well, at least accept my pull request until this happens, because a few intents have already been posted since three days ago and probably a few more will until this is fixed...


PhistucK

François Beaufort

unread,
Feb 2, 2015, 4:20:25 AM2/2/15
to PhistucK, Eric Bidelman, Chris Harrelson, Raymond Toy, blink-dev
Sorry for the late response!
Glad the earlier PR went through.

Here's another PR that updates completely the Intent-To-Ship blink template: https://github.com/GoogleChrome/chromium-dashboard/pull/189

Alex Russell

unread,
Feb 2, 2015, 5:48:40 AM2/2/15
to Raymond Toy, Chris Harrelson, Philip Rogers, blink-dev, Domenic Denicola
This seems reasonable (+1 to explicit control), but I have a question about the design:


Suggests that an exception will be thrown if this method is called on an OfflineAudioContext; why is the Error not sent to the reject handler instead?

Anne van Kesteren

unread,
Feb 2, 2015, 6:39:22 AM2/2/15
to Alex Russell, Raymond Toy, Chris Harrelson, Philip Rogers, blink-dev, Domenic Denicola
On Mon, Feb 2, 2015 at 11:48 AM, 'Alex Russell' via blink-dev
<blin...@chromium.org> wrote:
> This seems reasonable (+1 to explicit control), but I have a question about
> the design:
>
> http://webaudio.github.io/web-audio-api/#widl-AudioContext-close-Promise
>
> Suggests that an exception will be thrown if this method is called on an
> OfflineAudioContext; why is the Error not sent to the reject handler
> instead?

Note that due to the way IDL works throwing an error from an API
algorithm will result in a rejected promise in JavaScript land.


--
https://annevankesteren.nl/

Raymond Toy

unread,
Feb 2, 2015, 1:58:04 PM2/2/15
to Chris Harrelson, blink-dev
On Fri, Jan 30, 2015 at 12:46 PM, Chris Harrelson <chri...@chromium.org> wrote:
Hi,

Seems reasonable. Is there evidence of support for this change from other browser vendors?

I have not heard of any direct support from browser vendors, but there were no objections when this was added to the spec. The discussion occurred here:  https://github.com/WebAudio/web-audio-api/issues/317

Raymond Toy

unread,
Feb 2, 2015, 1:59:06 PM2/2/15
to PhistucK, blink-dev
Yeah, as mentioned, I got it from the dashboard this time. Previously, I used the link from the chromium developers page.

Raymond Toy

unread,
Feb 2, 2015, 2:00:31 PM2/2/15
to Alex Russell, Chris Harrelson, Philip Rogers, blink-dev, Domenic Denicola
On Mon, Feb 2, 2015 at 2:48 AM, Alex Russell <sligh...@google.com> wrote:
This seems reasonable (+1 to explicit control), but I have a question about the design:


Suggests that an exception will be thrown if this method is called on an OfflineAudioContext; why is the Error not sent to the reject handler instead?

Chris Harrelson

unread,
Feb 2, 2015, 2:00:51 PM2/2/15
to Raymond Toy, Alex Russell, Philip Rogers, blink-dev, Domenic Denicola
LGTM

Philip Jägenstedt

unread,
Feb 2, 2015, 10:20:39 PM2/2/15
to Chris Harrelson, Raymond Toy, Alex Russell, Philip Rogers, blink-dev, Domenic Denicola
LGTM3, this sounds simple to implement and useful to Web developers.
Reply all
Reply to author
Forward
0 new messages