Bug 216331 - Port BaseAudioContext to the HTML event loop
Summary: Port BaseAudioContext to the HTML event loop
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Audio (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Chris Dumez
URL:
Keywords: InRadar
Depends on:
Blocks: 212611
  Show dependency treegraph
 
Reported: 2020-09-09 15:40 PDT by Chris Dumez
Modified: 2020-09-10 10:33 PDT (History)
12 users (show)

See Also:


Attachments
Patch (4.13 KB, patch)
2020-09-09 15:41 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (4.41 KB, patch)
2020-09-09 17:51 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (4.51 KB, patch)
2020-09-09 18:43 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (5.27 KB, patch)
2020-09-09 18:46 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (9.87 KB, patch)
2020-09-10 08:49 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (8.49 KB, patch)
2020-09-10 09:24 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Dumez 2020-09-09 15:40:18 PDT
Port BaseAudioContext to the HTML event loop.
Comment 1 Chris Dumez 2020-09-09 15:41:34 PDT
Created attachment 408377 [details]
Patch
Comment 2 Chris Dumez 2020-09-09 17:51:27 PDT
Created attachment 408389 [details]
Patch
Comment 3 Chris Dumez 2020-09-09 18:43:26 PDT
Created attachment 408392 [details]
Patch
Comment 4 Chris Dumez 2020-09-09 18:46:13 PDT
Created attachment 408394 [details]
Patch
Comment 5 Chris Dumez 2020-09-10 08:49:37 PDT
Created attachment 408449 [details]
Patch
Comment 6 Eric Carlson 2020-09-10 09:16:35 PDT
Comment on attachment 408449 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=408449&action=review

> LayoutTests/webaudio/audiocontext-state-interrupted.html:74
> +    setTimeout(function() {
> +        debug('');
> +        debug('Test 2: resume() while interrupted will cause interruption to end.')
>  
> -    context.onstatechange = secondInterruptionStarted;
> -    if (window.internals)
> -        evalAndLog('internals.beginMediaSessionInterruption("System")');
> +        context.onstatechange = secondInterruptionStarted;
> +        if (window.internals)
> +            evalAndLog('internals.beginMediaSessionInterruption("System")');
> +    }, 0);

It would be good to have a LayoutTests ChangeLog explaining why these changes are necessary.
Comment 7 Chris Dumez 2020-09-10 09:19:22 PDT
(In reply to Eric Carlson from comment #6)
> Comment on attachment 408449 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=408449&action=review
> 
> > LayoutTests/webaudio/audiocontext-state-interrupted.html:74
> > +    setTimeout(function() {
> > +        debug('');
> > +        debug('Test 2: resume() while interrupted will cause interruption to end.')
> >  
> > -    context.onstatechange = secondInterruptionStarted;
> > -    if (window.internals)
> > -        evalAndLog('internals.beginMediaSessionInterruption("System")');
> > +        context.onstatechange = secondInterruptionStarted;
> > +        if (window.internals)
> > +            evalAndLog('internals.beginMediaSessionInterruption("System")');
> > +    }, 0);
> 
> It would be good to have a LayoutTests ChangeLog explaining why these
> changes are necessary.

Yes. Basically the issue is we sometimes move to on test to another based a Promise resolution (e.g. context.resume() / context.suspend() return promises). The promise gets resolved *BEFORE* the statechange event gets fired, as per spec. The setTimeout(0) makes sure any pending statechange event has been fired before we move on to the next text (because the next test may rely on the statechange event and we don't want it to receive the event from the previous test).
Comment 8 Chris Dumez 2020-09-10 09:24:07 PDT
Created attachment 408450 [details]
Patch
Comment 9 EWS 2020-09-10 10:32:46 PDT
Committed r266835: <https://trac.webkit.org/changeset/266835>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 408450 [details].
Comment 10 Radar WebKit Bug Importer 2020-09-10 10:33:16 PDT
<rdar://problem/68650688>