Title: [219621] trunk/Source/WebCore
- Revision
- 219621
- Author
- commit-qu...@webkit.org
- Date
- 2017-07-18 12:59:13 -0700 (Tue, 18 Jul 2017)
Log Message
[iOS] WebKit media controls are sometimes shown after exiting full screen on vimeo.com
https://bugs.webkit.org/show_bug.cgi?id=174627
<rdar://problem/33301005>
Patch by Antoine Quint <grao...@apple.com> on 2017-07-18
Reviewed by Dean Jackson, provisionally reviewed by Jeremy Jones.
On iOS 11, both the WebKit media controls and the Vimeo custom controls would appear sometimes when exiting
from fullscreen when the video was playing and the user would tap the X button, which would pause the video
as well as exit fullscreen.
The reason this happens is that the ControlsVisibilitySupport object, which governs whether the WebKit media
controls should be displayed for a given video, woud listen to "pause" and "webkitfullscreenchange" events
and determine whether to show the WebKit media controls. We listen to the "pause" event because when media
pauses, and the video has the "controls" attribute set, we should show the controls and suspend the controls
auto-hide timer. And we're interested in knowing when we enter and exit fullscreen because we want to override
the "controls" attribute not being set when we enter fullscreen.
However, on iOS 11, it appears that the "webkitfullscreenchange" event is not reliably fired as the user enters
and exits fullscreen, which is tracked by webkit.org/b/174626. So, when the user exits fullscreen, we would be
informed of the video being paused via a "pause" event, but not of the video exiting fullscreen. And because
media events are asynchronous, the "pause" event would sometimes be fired before we exited fullscreen, and when
the _updateControls() would run, we would sometimes determine that we are in fullscreen still and determine
that the WebKit media controls should be shown.
Of course, on iOS, the WebKit media controls are not shown and instead we delegate to AVKit to display media controls.
So we could simply disregard this whole logic in iOS. But we choose to instead use the "webkitpresentationmodechanged"
when the presentation mode API is supported, as is the case on iOS 11, to determine changes of media fullscreen state.
This way, should we ever choose to support fullscreen media controls provided by WebKit on iOS, this logic is already
correct and we write less platform-specific code.
This, alas, cannot be tested since we can't force the X button to be tapped within the AVKit fullscreen controls.
* Modules/modern-media-controls/media/controls-visibility-support.js:
(ControlsVisibilitySupport.prototype.get mediaEvents):
* Modules/modern-media-controls/media/media-controller.js:
(MediaController):
* Modules/modern-media-controls/media/start-support.js:
(StartSupport.prototype.get mediaEvents):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (219620 => 219621)
--- trunk/Source/WebCore/ChangeLog 2017-07-18 19:31:28 UTC (rev 219620)
+++ trunk/Source/WebCore/ChangeLog 2017-07-18 19:59:13 UTC (rev 219621)
@@ -1,3 +1,44 @@
+2017-07-18 Antoine Quint <grao...@apple.com>
+
+ [iOS] WebKit media controls are sometimes shown after exiting full screen on vimeo.com
+ https://bugs.webkit.org/show_bug.cgi?id=174627
+ <rdar://problem/33301005>
+
+ Reviewed by Dean Jackson, provisionally reviewed by Jeremy Jones.
+
+ On iOS 11, both the WebKit media controls and the Vimeo custom controls would appear sometimes when exiting
+ from fullscreen when the video was playing and the user would tap the X button, which would pause the video
+ as well as exit fullscreen.
+
+ The reason this happens is that the ControlsVisibilitySupport object, which governs whether the WebKit media
+ controls should be displayed for a given video, woud listen to "pause" and "webkitfullscreenchange" events
+ and determine whether to show the WebKit media controls. We listen to the "pause" event because when media
+ pauses, and the video has the "controls" attribute set, we should show the controls and suspend the controls
+ auto-hide timer. And we're interested in knowing when we enter and exit fullscreen because we want to override
+ the "controls" attribute not being set when we enter fullscreen.
+
+ However, on iOS 11, it appears that the "webkitfullscreenchange" event is not reliably fired as the user enters
+ and exits fullscreen, which is tracked by webkit.org/b/174626. So, when the user exits fullscreen, we would be
+ informed of the video being paused via a "pause" event, but not of the video exiting fullscreen. And because
+ media events are asynchronous, the "pause" event would sometimes be fired before we exited fullscreen, and when
+ the _updateControls() would run, we would sometimes determine that we are in fullscreen still and determine
+ that the WebKit media controls should be shown.
+
+ Of course, on iOS, the WebKit media controls are not shown and instead we delegate to AVKit to display media controls.
+ So we could simply disregard this whole logic in iOS. But we choose to instead use the "webkitpresentationmodechanged"
+ when the presentation mode API is supported, as is the case on iOS 11, to determine changes of media fullscreen state.
+ This way, should we ever choose to support fullscreen media controls provided by WebKit on iOS, this logic is already
+ correct and we write less platform-specific code.
+
+ This, alas, cannot be tested since we can't force the X button to be tapped within the AVKit fullscreen controls.
+
+ * Modules/modern-media-controls/media/controls-visibility-support.js:
+ (ControlsVisibilitySupport.prototype.get mediaEvents):
+ * Modules/modern-media-controls/media/media-controller.js:
+ (MediaController):
+ * Modules/modern-media-controls/media/start-support.js:
+ (StartSupport.prototype.get mediaEvents):
+
2017-07-18 Matt Lewis <jlew...@apple.com>
Unreviewed, rolling out r219610.
Modified: trunk/Source/WebCore/Modules/modern-media-controls/media/controls-visibility-support.js (219620 => 219621)
--- trunk/Source/WebCore/Modules/modern-media-controls/media/controls-visibility-support.js 2017-07-18 19:31:28 UTC (rev 219620)
+++ trunk/Source/WebCore/Modules/modern-media-controls/media/controls-visibility-support.js 2017-07-18 19:59:13 UTC (rev 219621)
@@ -45,7 +45,7 @@
get mediaEvents()
{
- return ["loadedmetadata", "play", "pause", "webkitfullscreenchange", "webkitcurrentplaybacktargetiswirelesschanged"];
+ return ["loadedmetadata", "play", "pause", "webkitcurrentplaybacktargetiswirelesschanged", this.mediaController.fullscreenChangeEventType];
}
get tracksToMonitor()
Modified: trunk/Source/WebCore/Modules/modern-media-controls/media/media-controller.js (219620 => 219621)
--- trunk/Source/WebCore/Modules/modern-media-controls/media/media-controller.js 2017-07-18 19:31:28 UTC (rev 219620)
+++ trunk/Source/WebCore/Modules/modern-media-controls/media/media-controller.js 2017-07-18 19:59:13 UTC (rev 219621)
@@ -32,6 +32,8 @@
this.media = media;
this.host = host;
+ this.fullscreenChangeEventType = media.webkitSupportsPresentationMode ? "webkitpresentationmodechanged" : "webkitfullscreenchange";
+
this.hasPlayed = false;
this.container = shadowRoot.appendChild(document.createElement("div"));
@@ -54,10 +56,7 @@
media.videoTracks.addEventListener("addtrack", this);
media.videoTracks.addEventListener("removetrack", this);
- if (media.webkitSupportsPresentationMode)
- media.addEventListener("webkitpresentationmodechanged", this);
- else
- media.addEventListener("webkitfullscreenchange", this);
+ media.addEventListener(this.fullscreenChangeEventType, this);
}
// Public
Modified: trunk/Source/WebCore/Modules/modern-media-controls/media/start-support.js (219620 => 219621)
--- trunk/Source/WebCore/Modules/modern-media-controls/media/start-support.js 2017-07-18 19:31:28 UTC (rev 219620)
+++ trunk/Source/WebCore/Modules/modern-media-controls/media/start-support.js 2017-07-18 19:59:13 UTC (rev 219621)
@@ -37,7 +37,7 @@
get mediaEvents()
{
- return ["loadedmetadata", "play", "error", "webkitfullscreenchange"];
+ return ["loadedmetadata", "play", "error", this.mediaController.fullscreenChangeEventType];
}
buttonWasPressed(control)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes