[webkit-changes] [WebKit/WebKit] 2ed67f: [iOS] Changing the mute state of autoplaying silen...

Jer Noble noreply at github.com
Fri Dec 16 09:38:36 PST 2022


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 2ed67ffbd825092a1f4b879fb1efe63e7e04a07a
      https://github.com/WebKit/WebKit/commit/2ed67ffbd825092a1f4b879fb1efe63e7e04a07a
  Author: Jer Noble <jer.noble at apple.com>
  Date:   2022-12-16 (Fri, 16 Dec 2022)

  Changed paths:
    A LayoutTests/media/audio-session-category-unmute-mute-expected.txt
    A LayoutTests/media/audio-session-category-unmute-mute.html
    M LayoutTests/media/video-test.js
    M LayoutTests/platform/gtk/TestExpectations
    M Source/WebCore/platform/audio/PlatformMediaSession.cpp
    M Source/WebCore/platform/audio/PlatformMediaSession.h
    M Source/WebCore/platform/audio/cocoa/MediaSessionManagerCocoa.mm
    M Source/WebCore/platform/audio/glib/MediaSessionManagerGLib.cpp

  Log Message:
  -----------
  [iOS] Changing the mute state of autoplaying silent videos can interrupt system audio
https://bugs.webkit.org/show_bug.cgi?id=249408
rdar://103408312

Reviewed by Eric Carlson.

WebKit will attempt to leave the default AVAudioSession category in "ambient"
when no audible playback exists. However, when an audible media element pauses,
WebKit will leave the category in "media playback", which allows APIs like Now
Playing to continue working. It does this by tracking, for each media element,
that the element has played sometime since the last time WebKit received an
interruption. The assumption is that elements which have previously played
should not cause the category to drop to "none" when they pause.

However, this logic gets confused when a previously silent media element
(i.e., muted) pauses, then becomes not-silent (i.e., unmuted). The
PlatformMediaSessionManager sees that the element is capable of producing
audio, and has played since the last interruption, so sets the AVAudioSession
category to "media playback". When that element is then played, AVFoundation
will activate the AVAudioSession, which by virtue of being configured for
"media playback", will interrupt other system audio.

To resolve this, rather than tracking whether the element has "played since the
last interruption", track whether the element has "played _audibly_ since the
last interruption." Rename hasPlayedSinceLastInterruption() ->
hasPlayedAudiblySinceLastInterruption() to clarify the new behavior.

* LayoutTests/media/audio-session-category-unmute-mute-expected.txt: Added.
* LayoutTests/media/audio-session-category-unmute-mute.html: Added.
* Source/WebCore/platform/audio/PlatformMediaSession.cpp:
(WebCore::PlatformMediaSession::setState):
* Source/WebCore/platform/audio/PlatformMediaSession.h:
(WebCore::PlatformMediaSession::hasPlayedAudiblySinceLastInterruption const):
(WebCore::PlatformMediaSession::clearHasPlayedAudiblySinceLastInterruption):
(WebCore::PlatformMediaSession::hasPlayedSinceLastInterruption const): Deleted.
(WebCore::PlatformMediaSession::clearHasPlayedSinceLastInterruption): Deleted.
* Source/WebCore/platform/audio/cocoa/MediaSessionManagerCocoa.mm:
(WebCore::MediaSessionManagerCocoa::updateSessionState):
(WebCore::MediaSessionManagerCocoa::beginInterruption):

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




More information about the webkit-changes mailing list