[webkit-changes] [WebKit/WebKit] ac6294: [visionOS] AudioSession interruptions do not stop ...

Aditya Keerthi noreply at github.com
Mon Aug 7 16:49:08 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: ac6294fe9e54d9a6ca7577d7576b57d1a7e26305
      https://github.com/WebKit/WebKit/commit/ac6294fe9e54d9a6ca7577d7576b57d1a7e26305
  Author: Aditya Keerthi <akeerthi at apple.com>
  Date:   2023-08-07 (Mon, 07 Aug 2023)

  Changed paths:
    M Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm

  Log Message:
  -----------
  [visionOS] AudioSession interruptions do not stop playback
https://bugs.webkit.org/show_bug.cgi?id=259887
rdar://112044261

Reviewed by Eric Carlson.

Timing differences on visionOS result in `AVSampleBufferRenderSynchronizer`'s
rate being set to zero, prior to the interruption notification being dispatched
when an interruption occurs. This difference ordering in ordering results in a
sequence of events that causes WebKit to automatically resume playback following
an interruption.

Specifically:

1. `CMTimebaseEffectiveRateChangedCallback` is fired as AVSBRS has its rate changed, by the system.
2. Through the callback, the rate is observed as zero, resulting in playback being considered paused in the GPU process.
3. The GPU process state is reflected in the web process with a call to `MediaPlayerPrivateRemote::updateCachedState`.
4. `AVAudioSessionInterruptionNotification` is dispatched in the GPU process, by the system.
5. `HTMLMediaElement::updatePlayState()` is called in the web process.
6. The web process believes that playback is already paused, due to (3).
7. Consequently, the GPU process is never told to pause content; specifically, `MediaPlayerPrivateMediaSourceAVFObjC::pauseInternal()` is elided.
8. Importantly, that method sets a flag variable, `m_playing` to false.
9. Since `m_playing` is not set to false, `MediaPlayerPrivateMediaSourceAVFObjC::shouldBePlaying()` will return true.
10. `MediaPlayerPrivateMediaSourceAVFObjC::updateAllRenderersHaveAvailableSamples()` eventually restarts playback, since `shouldBePlaying()` is true.

On iOS, steps 1-3 do not occur before `AVAudioSessionInterruptionNotification`,
and `MediaPlayerPrivateMediaSourceAVFObjC::pauseInternal()` drives the pausing
of playback.

To fix, ensure the value of `m_playing` reflects the rate change.

* Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm:
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::effectiveRateChanged):

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




More information about the webkit-changes mailing list