Title: [241487] trunk
Revision
241487
Author
[email protected]
Date
2019-02-13 16:28:55 -0800 (Wed, 13 Feb 2019)

Log Message

[iOS] Add a hack to work around buggy video control library
https://bugs.webkit.org/show_bug.cgi?id=194615
<rdar://problem/46146946>

Reviewed by Jer Noble.

Source/WebCore:

Test: media/ios/video-volume-ios-quirk.html

* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::setVolume): Change m_volume for one turn of the runloop.
(WebCore::HTMLMediaElement::cancelPendingTasks): Clear the task queue used to restore m_volume.
(WebCore::HTMLMediaElement::closeTaskQueues): Close it.
* html/HTMLMediaElement.h:

LayoutTests:

* media/ios/video-volume-ios-quirk-expected.txt: Added.
* media/ios/video-volume-ios-quirk.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (241486 => 241487)


--- trunk/LayoutTests/ChangeLog	2019-02-14 00:21:47 UTC (rev 241486)
+++ trunk/LayoutTests/ChangeLog	2019-02-14 00:28:55 UTC (rev 241487)
@@ -1,3 +1,14 @@
+2019-02-13  Eric Carlson  <[email protected]>
+
+        [iOS] Add a hack to work around buggy video control library
+        https://bugs.webkit.org/show_bug.cgi?id=194615
+        <rdar://problem/46146946>
+
+        Reviewed by Jer Noble.
+
+        * media/ios/video-volume-ios-quirk-expected.txt: Added.
+        * media/ios/video-volume-ios-quirk.html: Added.
+
 2019-02-13  Jer Noble  <[email protected]>
 
         Entering fullscreen inside a shadow root will not set fullscreen pseudoclasses outside of root

Added: trunk/LayoutTests/media/ios/video-volume-ios-quirk-expected.txt (0 => 241487)


--- trunk/LayoutTests/media/ios/video-volume-ios-quirk-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/media/ios/video-volume-ios-quirk-expected.txt	2019-02-14 00:28:55 UTC (rev 241487)
@@ -0,0 +1,13 @@
+
+Test 'volume' attribute
+
+EXPECTED (video.volume == '1') OK
+RUN(video.volume = 0.5)
+EXPECTED (video.volume == '0.5') OK
+RUN(video.volume = 0)
+EXPECTED (video.volume == '0') OK
+TEST(video.volume = 1.5) THROWS(DOMException.INDEX_SIZE_ERR) OK
+TEST(video.volume = -0.5) THROWS(DOMException.INDEX_SIZE_ERR) OK
+EXPECTED (video.volume == '1') OK
+END OF TEST
+

Added: trunk/LayoutTests/media/ios/video-volume-ios-quirk.html (0 => 241487)


--- trunk/LayoutTests/media/ios/video-volume-ios-quirk.html	                        (rev 0)
+++ trunk/LayoutTests/media/ios/video-volume-ios-quirk.html	2019-02-14 00:28:55 UTC (rev 241487)
@@ -0,0 +1,19 @@
+<video controls></video>
+<p>Test 'volume' attribute<p>
+<script src=""
+<script src=""
+<script>
+    testExpected("video.volume", 1.0);
+    run("video.volume = 0.5");
+    testExpected("video.volume", 0.5);
+    run("video.volume = 0");
+    testExpected("video.volume", 0);
+    testDOMException("video.volume = 1.5", "DOMException.INDEX_SIZE_ERR");
+    testDOMException("video.volume = -0.5", "DOMException.INDEX_SIZE_ERR");
+    video.src = "" "content/test");
+
+	setTimeout(function() { 
+	    testExpected("video.volume", 1.0);
+        endTest();
+	} , 100);
+</script>

Modified: trunk/Source/WebCore/ChangeLog (241486 => 241487)


