Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: f25ae590196b3cf576f1140a6c627927761cdaa5
      
https://github.com/WebKit/WebKit/commit/f25ae590196b3cf576f1140a6c627927761cdaa5
  Author: Jean-Yves Avenard <j...@apple.com>
  Date:   2024-03-08 (Fri, 08 Mar 2024)

  Changed paths:
    A 
LayoutTests/media/media-source/media-managedmse-noresumeafterpause-expected.txt
    A LayoutTests/media/media-source/media-managedmse-noresumeafterpause.html
    M LayoutTests/platform/glib/TestExpectations
    M Source/WebCore/platform/graphics/MediaPlayerPrivate.h
    M 
Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm
    M Source/WebCore/platform/graphics/cocoa/MediaPlayerPrivateWebM.mm

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

Reviewed by Eric Carlson.

In 266665@main changes were made and then later reverted.
The original description of 266665@main was:

"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.
"

The observed effect description was correct, but the explanation  wasn't.
MediaPlayerPrivateMediaSourceAVFObjC::m_playing (later renamed m_isPlaying)
indicates if the video "should be playing", which exclude the state where
playback has paused due to the lack of data.

MediaPlayerPrivateInterface::paused() was originally designed to determine
if the CRABS player had been paused indirectly by the AVPlay through AirPlay
interaction.
As AirPlay doesn't support MSE, the only possible way the player is paused
is if the MediaPlayerPrivateInterface::pause() got called. The
implementation of MediaPlayerPrivateMediaSourceAVFObjC incorrectly reported
the player as being paused if playback had stalled (the rate of the synchroniser
had changed to 0). This leads to step 7. above happening.

While the issue was noted on visionOS, side-effects could be observed elsewhere:
if you called video.pause() while the video playback had stalled, currentTime
could be seen temporarily progressing once more data was added due to
MediaPlayerPrivate::pause() only being called once the media element's 
readyState
changed.

Test Added.
* 
LayoutTests/media/media-source/media-managedmse-noresumeafterpause-expected.txt:
 Added.
* LayoutTests/media/media-source/media-managedmse-noresumeafterpause.html: 
Added.
* Source/WebCore/platform/graphics/MediaPlayerPrivate.h: Add API documentation 
for future references.
* 
Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm:
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::paused const):
* Source/WebCore/platform/graphics/cocoa/MediaPlayerPrivateWebM.mm: WebM player 
copies the logic of the AVF MSE player.
(WebCore::MediaPlayerPrivateWebM::paused const): apply the same fix as for MSE.

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



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to