Diff
Modified: branches/safari-610.1.1-branch/Source/WebCore/ChangeLog (255301 => 255302)
--- branches/safari-610.1.1-branch/Source/WebCore/ChangeLog 2020-01-28 21:49:50 UTC (rev 255301)
+++ branches/safari-610.1.1-branch/Source/WebCore/ChangeLog 2020-01-28 21:49:54 UTC (rev 255302)
@@ -1,5 +1,103 @@
2020-01-28 Russell Epstein <[email protected]>
+ Cherry-pick r255116. rdar://problem/58800787
+
+ HTMLMediaElement should not remove the media session at DOM suspension time
+ https://bugs.webkit.org/show_bug.cgi?id=206661
+ <rdar://problem/58800787>
+
+ Source/WebCore:
+
+ Reviewed by Eric Carlson.
+
+ https://trac.webkit.org/changeset/233560 made it so that, on HTMLMediaElement suspension,
+ its media session is stopped.
+ This was done to ensure updateNowPlayingInfo is not called synchronously but asynchronously.
+ The issue is that, once the media session is stopped, it is removed from the media session vector.
+ On updating the ready state after suspension, and playing, we try to look into the media session vector and do not find the session.
+ This triggers the ASSERT.
+
+ Partially revert the behavior by calling the same code as clientWillPausePlayback
+ but make sure updateNowPlayingInfo is calling asynchronously when suspending the media element.
+ Introduce clientWillBeDOMSuspended for that purpose.
+
+ Update mediaPlayerReadyStateChanged to enqueue a task to do the update if the media element is suspended.
+
+ Covered by test no longer crashing in debug.
+
+ * html/HTMLMediaElement.cpp:
+ (WebCore::HTMLMediaElement::mediaPlayerReadyStateChanged):
+ (WebCore::HTMLMediaElement::stopWithoutDestroyingMediaPlayer):
+ * platform/audio/PlatformMediaSession.cpp:
+ (WebCore::PlatformMediaSession::processClientWillPausePlayback):
+ (WebCore::PlatformMediaSession::clientWillPausePlayback):
+ (WebCore::PlatformMediaSession::clientWillBeDOMSuspended):
+ * platform/audio/PlatformMediaSession.h:
+ * platform/audio/PlatformMediaSessionManager.cpp:
+ (WebCore::PlatformMediaSessionManager::sessionWillEndPlayback):
+ * platform/audio/PlatformMediaSessionManager.h:
+ * platform/audio/cocoa/MediaSessionManagerCocoa.h:
+ * platform/audio/cocoa/MediaSessionManagerCocoa.mm:
+ (MediaSessionManagerCocoa::sessionWillEndPlayback):
+ * platform/audio/ios/MediaSessionManagerIOS.h:
+ * platform/audio/ios/MediaSessionManagerIOS.mm:
+ (WebCore::MediaSessionManageriOS::sessionWillEndPlayback):
+
+ Tools:
+
+ Reviewed by Eric Carlson.
+
+ * TestWebKitAPI/Tests/WebKitLegacy/ios/ScrollingDoesNotPauseMedia.mm:
+ (TestWebKitAPI::TEST):
+ Suspend/resume Active DOM Objects from time to time as would do scrolling.
+ This allows pending tasks to be executed asynchronously when not scrolling.
+
+
+ git-svn-id: https://svn.webkit.org/repository/webkit/trunk@255116 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+ 2020-01-25 youenn fablet <[email protected]>
+
+ HTMLMediaElement should not remove the media session at DOM suspension time
+ https://bugs.webkit.org/show_bug.cgi?id=206661
+ <rdar://problem/58800787>
+
+ Reviewed by Eric Carlson.
+
+ https://trac.webkit.org/changeset/233560 made it so that, on HTMLMediaElement suspension,
+ its media session is stopped.
+ This was done to ensure updateNowPlayingInfo is not called synchronously but asynchronously.
+ The issue is that, once the media session is stopped, it is removed from the media session vector.
+ On updating the ready state after suspension, and playing, we try to look into the media session vector and do not find the session.
+ This triggers the ASSERT.
+
+ Partially revert the behavior by calling the same code as clientWillPausePlayback
+ but make sure updateNowPlayingInfo is calling asynchronously when suspending the media element.
+ Introduce clientWillBeDOMSuspended for that purpose.
+
+ Update mediaPlayerReadyStateChanged to enqueue a task to do the update if the media element is suspended.
+
+ Covered by test no longer crashing in debug.
+
+ * html/HTMLMediaElement.cpp:
+ (WebCore::HTMLMediaElement::mediaPlayerReadyStateChanged):
+ (WebCore::HTMLMediaElement::stopWithoutDestroyingMediaPlayer):
+ * platform/audio/PlatformMediaSession.cpp:
+ (WebCore::PlatformMediaSession::processClientWillPausePlayback):
+ (WebCore::PlatformMediaSession::clientWillPausePlayback):
+ (WebCore::PlatformMediaSession::clientWillBeDOMSuspended):
+ * platform/audio/PlatformMediaSession.h:
+ * platform/audio/PlatformMediaSessionManager.cpp:
+ (WebCore::PlatformMediaSessionManager::sessionWillEndPlayback):
+ * platform/audio/PlatformMediaSessionManager.h:
+ * platform/audio/cocoa/MediaSessionManagerCocoa.h:
+ * platform/audio/cocoa/MediaSessionManagerCocoa.mm:
+ (MediaSessionManagerCocoa::sessionWillEndPlayback):
+ * platform/audio/ios/MediaSessionManagerIOS.h:
+ * platform/audio/ios/MediaSessionManagerIOS.mm:
+ (WebCore::MediaSessionManageriOS::sessionWillEndPlayback):
+
+2020-01-28 Russell Epstein <[email protected]>
+
Cherry-pick r255068. rdar://problem/58809696
[LFC][Integration] LineLayout::paint should take advantage of the glyph display list cache
Modified: branches/safari-610.1.1-branch/Source/WebCore/html/HTMLMediaElement.cpp (255301 => 255302)
--- branches/safari-610.1.1-branch/Source/WebCore/html/HTMLMediaElement.cpp 2020-01-28 21:49:50 UTC (rev 255301)
+++ branches/safari-610.1.1-branch/Source/WebCore/html/HTMLMediaElement.cpp 2020-01-28 21:49:54 UTC (rev 255302)
@@ -2327,6 +2327,13 @@
void HTMLMediaElement::mediaPlayerReadyStateChanged()
{
+ if (isSuspended()) {
+ queueTaskKeepingObjectAlive(*this, TaskSource::MediaElement, [this] {
+ mediaPlayerReadyStateChanged();
+ });
+ return;
+ }
+
beginProcessingMediaPlayerCallback();
setReadyState(m_player->readyState());
@@ -5627,7 +5634,7 @@
// Stop the playback without generating events
setPlaying(false);
pauseAndUpdatePlayStateImmediately();
- m_mediaSession->stopSession();
+ m_mediaSession->clientWillBeDOMSuspended();
setAutoplayEventPlaybackState(AutoplayEventPlaybackState::None);
Modified: branches/safari-610.1.1-branch/Source/WebCore/platform/audio/PlatformMediaSession.cpp (255301 => 255302)
--- branches/safari-610.1.1-branch/Source/WebCore/platform/audio/PlatformMediaSession.cpp 2020-01-28 21:49:50 UTC (rev 255301)
+++ branches/safari-610.1.1-branch/Source/WebCore/platform/audio/PlatformMediaSession.cpp 2020-01-28 21:49:54 UTC (rev 255302)
@@ -224,7 +224,7 @@
return true;
}
-bool PlatformMediaSession::clientWillPausePlayback()
+bool PlatformMediaSession::processClientWillPausePlayback(DelayCallingUpdateNowPlaying shouldDelayCallingUpdateNowPlaying)
{
if (m_notifyingClient)
return true;
@@ -237,10 +237,20 @@
}
setState(Paused);
- PlatformMediaSessionManager::sharedManager().sessionWillEndPlayback(*this);
+ PlatformMediaSessionManager::sharedManager().sessionWillEndPlayback(*this, shouldDelayCallingUpdateNowPlaying);
return true;
}
+bool PlatformMediaSession::clientWillPausePlayback()
+{
+ return processClientWillPausePlayback(DelayCallingUpdateNowPlaying::No);
+}
+
+void PlatformMediaSession::clientWillBeDOMSuspended()
+{
+ processClientWillPausePlayback(DelayCallingUpdateNowPlaying::Yes);
+}
+
void PlatformMediaSession::pauseSession()
{
INFO_LOG(LOGIDENTIFIER);
Modified: branches/safari-610.1.1-branch/Source/WebCore/platform/audio/PlatformMediaSession.h (255301 => 255302)
--- branches/safari-610.1.1-branch/Source/WebCore/platform/audio/PlatformMediaSession.h 2020-01-28 21:49:50 UTC (rev 255301)
+++ branches/safari-610.1.1-branch/Source/WebCore/platform/audio/PlatformMediaSession.h 2020-01-28 21:49:54 UTC (rev 255302)
@@ -41,6 +41,7 @@
class Document;
class MediaPlaybackTarget;
class PlatformMediaSessionClient;
+enum class DelayCallingUpdateNowPlaying { No, Yes };
class PlatformMediaSession
: public CanMakeWeakPtr<PlatformMediaSession>
@@ -113,6 +114,8 @@
virtual bool clientWillBeginPlayback();
virtual bool clientWillPausePlayback();
+ void clientWillBeDOMSuspended();
+
void pauseSession();
void stopSession();
@@ -199,6 +202,8 @@
PlatformMediaSessionClient& client() const { return m_client; }
private:
+ bool processClientWillPausePlayback(DelayCallingUpdateNowPlaying);
+
PlatformMediaSessionClient& m_client;
State m_state;
State m_stateToRestore;
Modified: branches/safari-610.1.1-branch/Source/WebCore/platform/audio/PlatformMediaSessionManager.cpp (255301 => 255302)
--- branches/safari-610.1.1-branch/Source/WebCore/platform/audio/PlatformMediaSessionManager.cpp 2020-01-28 21:49:50 UTC (rev 255301)
+++ branches/safari-610.1.1-branch/Source/WebCore/platform/audio/PlatformMediaSessionManager.cpp 2020-01-28 21:49:54 UTC (rev 255302)
@@ -235,7 +235,7 @@
return true;
}
-void PlatformMediaSessionManager::sessionWillEndPlayback(PlatformMediaSession& session)
+void PlatformMediaSessionManager::sessionWillEndPlayback(PlatformMediaSession& session, DelayCallingUpdateNowPlaying)
{
ALWAYS_LOG(LOGIDENTIFIER, session.logIdentifier());
Modified: branches/safari-610.1.1-branch/Source/WebCore/platform/audio/PlatformMediaSessionManager.h (255301 => 255302)
--- branches/safari-610.1.1-branch/Source/WebCore/platform/audio/PlatformMediaSessionManager.h 2020-01-28 21:49:50 UTC (rev 255301)
+++ branches/safari-610.1.1-branch/Source/WebCore/platform/audio/PlatformMediaSessionManager.h 2020-01-28 21:49:54 UTC (rev 255302)
@@ -113,7 +113,8 @@
virtual void resetRestrictions();
virtual bool sessionWillBeginPlayback(PlatformMediaSession&);
- virtual void sessionWillEndPlayback(PlatformMediaSession&);
+
+ virtual void sessionWillEndPlayback(PlatformMediaSession&, DelayCallingUpdateNowPlaying);
virtual void sessionStateChanged(PlatformMediaSession&);
virtual void sessionDidEndRemoteScrubbing(const PlatformMediaSession&) { };
virtual void clientCharacteristicsChanged(PlatformMediaSession&) { }
Modified: branches/safari-610.1.1-branch/Source/WebCore/platform/audio/cocoa/MediaSessionManagerCocoa.h (255301 => 255302)
--- branches/safari-610.1.1-branch/Source/WebCore/platform/audio/cocoa/MediaSessionManagerCocoa.h 2020-01-28 21:49:50 UTC (rev 255301)
+++ branches/safari-610.1.1-branch/Source/WebCore/platform/audio/cocoa/MediaSessionManagerCocoa.h 2020-01-28 21:49:54 UTC (rev 255302)
@@ -53,7 +53,7 @@
void removeSession(PlatformMediaSession&) override;
bool sessionWillBeginPlayback(PlatformMediaSession&) override;
- void sessionWillEndPlayback(PlatformMediaSession&) override;
+ void sessionWillEndPlayback(PlatformMediaSession&, DelayCallingUpdateNowPlaying) override;
void sessionDidEndRemoteScrubbing(const PlatformMediaSession&) override;
void clientCharacteristicsChanged(PlatformMediaSession&) override;
void sessionCanProduceAudioChanged() override;
Modified: branches/safari-610.1.1-branch/Source/WebCore/platform/audio/cocoa/MediaSessionManagerCocoa.mm (255301 => 255302)
--- branches/safari-610.1.1-branch/Source/WebCore/platform/audio/cocoa/MediaSessionManagerCocoa.mm 2020-01-28 21:49:50 UTC (rev 255301)
+++ branches/safari-610.1.1-branch/Source/WebCore/platform/audio/cocoa/MediaSessionManagerCocoa.mm 2020-01-28 21:49:54 UTC (rev 255302)
@@ -161,10 +161,14 @@
scheduleUpdateNowPlayingInfo();
}
-void MediaSessionManagerCocoa::sessionWillEndPlayback(PlatformMediaSession& session)
+void MediaSessionManagerCocoa::sessionWillEndPlayback(PlatformMediaSession& session, DelayCallingUpdateNowPlaying delayCallingUpdateNowPlaying)
{
- PlatformMediaSessionManager::sessionWillEndPlayback(session);
- updateNowPlayingInfo();
+ PlatformMediaSessionManager::sessionWillEndPlayback(session, delayCallingUpdateNowPlaying);
+ if (delayCallingUpdateNowPlaying == DelayCallingUpdateNowPlaying::No) {
+ updateNowPlayingInfo();
+ return;
+ }
+ scheduleUpdateNowPlayingInfo();
}
void MediaSessionManagerCocoa::clientCharacteristicsChanged(PlatformMediaSession& session)
Modified: branches/safari-610.1.1-branch/Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.h (255301 => 255302)
--- branches/safari-610.1.1-branch/Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.h 2020-01-28 21:49:50 UTC (rev 255301)
+++ branches/safari-610.1.1-branch/Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.h 2020-01-28 21:49:54 UTC (rev 255302)
@@ -62,7 +62,7 @@
void configureWireLessTargetMonitoring() override;
void providePresentingApplicationPIDIfNecessary() final;
- void sessionWillEndPlayback(PlatformMediaSession&) final;
+ void sessionWillEndPlayback(PlatformMediaSession&, DelayCallingUpdateNowPlaying) final;
#if !RELEASE_LOG_DISABLED
const char* logClassName() const final { return "MediaSessionManageriOS"; }
Modified: branches/safari-610.1.1-branch/Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.mm (255301 => 255302)
--- branches/safari-610.1.1-branch/Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.mm 2020-01-28 21:49:50 UTC (rev 255301)
+++ branches/safari-610.1.1-branch/Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.mm 2020-01-28 21:49:54 UTC (rev 255302)
@@ -190,9 +190,9 @@
#endif
}
-void MediaSessionManageriOS::sessionWillEndPlayback(PlatformMediaSession& session)
+void MediaSessionManageriOS::sessionWillEndPlayback(PlatformMediaSession& session, DelayCallingUpdateNowPlaying delayCallingUpdateNowPlaying)
{
- MediaSessionManagerCocoa::sessionWillEndPlayback(session);
+ MediaSessionManagerCocoa::sessionWillEndPlayback(session, delayCallingUpdateNowPlaying);
#if USE(AUDIO_SESSION)
if (isApplicationInBackground() && !anyOfSessions([] (auto& session) { return session.state() == PlatformMediaSession::Playing; }))
Modified: branches/safari-610.1.1-branch/Tools/ChangeLog (255301 => 255302)
--- branches/safari-610.1.1-branch/Tools/ChangeLog 2020-01-28 21:49:50 UTC (rev 255301)
+++ branches/safari-610.1.1-branch/Tools/ChangeLog 2020-01-28 21:49:54 UTC (rev 255302)
@@ -1,5 +1,75 @@
2020-01-28 Russell Epstein <[email protected]>
+ Cherry-pick r255116. rdar://problem/58800787
+
+ HTMLMediaElement should not remove the media session at DOM suspension time
+ https://bugs.webkit.org/show_bug.cgi?id=206661
+ <rdar://problem/58800787>
+
+ Source/WebCore:
+
+ Reviewed by Eric Carlson.
+
+ https://trac.webkit.org/changeset/233560 made it so that, on HTMLMediaElement suspension,
+ its media session is stopped.
+ This was done to ensure updateNowPlayingInfo is not called synchronously but asynchronously.
+ The issue is that, once the media session is stopped, it is removed from the media session vector.
+ On updating the ready state after suspension, and playing, we try to look into the media session vector and do not find the session.
+ This triggers the ASSERT.
+
+ Partially revert the behavior by calling the same code as clientWillPausePlayback
+ but make sure updateNowPlayingInfo is calling asynchronously when suspending the media element.
+ Introduce clientWillBeDOMSuspended for that purpose.
+
+ Update mediaPlayerReadyStateChanged to enqueue a task to do the update if the media element is suspended.
+
+ Covered by test no longer crashing in debug.
+
+ * html/HTMLMediaElement.cpp:
+ (WebCore::HTMLMediaElement::mediaPlayerReadyStateChanged):
+ (WebCore::HTMLMediaElement::stopWithoutDestroyingMediaPlayer):
+ * platform/audio/PlatformMediaSession.cpp:
+ (WebCore::PlatformMediaSession::processClientWillPausePlayback):
+ (WebCore::PlatformMediaSession::clientWillPausePlayback):
+ (WebCore::PlatformMediaSession::clientWillBeDOMSuspended):
+ * platform/audio/PlatformMediaSession.h:
+ * platform/audio/PlatformMediaSessionManager.cpp:
+ (WebCore::PlatformMediaSessionManager::sessionWillEndPlayback):
+ * platform/audio/PlatformMediaSessionManager.h:
+ * platform/audio/cocoa/MediaSessionManagerCocoa.h:
+ * platform/audio/cocoa/MediaSessionManagerCocoa.mm:
+ (MediaSessionManagerCocoa::sessionWillEndPlayback):
+ * platform/audio/ios/MediaSessionManagerIOS.h:
+ * platform/audio/ios/MediaSessionManagerIOS.mm:
+ (WebCore::MediaSessionManageriOS::sessionWillEndPlayback):
+
+ Tools:
+
+ Reviewed by Eric Carlson.
+
+ * TestWebKitAPI/Tests/WebKitLegacy/ios/ScrollingDoesNotPauseMedia.mm:
+ (TestWebKitAPI::TEST):
+ Suspend/resume Active DOM Objects from time to time as would do scrolling.
+ This allows pending tasks to be executed asynchronously when not scrolling.
+
+
+ git-svn-id: https://svn.webkit.org/repository/webkit/trunk@255116 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+ 2020-01-25 Youenn Fablet <[email protected]>
+
+ HTMLMediaElement should not remove the media session at DOM suspension time
+ https://bugs.webkit.org/show_bug.cgi?id=206661
+ <rdar://problem/58800787>
+
+ Reviewed by Eric Carlson.
+
+ * TestWebKitAPI/Tests/WebKitLegacy/ios/ScrollingDoesNotPauseMedia.mm:
+ (TestWebKitAPI::TEST):
+ Suspend/resume Active DOM Objects from time to time as would do scrolling.
+ This allows pending tasks to be executed asynchronously when not scrolling.
+
+2020-01-28 Russell Epstein <[email protected]>
+
Cherry-pick r254711. rdar://problem/58537467
Regression(r253224) No longer able to prevent a tab from closing via the beforeunload prompt
Modified: branches/safari-610.1.1-branch/Tools/TestWebKitAPI/Tests/WebKitLegacy/ios/ScrollingDoesNotPauseMedia.mm (255301 => 255302)
--- branches/safari-610.1.1-branch/Tools/TestWebKitAPI/Tests/WebKitLegacy/ios/ScrollingDoesNotPauseMedia.mm 2020-01-28 21:49:50 UTC (rev 255301)
+++ branches/safari-610.1.1-branch/Tools/TestWebKitAPI/Tests/WebKitLegacy/ios/ScrollingDoesNotPauseMedia.mm 2020-01-28 21:49:54 UTC (rev 255302)
@@ -92,27 +92,31 @@
Util::run(&gotMainFrame);
callOnMainThreadAndWait([&] () mutable {
+ [mainFrame setTimeoutsPaused:YES];
+
DOMHTMLMediaElement* video = (DOMHTMLMediaElement*)[mainFrame.DOMDocument querySelector:@"video"];
ASSERT_TRUE([video isKindOfClass:[DOMHTMLMediaElement class]]);
[video addEventListener:@"playing" listener:testController.get() useCapture:NO];
-
- [mainFrame setTimeoutsPaused:YES];
didReceivePlaying = false;
[video play];
+
+ [mainFrame setTimeoutsPaused:NO];
});
Util::run(&didReceivePlaying);
callOnMainThreadAndWait([&] () mutable {
+ [mainFrame setTimeoutsPaused:YES];
+
DOMHTMLMediaElement* video = (DOMHTMLMediaElement*)[mainFrame.DOMDocument querySelector:@"video"];
ASSERT_TRUE([video isKindOfClass:[DOMHTMLMediaElement class]]);
[video addEventListener:@"pause" listener:testController.get() useCapture:NO];
+ didReceivePause = false;
+ [video pause];
[mainFrame setTimeoutsPaused:NO];
- didReceivePause = false;
- [video pause];
});
Util::run(&didReceivePause);