--- trunk/Source/WebCore/ChangeLog	2019-02-14 00:21:47 UTC (rev 241486)
+++ trunk/Source/WebCore/ChangeLog	2019-02-14 00:28:55 UTC (rev 241487)
@@ -1,3 +1,19 @@
+2019-02-13  Eric Carlson  <[email protected]>
+
+        [iOS] Add a hack to work around buggy video control library
+        https://bugs.webkit.org/show_bug.cgi?id=194615
+        <rdar://problem/46146946>
+
+        Reviewed by Jer Noble.
+
+        Test: media/ios/video-volume-ios-quirk.html
+
+        * html/HTMLMediaElement.cpp:
+        (WebCore::HTMLMediaElement::setVolume): Change m_volume for one turn of the runloop.
+        (WebCore::HTMLMediaElement::cancelPendingTasks): Clear the task queue used to restore m_volume.
+        (WebCore::HTMLMediaElement::closeTaskQueues): Close it.
+        * html/HTMLMediaElement.h:
+
 2019-02-13  Jer Noble  <[email protected]>
 
         [Cocoa] Media elements will restart network buffering just before suspending

Modified: trunk/Source/WebCore/html/HTMLMediaElement.cpp (241486 => 241487)


--- trunk/Source/WebCore/html/HTMLMediaElement.cpp	2019-02-14 00:21:47 UTC (rev 241486)
+++ trunk/Source/WebCore/html/HTMLMediaElement.cpp	2019-02-14 00:28:55 UTC (rev 241487)
@@ -3722,10 +3722,10 @@
     if (!(volume >= 0 && volume <= 1))
         return Exception { IndexSizeError };
 
-#if !PLATFORM(IOS_FAMILY)
     if (m_volume == volume)
         return { };
 
+#if !PLATFORM(IOS_FAMILY)
     if (volume && processingUserGestureForMedia())
         removeBehaviorsRestrictionsAfterFirstUserGesture(MediaElementSession::AllRestrictions & ~MediaElementSession::RequireUserGestureToControlControlsManager);
 
@@ -3738,7 +3738,19 @@
         pauseInternal();
         setAutoplayEventPlaybackState(AutoplayEventPlaybackState::PreventedAutoplay);
     }
+#else
+    auto oldVolume = m_volume;
+    m_volume = volume;
+
+    if (m_volumeRevertTaskQueue.hasPendingTask())
+        return { };
+
+    m_volumeRevertTaskQueue.scheduleTask([this, oldVolume] {
+        m_volume = oldVolume;
+    });
+
 #endif
+    
     return { };
 }
 
@@ -5527,6 +5539,9 @@
     m_updateMediaStateTask.cancelTask();
     m_mediaEngineUpdatedTask.cancelTask();
     m_updatePlayStateTask.cancelTask();
+#if PLATFORM(IOS_FAMILY)
+    m_volumeRevertTaskQueue.cancelTask();
+#endif
 }
 
 void HTMLMediaElement::userCancelledLoad()
@@ -5705,6 +5720,9 @@
     m_encryptedMediaQueue.close();
 #endif
     m_asyncEventQueue.close();
+#if PLATFORM(IOS_FAMILY)
+    m_volumeRevertTaskQueue.close();
+#endif
 }
 
 void HTMLMediaElement::contextDestroyed()

Modified: trunk/Source/WebCore/html/HTMLMediaElement.h (241486 => 241487)


--- trunk/Source/WebCore/html/HTMLMediaElement.h	2019-02-14 00:21:47 UTC (rev 241486)
+++ trunk/Source/WebCore/html/HTMLMediaElement.h	2019-02-14 00:28:55 UTC (rev 241487)
@@ -967,6 +967,9 @@
     GenericTaskQueue<Timer> m_playbackTargetIsWirelessQueue;
     RefPtr<TimeRanges> m_playedTimeRanges;
     GenericEventQueue m_asyncEventQueue;
+#if PLATFORM(IOS_FAMILY)
+    DeferrableTask<Timer> m_volumeRevertTaskQueue;
+#endif
 
     PlayPromiseVector m_pendingPlayPromises;
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to