⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 269047 in webkit


Ignore:
Timestamp:
Oct 27, 2020, 10:09:34 AM (6 years ago)
Author:
Chris Dumez
Message:

Calling AudioContext.suspend() / resume() while already suspended / running should resolve the promise right away
​https://bugs.webkit.org/show_bug.cgi?id=218236

Reviewed by Sam Weinig.

Source/WebCore:

Calling AudioContext.suspend() / resume() while already suspended / running should resolve the promise right
away. This is the behavior in the specification [1][2] and matches Blink / Gecko.

[1] ​https://www.w3.org/TR/webaudio/#dom-audiocontext-suspend
[2] ​https://www.w3.org/TR/webaudio/#dom-audiocontext-resume

Tests: webaudio/resume-context-while-running.html

webaudio/suspend-context-while-suspended.html

  • Modules/webaudio/AudioContext.cpp:

(WebCore::AudioContext::suspendRendering):
(WebCore::AudioContext::resumeRendering):

LayoutTests:

Add layout test coverage.

  • webaudio/resume-context-while-running-expected.txt: Added.
  • webaudio/resume-context-while-running.html: Added.
  • webaudio/suspend-context-while-suspended-expected.txt: Added.
  • webaudio/suspend-context-while-suspended.html: Added.
Location:
trunk
Files:
4 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r269044 r269047  
     12020-10-27  Chris Dumez  <cdumez@apple.com>
     2
     3        Calling AudioContext.suspend() / resume() while already suspended / running should resolve the promise right away
     4        https://bugs.webkit.org/show_bug.cgi?id=218236
     5
     6        Reviewed by Sam Weinig.
     7
     8        Add layout test coverage.
     9
     10        * webaudio/resume-context-while-running-expected.txt: Added.
     11        * webaudio/resume-context-while-running.html: Added.
     12        * webaudio/suspend-context-while-suspended-expected.txt: Added.
     13        * webaudio/suspend-context-while-suspended.html: Added.
     14
    1152020-10-27  Ryan Haddad  <ryanhaddad@apple.com>
    216
  • trunk/Source/WebCore/ChangeLog

    r269046 r269047  
     12020-10-27  Chris Dumez  <cdumez@apple.com>
     2
     3        Calling AudioContext.suspend() / resume() while already suspended / running should resolve the promise right away
     4        https://bugs.webkit.org/show_bug.cgi?id=218236
     5
     6        Reviewed by Sam Weinig.
     7
     8        Calling AudioContext.suspend() / resume() while already suspended / running should resolve the promise right
     9        away. This is the behavior in the specification [1][2] and matches Blink / Gecko.
     10
     11        [1] https://www.w3.org/TR/webaudio/#dom-audiocontext-suspend
     12        [2] https://www.w3.org/TR/webaudio/#dom-audiocontext-resume
     13
     14        Tests: webaudio/resume-context-while-running.html
     15               webaudio/suspend-context-while-suspended.html
     16
     17        * Modules/webaudio/AudioContext.cpp:
     18        (WebCore::AudioContext::suspendRendering):
     19        (WebCore::AudioContext::resumeRendering):
     20
    1212020-10-27  Chris Lord  <clord@igalia.com>
    222
  • trunk/Source/WebCore/Modules/webaudio/AudioContext.cpp

    r269039 r269047  
    215215    }
    216216
    217     addReaction(State::Suspended, WTFMove(promise));
    218217    m_wasSuspendedByScript = true;
    219218
    220     if (!willPausePlayback())
    221         return;
    222 
    223     lazyInitialize();
    224 
    225     destinationNode()->suspend([this, protectedThis = makeRef(*this)] {
     219    if (!willPausePlayback()) {
     220        addReaction(State::Suspended, WTFMove(promise));
     221        return;
     222    }
     223
     224    lazyInitialize();
     225
     226    destinationNode()->suspend([this, protectedThis = makeRef(*this), promise = WTFMove(promise)]() mutable {
    226227        setState(State::Suspended);
     228        promise.resolve();
    227229    });
    228230}
    … …  
    240242    }
    241243
    242     addReaction(State::Running, WTFMove(promise));
    243244    m_wasSuspendedByScript = false;
    244245
    245     if (!willBeginPlayback())
    246         return;
    247 
    248     lazyInitialize();
    249 
    250     destinationNode()->resume([this, protectedThis = makeRef(*this)] {
     246    if (!willBeginPlayback()) {
     247        addReaction(State::Running, WTFMove(promise));
     248        return;
     249    }
     250
     251    lazyInitialize();
     252
     253    destinationNode()->resume([this, protectedThis = makeRef(*this), promise = WTFMove(promise)]() mutable {
    251254        // Since we update the state asynchronously, we may have been interrupted after the
    252255        // call to resume() and before this lambda runs. In this case, we don't want to
    … …  
    254257        bool interrupted = m_mediaSession->state() == PlatformMediaSession::Interrupted;
    255258        setState(interrupted ? State::Interrupted : State::Running);
     259        if (interrupted)
     260            addReaction(State::Running, WTFMove(promise));
     261        else
     262            promise.resolve();
    256263    });
    257264}
Note: See TracChangeset for help on using the changeset viewer.