Title: [264684] trunk/Source/WebCore
Revision
264684
Author
peng.l...@apple.com
Date
2020-07-21 17:21:25 -0700 (Tue, 21 Jul 2020)

Log Message

Safari is unresponsive after playing a video of youtube.com playlist in picture-in-picture mode
https://bugs.webkit.org/show_bug.cgi?id=214616

Reviewed by Eric Carlson.

Remove the function setPreparedToReturnVideoLayerToInline() from
MediaControlsHost.idl and replace all the calls to that function
in _javascript_ code with a call in HTMLVideoElement::fullscreenModeChanged().

Calling setPreparedToReturnVideoLayerToInline() in the _javascript_ code of
modern media controls can be problematic because the host object might have
been destroyed when the webkitpresentationmodechanged event is fired.
During the exit fullscreen/picture-in-picture transaction, missing a call to
setPreparedToReturnVideoLayerToInline() will block the transaction,
and the UI process will be stuck in a bad state.

* Modules/mediacontrols/MediaControlsHost.cpp:
(WebCore::MediaControlsHost::setPreparedToReturnVideoLayerToInline): Deleted.
* Modules/mediacontrols/MediaControlsHost.h:
* Modules/mediacontrols/MediaControlsHost.idl:
* Modules/mediacontrols/mediaControlsApple.js:
(Controller.prototype.handlePresentationModeChange):
* Modules/modern-media-controls/media/media-controller.js:
(MediaController.prototype.handleEvent):
(MediaController.prototype._returnMediaLayerToInlineIfNeeded): Deleted.
* html/HTMLVideoElement.cpp:
(WebCore::HTMLVideoElement::fullscreenModeChanged):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (264683 => 264684)


--- trunk/Source/WebCore/ChangeLog	2020-07-22 00:09:59 UTC (rev 264683)
+++ trunk/Source/WebCore/ChangeLog	2020-07-22 00:21:25 UTC (rev 264684)
@@ -1,3 +1,33 @@
+2020-07-21  Peng Liu  <peng.l...@apple.com>
+
+        Safari is unresponsive after playing a video of youtube.com playlist in picture-in-picture mode
+        https://bugs.webkit.org/show_bug.cgi?id=214616
+
+        Reviewed by Eric Carlson.
+
+        Remove the function setPreparedToReturnVideoLayerToInline() from
+        MediaControlsHost.idl and replace all the calls to that function
+        in _javascript_ code with a call in HTMLVideoElement::fullscreenModeChanged().
+
+        Calling setPreparedToReturnVideoLayerToInline() in the _javascript_ code of
+        modern media controls can be problematic because the host object might have
+        been destroyed when the webkitpresentationmodechanged event is fired.
+        During the exit fullscreen/picture-in-picture transaction, missing a call to
+        setPreparedToReturnVideoLayerToInline() will block the transaction,
+        and the UI process will be stuck in a bad state.
+
+        * Modules/mediacontrols/MediaControlsHost.cpp:
+        (WebCore::MediaControlsHost::setPreparedToReturnVideoLayerToInline): Deleted.
+        * Modules/mediacontrols/MediaControlsHost.h:
+        * Modules/mediacontrols/MediaControlsHost.idl:
+        * Modules/mediacontrols/mediaControlsApple.js:
+        (Controller.prototype.handlePresentationModeChange):
+        * Modules/modern-media-controls/media/media-controller.js:
+        (MediaController.prototype.handleEvent):
+        (MediaController.prototype._returnMediaLayerToInlineIfNeeded): Deleted.
+        * html/HTMLVideoElement.cpp:
+        (WebCore::HTMLVideoElement::fullscreenModeChanged):
+
 2020-07-21  Tim Horton  <timothy_hor...@apple.com>
 
         REGRESSION (WebSQL disablement): Fudget app is unresponsive on launch

Modified: trunk/Source/WebCore/Modules/mediacontrols/MediaControlsHost.cpp (264683 => 264684)


--- trunk/Source/WebCore/Modules/mediacontrols/MediaControlsHost.cpp	2020-07-22 00:09:59 UTC (rev 264683)
+++ trunk/Source/WebCore/Modules/mediacontrols/MediaControlsHost.cpp	2020-07-22 00:21:25 UTC (rev 264684)
@@ -215,12 +215,6 @@
     return m_mediaElement && m_mediaElement->document().isMediaDocument();
 }
 
