Changeset 269039 in webkit


Ignore:
Timestamp:
Oct 27, 2020 8:26:01 AM (21 months ago)
Author:
Chris Dumez
Message:

AudioContext.suspend() should not reject promise when audio session is interrupted
https://bugs.webkit.org/show_bug.cgi?id=218235

Reviewed by Darin Adler.

Source/WebCore:

AudioContext.suspend() should not reject promise when audio session is interrupted. Being
"interrupted" is an internal WebKit concept and rejecting the promise here is confusing
to Web developers.

We now no longer throw when AudioContext.suspend() is called while interrupted. Instead,
we set the 'wasSuspendedByJavascript' flag and register a state change listener to resolve
the promise when the state changes to "suspended".

When the interruption ends, AudioContext::mayResumePlayback() gets called with
shouldResume=false, causing us to update the state from "interrupted" to "suspended",
which resolves the suspend promise.

Test: webaudio/suspend-context-while-interrupted.html

  • Modules/webaudio/AudioContext.cpp:

(WebCore::AudioContext::suspendRendering):

LayoutTests:

Add layout test coverage.

  • webaudio/suspend-context-while-interrupted-expected.txt: Added.
  • webaudio/suspend-context-while-interrupted.html: Added.
Location:
trunk
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r269036 r269039  
     12020-10-27  Chris Dumez  <cdumez@apple.com>
     2
     3        AudioContext.suspend() should not reject promise when audio session is interrupted
     4        https://bugs.webkit.org/show_bug.cgi?id=218235
     5
     6        Reviewed by Darin Adler.
     7
     8        Add layout test coverage.
     9
     10        * webaudio/suspend-context-while-interrupted-expected.txt: Added.
     11        * webaudio/suspend-context-while-interrupted.html: Added.
     12
    1132020-10-27  Zalan Bujtas  <zalan@apple.com>
    214
  • trunk/Source/WebCore/ChangeLog

    r269038 r269039  
     12020-10-27  Chris Dumez  <cdumez@apple.com>
     2
     3        AudioContext.suspend() should not reject promise when audio session is interrupted
     4        https://bugs.webkit.org/show_bug.cgi?id=218235
     5
     6        Reviewed by Darin Adler.
     7
     8        AudioContext.suspend() should not reject promise when audio session is interrupted. Being
     9        "interrupted" is an internal WebKit concept and rejecting the promise here is confusing
     10        to Web developers.
     11
     12        We now no longer throw when AudioContext.suspend() is called while interrupted. Instead,
     13        we set the 'wasSuspendedByJavascript' flag and register a state change listener to resolve
     14        the promise when the state changes to "suspended".
     15
     16        When the interruption ends, AudioContext::mayResumePlayback() gets called with
     17        shouldResume=false, causing us to update the state from "interrupted" to "suspended",
     18        which resolves the suspend promise.
     19
     20        Test: webaudio/suspend-context-while-interrupted.html
     21
     22        * Modules/webaudio/AudioContext.cpp:
     23        (WebCore::AudioContext::suspendRendering):
     24
    1252020-10-27  Antti Koivisto  <antti@apple.com>
    226
  • trunk/Source/WebCore/Modules/webaudio/AudioContext.cpp

    r268999 r269039  
    210210    }
    211211
    212     if (isStopped() || state() == State::Closed || state() == State::Interrupted || !destinationNode()) {
     212    if (isStopped() || state() == State::Closed || !destinationNode()) {
    213213        promise.reject(Exception { InvalidStateError, "Context is closed"_s });
    214214        return;
Note: See TracChangeset for help on using the changeset viewer.