- Revision
- 261004
- Author
- [email protected]
- Date
- 2020-05-01 10:05:23 -0700 (Fri, 01 May 2020)
Log Message
[MSE] Audio session category is sometimes not set correctly after changing video source
https://bugs.webkit.org/show_bug.cgi?id=211252
<rdar://problem/61894737>
Reviewed by Jer Noble.
Source/WebCore:
Test: media/media-source/media-source-change-source.html
* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::mediaPlayerActiveSourceBuffersChanged): Call checkForAudioAndVideo.
(WebCore::HTMLMediaElement::audioTrackEnabledChanged): Ditto.
(WebCore::HTMLMediaElement::videoTrackSelectedChanged): Ditto.
(WebCore::HTMLMediaElement::mediaPlayerCharacteristicChanged): Ditto.
(WebCore::HTMLMediaElement::updatePlayState): Ditto.
(WebCore::HTMLMediaElement::checkForAudioAndVideo): New, update m_hasEverHadAudio and m_hasEverHadVideo
and call m_mediaSession->canProduceAudioChanged.
(WebCore::HTMLMediaElement::mediaType const): Put `hasVideo()` in a local variable since it
is used more than once.
* html/HTMLMediaElement.h:
* platform/audio/cocoa/MediaSessionManagerCocoa.mm:
(WebCore::MediaSessionManagerCocoa::updateSessionState): Iterate over the list of media
sessions once, not five times.
* platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm:
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::addAudioRenderer): Call m_player->characteristicChanged()
rather than m_player->renderingModeChanged().
LayoutTests:
* platform/mac/media/media-source/media-source-change-source-expected.txt: Added.
* platform/mac/media/media-source/media-source-change-source.html: Added.
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (261003 => 261004)
--- trunk/LayoutTests/ChangeLog 2020-05-01 16:30:29 UTC (rev 261003)
+++ trunk/LayoutTests/ChangeLog 2020-05-01 17:05:23 UTC (rev 261004)
@@ -1,3 +1,14 @@
+2020-05-01 Eric Carlson <[email protected]>
+
+ [MSE] Audio session category is sometimes not set correctly after changing video source
+ https://bugs.webkit.org/show_bug.cgi?id=211252
+ <rdar://problem/61894737>
+
+ Reviewed by Jer Noble.
+
+ * platform/mac/media/media-source/media-source-change-source-expected.txt: Added.
+ * platform/mac/media/media-source/media-source-change-source.html: Added.
+
2020-05-01 Truitt Savell <[email protected]>
[ iOS ] compositing/iframes/border-radius-composited-frame.html and compositing/iframes/border-uneven-radius-composited-frame.html are flaky failures
Modified: trunk/LayoutTests/platform/ios/TestExpectations (261003 => 261004)
--- trunk/LayoutTests/platform/ios/TestExpectations 2020-05-01 16:30:29 UTC (rev 261003)
+++ trunk/LayoutTests/platform/ios/TestExpectations 2020-05-01 17:05:23 UTC (rev 261004)
@@ -3083,6 +3083,7 @@
# Audio session does not have a "none" category on iOS [ Skip ]
webkit.org/b/188285 platform/mac/media/audio-session-category-video-paused.html [ Skip ]
+webkit.org/b/188285 platform/mac/media/media-source/media-source-change-source.html [ Skip ]
webkit.org/b/188578 svg/custom/scrolling-embedded-svg-file-image-repaint-problem.html [ Pass Failure ]
Added: trunk/LayoutTests/platform/mac/media/media-source/media-source-change-source-expected.txt (0 => 261004)
--- trunk/LayoutTests/platform/mac/media/media-source/media-source-change-source-expected.txt (rev 0)
+++ trunk/LayoutTests/platform/mac/media/media-source/media-source-change-source-expected.txt 2020-05-01 17:05:23 UTC (rev 261004)
@@ -0,0 +1,52 @@
+
+EXPECTED (window.internals.audioSessionCategory() == 'None') OK
+
+RUN(video.volume = 0.05)
+EVENT(volumechange)
+
+* Load first file.
+EVENT(sourceopen)
+EVENT(update)
+
+** append segments
+EVENT(update)
+EVENT(update)
+EVENT(update)
+EVENT(update)
+EVENT(update)
+EVENT(update)
+EVENT(update)
+EVENT(update)
+EVENT(update)
+EVENT(update)
+
+** play
+RUN(video.play())
+EVENT(playing)
+
+EXPECTED (window.internals.audioSessionCategory() == 'MediaPlayback') OK
+
+* Load second file.
+EVENT(sourceopen)
+EVENT(update)
+
+** append segments
+EVENT(update)
+EVENT(update)
+EVENT(update)
+EVENT(update)
+EVENT(update)
+EVENT(update)
+EVENT(update)
+EVENT(update)
+EVENT(update)
+EVENT(update)
+
+** play
+RUN(video.play())
+EVENT(playing)
+
+EXPECTED (window.internals.audioSessionCategory() == 'MediaPlayback') OK
+
+END OF TEST
+
Added: trunk/LayoutTests/platform/mac/media/media-source/media-source-change-source.html (0 => 261004)
--- trunk/LayoutTests/platform/mac/media/media-source/media-source-change-source.html (rev 0)
+++ trunk/LayoutTests/platform/mac/media/media-source/media-source-change-source.html 2020-05-01 17:05:23 UTC (rev 261004)
@@ -0,0 +1,77 @@
+<html>
+<head>
+ <title>media-source-change-source</title>
+ <script src=""
+ <script src=""
+ <script>
+ let loader;
+ let source;
+ let sourceBuffer;
+
+ async function loadAndPlay() {
+ source = new MediaSource();
+ video.src = ""
+ await waitFor(source, 'sourceopen'),
+
+ sourceBuffer = source.addSourceBuffer(loader.type());
+ sourceBuffer.appendBuffer(loader.initSegment());
+ await waitFor(sourceBuffer, 'update');
+
+ consoleWrite('<br>** append segments');
+ for (let i = 0; i < loader.mediaSegmentsLength(); i++) {
+ sourceBuffer.appendBuffer(loader.mediaSegment(i));
+ await waitFor(sourceBuffer, 'update');
+ }
+
+ if (video.readyState < HTMLMediaElement.HAVE_CURRENT_DATA)
+ await waitFor(video, 'canplaythrough');
+
+ consoleWrite('<br>** play');
+ runWithKeyDown('video.play()');
+ await waitFor(video, 'playing');
+
+ consoleWrite('');
+ if (window.internals)
+ await testExpectedEventually("window.internals.audioSessionCategory()", "MediaPlayback");
+ }
+
+ async function runTest() {
+ if (window.internals)
+ internals.settings.setShouldManageAudioSessionCategory(true);
+
+ loader = new MediaSourceLoader('../../../../media/media-source/content/test-fragmented-manifest.json', '../../../../media/media-source/');
+
+ loader._onerror_ = async () => {
+ failTest('Media data loading failed');
+ };
+
+ loader._onload_ = async () => {
+ if (window.internals)
+ await testExpectedEventually("window.internals.audioSessionCategory()", "None");
+
+ consoleWrite('');
+ findMediaElement();
+ runWithKeyDown('video.volume = 0.05');
+ await waitFor(video, 'volumechange');
+
+ failTestIn(15000);
+
+ consoleWrite('<br>* Load first file.');
+ await loadAndPlay();
+
+ await new Promise(resolve => setTimeout(resolve, 1000));
+
+ consoleWrite('<br>* Load second file.');
+ await loadAndPlay();
+
+ consoleWrite('');
+ endTest();
+ };
+ }
+
+ </script>
+</head>
+<body _onload_="runTest()">
+<video controls></video><br>
+</body>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (261003 => 261004)
--- trunk/Source/WebCore/ChangeLog 2020-05-01 16:30:29 UTC (rev 261003)
+++ trunk/Source/WebCore/ChangeLog 2020-05-01 17:05:23 UTC (rev 261004)
@@ -1,3 +1,32 @@
+2020-05-01 Eric Carlson <[email protected]>
+
+ [MSE] Audio session category is sometimes not set correctly after changing video source
+ https://bugs.webkit.org/show_bug.cgi?id=211252
+ <rdar://problem/61894737>
+
+ Reviewed by Jer Noble.
+
+ Test: media/media-source/media-source-change-source.html
+
+ * html/HTMLMediaElement.cpp:
+ (WebCore::HTMLMediaElement::mediaPlayerActiveSourceBuffersChanged): Call checkForAudioAndVideo.
+ (WebCore::HTMLMediaElement::audioTrackEnabledChanged): Ditto.
+ (WebCore::HTMLMediaElement::videoTrackSelectedChanged): Ditto.
+ (WebCore::HTMLMediaElement::mediaPlayerCharacteristicChanged): Ditto.
+ (WebCore::HTMLMediaElement::updatePlayState): Ditto.
+ (WebCore::HTMLMediaElement::checkForAudioAndVideo): New, update m_hasEverHadAudio and m_hasEverHadVideo
+ and call m_mediaSession->canProduceAudioChanged.
+ (WebCore::HTMLMediaElement::mediaType const): Put `hasVideo()` in a local variable since it
+ is used more than once.
+ * html/HTMLMediaElement.h:
+
+ * platform/audio/cocoa/MediaSessionManagerCocoa.mm:
+ (WebCore::MediaSessionManagerCocoa::updateSessionState): Iterate over the list of media
+ sessions once, not five times.
+ * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm:
+ (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::addAudioRenderer): Call m_player->characteristicChanged()
+ rather than m_player->renderingModeChanged().
+
2020-05-01 Peng Liu <[email protected]>
A PiP window doesn’t actually dismiss after the browser navigates to a different page within the same domain
Modified: trunk/Source/WebCore/html/HTMLMediaElement.cpp (261003 => 261004)
--- trunk/Source/WebCore/html/HTMLMediaElement.cpp 2020-05-01 16:30:29 UTC (rev 261003)
+++ trunk/Source/WebCore/html/HTMLMediaElement.cpp 2020-05-01 17:05:23 UTC (rev 261004)
@@ -939,8 +939,7 @@
void HTMLMediaElement::mediaPlayerActiveSourceBuffersChanged()
{
- m_hasEverHadAudio |= hasAudio();
- m_hasEverHadVideo |= hasVideo();
+ checkForAudioAndVideo();
}
void HTMLMediaElement::scheduleEvent(const AtomString& eventName)
@@ -1852,6 +1851,7 @@
m_audioTracks->scheduleChangeEvent();
if (processingUserGestureForMedia())
removeBehaviorRestrictionsAfterFirstUserGesture(MediaElementSession::AllRestrictions & ~MediaElementSession::RequireUserGestureToControlControlsManager);
+ checkForAudioAndVideo();
}
void HTMLMediaElement::textTrackModeChanged(TextTrack& track)
@@ -1893,6 +1893,7 @@
{
if (m_videoTracks && m_videoTracks->contains(track))
m_videoTracks->scheduleChangeEvent();
+ checkForAudioAndVideo();
}
void HTMLMediaElement::textTrackKindChanged(TextTrack& track)
@@ -5104,11 +5105,7 @@
document().updateIsPlayingMedia();
#endif
- m_hasEverHadAudio |= hasAudio();
- m_hasEverHadVideo |= hasVideo();
-
- m_mediaSession->canProduceAudioChanged();
-
+ checkForAudioAndVideo();
updateSleepDisabling();
endProcessingMediaPlayerCallback();
@@ -5378,8 +5375,14 @@
updateMediaController();
updateRenderer();
+ checkForAudioAndVideo();
+}
+
+void HTMLMediaElement::checkForAudioAndVideo()
+{
m_hasEverHadAudio |= hasAudio();
m_hasEverHadVideo |= hasVideo();
+ m_mediaSession->canProduceAudioChanged();
}
void HTMLMediaElement::setPlaying(bool playing)
@@ -7386,9 +7389,10 @@
PlatformMediaSession::MediaType HTMLMediaElement::mediaType() const
{
if (m_player && m_readyState >= HAVE_METADATA) {
- if (hasVideo() && hasAudio() && !muted())
+ auto hasVideo = this->hasVideo();
+ if (hasVideo && hasAudio() && !muted())
return PlatformMediaSession::MediaType::VideoAudio;
- return hasVideo() ? PlatformMediaSession::MediaType::Video : PlatformMediaSession::MediaType::Audio;
+ return hasVideo ? PlatformMediaSession::MediaType::Video : PlatformMediaSession::MediaType::Audio;
}
return presentationType();
Modified: trunk/Source/WebCore/html/HTMLMediaElement.h (261003 => 261004)
--- trunk/Source/WebCore/html/HTMLMediaElement.h 2020-05-01 16:30:29 UTC (rev 261003)
+++ trunk/Source/WebCore/html/HTMLMediaElement.h 2020-05-01 17:05:23 UTC (rev 261004)
@@ -933,6 +933,8 @@
void setInActiveDocument(bool);
+ void checkForAudioAndVideo();
+
#if !RELEASE_LOG_DISABLED
const void* mediaPlayerLogIdentifier() final { return logIdentifier(); }
const Logger& mediaPlayerLogger() final { return logger(); }
Modified: trunk/Source/WebCore/platform/audio/cocoa/MediaSessionManagerCocoa.mm (261003 => 261004)
--- trunk/Source/WebCore/platform/audio/cocoa/MediaSessionManagerCocoa.mm 2020-05-01 16:30:29 UTC (rev 261003)
+++ trunk/Source/WebCore/platform/audio/cocoa/MediaSessionManagerCocoa.mm 2020-05-01 17:05:23 UTC (rev 261004)
@@ -61,11 +61,39 @@
void MediaSessionManagerCocoa::updateSessionState()
{
- int videoCount = count(PlatformMediaSession::MediaType::Video);
- int videoAudioCount = count(PlatformMediaSession::MediaType::VideoAudio);
- int audioCount = count(PlatformMediaSession::MediaType::Audio);
- int webAudioCount = count(PlatformMediaSession::MediaType::WebAudio);
+ int videoCount = 0;
+ int videoAudioCount = 0;
+ int audioCount = 0;
+ int webAudioCount = 0;
int captureCount = countActiveAudioCaptureSources();
+ bool hasAudibleAudioOrVideoMediaType = false;
+ forEachSession([&] (auto& session) mutable {
+ auto type = session.mediaType();
+ switch (type) {
+ case PlatformMediaSession::MediaType::None:
+ break;
+ case PlatformMediaSession::MediaType::Video:
+ ++videoCount;
+ break;
+ case PlatformMediaSession::MediaType::VideoAudio:
+ ++videoAudioCount;
+ break;
+ case PlatformMediaSession::MediaType::Audio:
+ ++audioCount;
+ break;
+ case PlatformMediaSession::MediaType::WebAudio:
+ ++webAudioCount;
+ break;
+ }
+
+ if (!hasAudibleAudioOrVideoMediaType) {
+ if ((type == PlatformMediaSession::MediaType::VideoAudio || type == PlatformMediaSession::MediaType::Audio) && session.canProduceAudio() && session.hasPlayedSinceLastInterruption())
+ hasAudibleAudioOrVideoMediaType = true;
+ if (session.isPlayingToWirelessPlaybackTarget())
+ hasAudibleAudioOrVideoMediaType = true;
+ }
+ });
+
ALWAYS_LOG(LOGIDENTIFIER, "types: "
"AudioCapture(", captureCount, "), "
"Video(", videoCount, "), "
@@ -80,9 +108,6 @@
else if (captureCount)
AudioSession::sharedSession().setPreferredBufferSize(AudioSession::sharedSession().sampleRate() / 50);
else if ((videoAudioCount || audioCount) && DeprecatedGlobalSettings::lowPowerVideoAudioBufferSizeEnabled()) {
- // FIXME: <http://webkit.org/b/116725> Figure out why enabling the code below
- // causes media LayoutTests to fail on 10.8.
-
size_t bufferSize;
if (m_audioHardwareListener && m_audioHardwareListener->outputDeviceSupportsLowPowerMode())
bufferSize = kLowPowerVideoBufferSize;
@@ -95,15 +120,6 @@
if (!DeprecatedGlobalSettings::shouldManageAudioSessionCategory())
return;
- bool hasAudibleAudioOrVideoMediaType = false;
- forEachSession([&hasAudibleAudioOrVideoMediaType] (auto& session) mutable {
- auto type = session.mediaType();
- if ((type == PlatformMediaSession::MediaType::VideoAudio || type == PlatformMediaSession::MediaType::Audio) && session.canProduceAudio() && session.hasPlayedSinceLastInterruption())
- hasAudibleAudioOrVideoMediaType = true;
- if (session.isPlayingToWirelessPlaybackTarget())
- hasAudibleAudioOrVideoMediaType = true;
- });
-
RouteSharingPolicy policy = RouteSharingPolicy::Default;
AudioSession::CategoryType category = AudioSession::None;
if (captureCount)
Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm (261003 => 261004)
--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm 2020-05-01 16:30:29 UTC (rev 261003)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm 2020-05-01 17:05:23 UTC (rev 261004)
@@ -1184,7 +1184,8 @@
setNetworkState(MediaPlayer::NetworkState::DecodeError);
return;
}
- m_player->renderingModeChanged();
+
+ m_player->characteristicChanged();
}
ALLOW_NEW_API_WITHOUT_GUARDS_BEGIN