-void MediaControlsHost::setPreparedToReturnVideoLayerToInline(bool value)
-{
-    if (m_mediaElement)
-        m_mediaElement->setPreparedToReturnVideoLayerToInline(value);
-}
-
 bool MediaControlsHost::userGestureRequired() const
 {
     return m_mediaElement && !m_mediaElement->mediaSession().playbackPermitted();

Modified: trunk/Source/WebCore/Modules/mediacontrols/MediaControlsHost.h (264683 => 264684)


--- trunk/Source/WebCore/Modules/mediacontrols/MediaControlsHost.h	2020-07-22 00:09:59 UTC (rev 264683)
+++ trunk/Source/WebCore/Modules/mediacontrols/MediaControlsHost.h	2020-07-22 00:21:25 UTC (rev 264684)
@@ -67,7 +67,6 @@
     bool isInMediaDocument() const;
     bool userGestureRequired() const;
     bool shouldForceControlsDisplay() const;
-    void setPreparedToReturnVideoLayerToInline(bool);
 
     enum class ForceUpdate { Yes, No };
     void updateCaptionDisplaySizes(ForceUpdate = ForceUpdate::No);

Modified: trunk/Source/WebCore/Modules/mediacontrols/MediaControlsHost.idl (264683 => 264684)


--- trunk/Source/WebCore/Modules/mediacontrols/MediaControlsHost.idl	2020-07-22 00:09:59 UTC (rev 264683)
+++ trunk/Source/WebCore/Modules/mediacontrols/MediaControlsHost.idl	2020-07-22 00:21:25 UTC (rev 264684)
@@ -41,7 +41,6 @@
     readonly attribute TextTrack captionMenuAutomaticItem;
     readonly attribute DOMString captionDisplayMode;
     void setSelectedTextTrack(TextTrack? track);
-    void setPreparedToReturnVideoLayerToInline(boolean prepared);
     readonly attribute HTMLElement textTrackContainer;
     readonly attribute boolean allowsInlineMediaPlayback;
     readonly attribute boolean supportsFullscreen;

Modified: trunk/Source/WebCore/Modules/mediacontrols/mediaControlsApple.js (264683 => 264684)


--- trunk/Source/WebCore/Modules/mediacontrols/mediaControlsApple.js	2020-07-22 00:09:59 UTC (rev 264683)
+++ trunk/Source/WebCore/Modules/mediacontrols/mediaControlsApple.js	2020-07-22 00:21:25 UTC (rev 264684)
@@ -962,7 +962,6 @@
         this.resetHideControlsTimer();
         if (this.presentationMode() != 'fullscreen' && this.video.paused && this.controlsAreHidden())
             this.showControls();
-        this.host.setPreparedToReturnVideoLayerToInline(this.shouldReturnVideoLayerToInline());
     },
 
     handleFullscreenChange: function(event)

Modified: trunk/Source/WebCore/Modules/modern-media-controls/media/media-controller.js (264683 => 264684)


--- trunk/Source/WebCore/Modules/modern-media-controls/media/media-controller.js	2020-07-22 00:09:59 UTC (rev 264683)
+++ trunk/Source/WebCore/Modules/modern-media-controls/media/media-controller.js	2020-07-22 00:21:25 UTC (rev 264684)
@@ -173,8 +173,6 @@
                 this.hasPlayed = true;
             this._updateControlsIfNeeded();
             this._updateControlsAvailability();
-            if (event.type === "webkitpresentationmodechanged")
-                this._returnMediaLayerToInlineIfNeeded();
         } else if (event.type === "keydown" && this.isFullscreen && event.key === " ") {
             this.togglePlayback();
             event.preventDefault();
@@ -281,12 +279,6 @@
         this.controls.shouldCenterControlsVertically = this.isAudio;
     }
 
-    _returnMediaLayerToInlineIfNeeded()
-    {
-        if (this.host)
-            this.host.setPreparedToReturnVideoLayerToInline(this.media.webkitPresentationMode !== PiPMode);
-    }
-
     _controlsClassForLayoutTraits(layoutTraits)
     {
         if (layoutTraits & LayoutTraits.Compact)

Modified: trunk/Source/WebCore/html/HTMLVideoElement.cpp (264683 => 264684)


--- trunk/Source/WebCore/html/HTMLVideoElement.cpp	2020-07-22 00:09:59 UTC (rev 264683)
+++ trunk/Source/WebCore/html/HTMLVideoElement.cpp	2020-07-22 00:21:25 UTC (rev 264684)
@@ -510,6 +510,7 @@
     if (mode != fullscreenMode()) {
         INFO_LOG(LOGIDENTIFIER, "changed from ", fullscreenMode(), ", to ", mode);
         scheduleEvent(eventNames().webkitpresentationmodechangedEvent);
+        setPreparedToReturnVideoLayerToInline(mode != HTMLMediaElementEnums::VideoFullscreenModePictureInPicture);
     }
 
     if (player())
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to