Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: e9850528706fa288a2c8d085abb961faf81a2872
      
https://github.com/WebKit/WebKit/commit/e9850528706fa288a2c8d085abb961faf81a2872
  Author: Anthony Tarbinian <[email protected]>
  Date:   2026-07-17 (Fri, 17 Jul 2026)

  Changed paths:
    M LayoutTests/platform/ios-site-isolation/TestExpectations
    M Source/WebCore/Modules/webaudio/AudioContext.cpp

  Log Message:
  -----------
  [Site Isolation] cross-origin tests in 
http/tests/security/webaudio-render-remote-audio-* are failing
https://bugs.webkit.org/show_bug.cgi?id=318459
rdar://181257156

Reviewed by Sihui Liu.

The following tests are timing out with site isolation enabled:

http/tests/security/webaudio-render-remote-audio-allowed-crossorigin-redirect.html
http/tests/security/webaudio-render-remote-audio-allowed-crossorigin.html
http/tests/security/webaudio-render-remote-audio-blocked-no-crossorigin-redirect.html
http/tests/security/webaudio-render-remote-audio-blocked-no-crossorigin.html

```
context.resume().then(() => {   // ← promise stays pending
  audio.play();                 // ← never called
});
```

AudioContext first asks the UIProcess if it has playback permission.
However, there is a race where AudioContext asks the UIProcess about
playback permission before the RemoteMediaSessionState is registered with the 
UIProcess.

In terms of IPC messages, the UI process receives MediaSessionWillBeginPlayback
before AddMediaSession (comes from setActive(true)).

If the RemoteMediaSessionState doesn't exist in MediaSessionWillBeginPlayback, 
then
RemoteMediaSessionManagerProxy::mediaSessionWillBeginPlayback will call
completionHandler(false). This leads to AudioContext::resumeRendering
to be called with willBegin == false and the resume() promise is stored
until some point when the context starts running again.
This storage of the promise is what causes the resume() promise to
hang in the test JS.

setActive(true) ran synchronously before clientWillBeginPlayback() until
clientWillBeginPlayback was made asynchronous. Restore that ordering by calling
setActive(true) before clientWillBeginPlayback(), matching
HTMLMediaElement::playInternal(). This sends AddMediaSession ahead of
MediaSessionWillBeginPlayback so the UI-process manager can find the session.

The this fixes the following tests with site isolation enabled:

http/tests/security/webaudio-render-remote-audio-allowed-crossorigin-redirect.html
http/tests/security/webaudio-render-remote-audio-allowed-crossorigin.html
http/tests/security/webaudio-render-remote-audio-blocked-no-crossorigin-redirect.html
http/tests/security/webaudio-render-remote-audio-blocked-no-crossorigin.html

* LayoutTests/platform/ios-site-isolation/TestExpectations:
* Source/WebCore/Modules/webaudio/AudioContext.cpp:
(WebCore::AudioContext::willBeginPlayback):

Canonical link: https://commits.webkit.org/317386@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to