Title: [277788] trunk/Source/WebCore
- Revision
- 277788
- Author
- [email protected]
- Date
- 2021-05-20 09:12:49 -0700 (Thu, 20 May 2021)
Log Message
AirPlay icon of the Vimeo.com video player is missing
https://bugs.webkit.org/show_bug.cgi?id=226004
Reviewed by Eric Carlson.
With the optimizations in r276883, an `HTMLMediaElement` will activate its
`MediaSession` just before creating its `MediaPlayer` inside `prepareForLoad()`
or `loadNextSourceChild()`, and will deactivate its `MediaSession` after tearing
down its `MediaPlayer` inside `mediaLoadingFailed()`.
However, with these changes, when a new `HTMLMediaElement` is created and an
event handler of "webkitplaybacktargetavailabilitychanged" is added to the element,
the element's `MediaSession` might be inactive when function
`MediaSessionManageriOS::configureWireLessTargetMonitoring()` runs, so its
`MediaSession` won't monitor wireless routes, and no "webkitplaybacktargetavailabilitychanged"
will be fired thereafter.
This patch fixes this issue by activating an `HTMLMediaElement`'s `MediaSession`
when adding the first event handler to "webkitplaybacktargetavailabilitychanged" event.
It also keeps the `MediaSession` active if there is event handler to
"webkitplaybacktargetavailabilitychanged" after tearing down the `HTMLMediaElement`'s
`MediaPlayer` (in `HTMLMediaElement::mediaLoadingFailed()`).
We can improve the fix by refactoring the way to activate/deactivate
an `HTMLMediaElement`'s `MediaSession`.
* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::prepareForLoad):
(WebCore::HTMLMediaElement::loadNextSourceChild):
(WebCore::HTMLMediaElement::mediaLoadingFailed):
(WebCore::HTMLMediaElement::addEventListener):
(WebCore::HTMLMediaElement::createMediaPlayer):
Replace two `mediaSession().setActive(true);` in `prepareForLoad()`
and `loadNextSourceChild()` with one in `createMediaPlayer()`.
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (277787 => 277788)
--- trunk/Source/WebCore/ChangeLog 2021-05-20 16:11:24 UTC (rev 277787)
+++ trunk/Source/WebCore/ChangeLog 2021-05-20 16:12:49 UTC (rev 277788)
@@ -1,3 +1,40 @@
+2021-05-20 Peng Liu <[email protected]>
+
+ AirPlay icon of the Vimeo.com video player is missing
+ https://bugs.webkit.org/show_bug.cgi?id=226004
+
+ Reviewed by Eric Carlson.
+
+ With the optimizations in r276883, an `HTMLMediaElement` will activate its
+ `MediaSession` just before creating its `MediaPlayer` inside `prepareForLoad()`
+ or `loadNextSourceChild()`, and will deactivate its `MediaSession` after tearing
+ down its `MediaPlayer` inside `mediaLoadingFailed()`.
+
+ However, with these changes, when a new `HTMLMediaElement` is created and an
+ event handler of "webkitplaybacktargetavailabilitychanged" is added to the element,
+ the element's `MediaSession` might be inactive when function
+ `MediaSessionManageriOS::configureWireLessTargetMonitoring()` runs, so its
+ `MediaSession` won't monitor wireless routes, and no "webkitplaybacktargetavailabilitychanged"
+ will be fired thereafter.
+
+ This patch fixes this issue by activating an `HTMLMediaElement`'s `MediaSession`
+ when adding the first event handler to "webkitplaybacktargetavailabilitychanged" event.
+ It also keeps the `MediaSession` active if there is event handler to
+ "webkitplaybacktargetavailabilitychanged" after tearing down the `HTMLMediaElement`'s
+ `MediaPlayer` (in `HTMLMediaElement::mediaLoadingFailed()`).
+
+ We can improve the fix by refactoring the way to activate/deactivate
+ an `HTMLMediaElement`'s `MediaSession`.
+
+ * html/HTMLMediaElement.cpp:
+ (WebCore::HTMLMediaElement::prepareForLoad):
+ (WebCore::HTMLMediaElement::loadNextSourceChild):
+ (WebCore::HTMLMediaElement::mediaLoadingFailed):
+ (WebCore::HTMLMediaElement::addEventListener):
+ (WebCore::HTMLMediaElement::createMediaPlayer):
+ Replace two `mediaSession().setActive(true);` in `prepareForLoad()`
+ and `loadNextSourceChild()` with one in `createMediaPlayer()`.
+
2021-05-20 Jer Noble <[email protected]>
CRASH: Null-pointer deref in MediaSessionManagerCocoa::setNowPlayingInfo()
Modified: trunk/Source/WebCore/html/HTMLMediaElement.cpp (277787 => 277788)
--- trunk/Source/WebCore/html/HTMLMediaElement.cpp 2021-05-20 16:11:24 UTC (rev 277787)
+++ trunk/Source/WebCore/html/HTMLMediaElement.cpp 2021-05-20 16:12:49 UTC (rev 277788)
@@ -1137,7 +1137,6 @@
if (!document().hasBrowsingContext())
return;
- mediaSession().setActive(true);
createMediaPlayer();
// 2 - Let pending tasks be a list of all tasks from the media element's media element event task source in one of the task queues.
@@ -1424,8 +1423,6 @@
return;
}
- mediaSession().setActive(true);
-
// Recreate the media player for the new url
createMediaPlayer();
@@ -2231,7 +2228,12 @@
logMediaLoadRequest(document().page(), String(), convertEnumerationToString(error), false);
mediaSession().clientCharacteristicsChanged();
+#if ENABLE(WIRELESS_PLAYBACK_TARGET)
+ if (!m_hasPlaybackTargetAvailabilityListeners)
+ mediaSession().setActive(false);
+#else
mediaSession().setActive(false);
+#endif
}
void HTMLMediaElement::setNetworkState(MediaPlayer::NetworkState state)
@@ -5863,6 +5865,7 @@
if (isFirstAvailabilityChangedListener) {
m_hasPlaybackTargetAvailabilityListeners = true;
+ mediaSession().setActive(true);
mediaSession().setHasPlaybackTargetAvailabilityListeners(true);
}
@@ -6619,6 +6622,8 @@
{
INFO_LOG(LOGIDENTIFIER);
+ mediaSession().setActive(true);
+
#if ENABLE(WEB_AUDIO)
auto protectedAudioSourceNode = makeRefPtr(m_audioSourceNode);
Locker<Lock> audioSourceNodeLocker(m_audioSourceNode ? &m_audioSourceNode->processLock() : nullptr);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes