Title: [227272] trunk
Revision
227272
Author
jer.no...@apple.com
Date
2018-01-20 08:55:45 -0800 (Sat, 20 Jan 2018)

Log Message

Release ASSERT when reloading Vimeo page @ WebCore: WebCore::Document::updateLayout
https://bugs.webkit.org/show_bug.cgi?id=181840
<rdar://problem/36186214>

Reviewed by Simon Fraser.

Source/WebCore:

Test: media/video-fullscreen-reload-crash.html

Short circuit play() or pause() operations if the document is suspended or stopped.

* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::playInternal):
(WebCore::HTMLMediaElement::pauseInternal):

Source/WebKit:

Updating layout while the document is suspended or stopped is unsafe.

* WebProcess/cocoa/VideoFullscreenManager.mm:
(WebKit::inlineVideoFrame):

LayoutTests:

* media/video-fullscreen-reload-crash-expected.txt: Added.
* media/video-fullscreen-reload-crash.html: Added.
* platform/ios/TestExpectations:

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (227271 => 227272)


--- trunk/LayoutTests/ChangeLog	2018-01-20 12:53:52 UTC (rev 227271)
+++ trunk/LayoutTests/ChangeLog	2018-01-20 16:55:45 UTC (rev 227272)
@@ -1,3 +1,15 @@
+2018-01-20  Jer Noble  <jer.no...@apple.com>
+
+        Release ASSERT when reloading Vimeo page @ WebCore: WebCore::Document::updateLayout
+        https://bugs.webkit.org/show_bug.cgi?id=181840
+        <rdar://problem/36186214>
+
+        Reviewed by Simon Fraser.
+
+        * media/video-fullscreen-reload-crash-expected.txt: Added.
+        * media/video-fullscreen-reload-crash.html: Added.
+        * platform/ios/TestExpectations:
+
 2018-01-20  Youenn Fablet  <you...@apple.com>
 
         fetch redirect is incompatible with "no-cors" mode

Added: trunk/LayoutTests/media/video-fullscreen-reload-crash-expected.txt (0 => 227272)


--- trunk/LayoutTests/media/video-fullscreen-reload-crash-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/media/video-fullscreen-reload-crash-expected.txt	2018-01-20 16:55:45 UTC (rev 227272)
@@ -0,0 +1,10 @@
+Destroy the document containing a video while that video is in fullscreen; should not crash.
+
+RUN(internals.settings.setAllowsInlineMediaPlayback(false))
+RUN(video.load())
+EVENT(canplaythrough)
+RUN(video.play())
+EVENT(webkitbeginfullscreen)
+RUN(iframe.src = ""
+END OF TEST
+

Added: trunk/LayoutTests/media/video-fullscreen-reload-crash.html (0 => 227272)


--- trunk/LayoutTests/media/video-fullscreen-reload-crash.html	                        (rev 0)
+++ trunk/LayoutTests/media/video-fullscreen-reload-crash.html	2018-01-20 16:55:45 UTC (rev 227272)
@@ -0,0 +1,47 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+<script src=""
+<script>
+function runTest() {
+    run('internals.settings.setAllowsInlineMediaPlayback(false)');
+
+    iframe = document.querySelector('iframe');
+    mediaElement = video = iframe.contentDocument.createElement('video');
+    iframe.contentDocument.body.appendChild(video);
+
+    video.controls = true;
+    video.src = "" "content/test");
+    video.style.width = '100%';
+    video.style.height = '100%';
+
+    video.addEventListener('webkitbeginfullscreen', beginfullscreen);
+    video.addEventListener('webkitfullscreenchange', beginfullscreen);
+    waitForEvent('canplaythrough', canplaythrough);
+
+    runWithKeyDown(() => {
+        run('video.load()');
+    });
+}
+
+function canplaythrough() {
+    runWithKeyDown(() => {
+        run('video.play()');
+    });
+}
+
+function beginfullscreen() {
+    consoleWrite("EVENT(webkitbeginfullscreen)");
+    setTimeout(() => {
+        run('iframe.src = ""
+        setTimeout(endTest, 100);
+    }, 1000);
+}
+</script>
+</head>
+<body _onload_="runTest()">
+    <div>Destroy the document containing a video while that video is in fullscreen; should not crash.</div>
+    <iframe></iframe>
+</body>
+</html>

Modified: trunk/LayoutTests/platform/ios/TestExpectations (227271 => 227272)


--- trunk/LayoutTests/platform/ios/TestExpectations	2018-01-20 12:53:52 UTC (rev 227271)
+++ trunk/LayoutTests/platform/ios/TestExpectations	2018-01-20 16:55:45 UTC (rev 227272)
@@ -951,6 +951,7 @@
 media/audio-playback-volume-changes-with-restrictions.html [ Skip ]
 media/restricted-audio-playback-with-document-gesture.html [ Skip ]
 media/restricted-audio-playback-with-multiple-settimeouts.html [ Skip ]
+media/video-fullscreen-reload-crash.html [ Skip ]
 scrollbars/scrolling-backward-by-page-accounting-bottom-fixed-elements-on-keyboard-spacebar.html [ Skip ]
 scrollbars/scrolling-backward-by-page-on-keyboard-spacebar.html [ Skip ]
 scrollbars/scrolling-by-page-accounting-oversized-fixed-elements-on-keyboard-spacebar.html [ Skip ]

Modified: trunk/Source/WebCore/ChangeLog (227271 => 227272)


--- trunk/Source/WebCore/ChangeLog	2018-01-20 12:53:52 UTC (rev 227271)
+++ trunk/Source/WebCore/ChangeLog	2018-01-20 16:55:45 UTC (rev 227272)
@@ -1,3 +1,19 @@
+2018-01-20  Jer Noble  <jer.no...@apple.com>
+
+        Release ASSERT when reloading Vimeo page @ WebCore: WebCore::Document::updateLayout
+        https://bugs.webkit.org/show_bug.cgi?id=181840
+        <rdar://problem/36186214>
+
+        Reviewed by Simon Fraser.
+
+        Test: media/video-fullscreen-reload-crash.html
+
+        Short circuit play() or pause() operations if the document is suspended or stopped.
+
+        * html/HTMLMediaElement.cpp:
+        (WebCore::HTMLMediaElement::playInternal):
+        (WebCore::HTMLMediaElement::pauseInternal):
+
 2018-01-20  Youenn Fablet  <you...@apple.com>
 
         fetch redirect is incompatible with "no-cors" mode

Modified: trunk/Source/WebCore/dom/Document.h (227271 => 227272)


--- trunk/Source/WebCore/dom/Document.h	2018-01-20 12:53:52 UTC (rev 227271)
+++ trunk/Source/WebCore/dom/Document.h	2018-01-20 16:55:45 UTC (rev 227272)
@@ -1251,7 +1251,7 @@
 
     bool inStyleRecalc() const { return m_inStyleRecalc; }
     bool inRenderTreeUpdate() const { return m_inRenderTreeUpdate; }
-    bool isSafeToUpdateStyleOrLayout() const;
+    WEBCORE_EXPORT bool isSafeToUpdateStyleOrLayout() const;
 
     void updateTextRenderer(Text&, unsigned offsetOfReplacedText, unsigned lengthOfReplacedText);
 

Modified: trunk/Source/WebCore/html/HTMLMediaElement.cpp (227271 => 227272)


--- trunk/Source/WebCore/html/HTMLMediaElement.cpp	2018-01-20 12:53:52 UTC (rev 227271)
+++ trunk/Source/WebCore/html/HTMLMediaElement.cpp	2018-01-20 16:55:45 UTC (rev 227272)
@@ -3442,6 +3442,11 @@
 {
     ALWAYS_LOG(LOGIDENTIFIER);
 
+    if (isSuspended()) {
+        ALWAYS_LOG(LOGIDENTIFIER, "  returning because context is suspended");
+        return;
+    }
+
     if (!m_mediaSession->clientWillBeginPlayback()) {
         ALWAYS_LOG(LOGIDENTIFIER, "  returning because of interruption");
         return;
@@ -3527,6 +3532,11 @@
 {
     ALWAYS_LOG(LOGIDENTIFIER);
 
+    if (isSuspended()) {
+        ALWAYS_LOG(LOGIDENTIFIER, "  returning because context is suspended");
+        return;
+    }
+
     if (!m_mediaSession->clientWillPausePlayback()) {
         ALWAYS_LOG(LOGIDENTIFIER, "  returning because of interruption");
         return;

Modified: trunk/Source/WebKit/ChangeLog (227271 => 227272)


--- trunk/Source/WebKit/ChangeLog	2018-01-20 12:53:52 UTC (rev 227271)
+++ trunk/Source/WebKit/ChangeLog	2018-01-20 16:55:45 UTC (rev 227272)
@@ -1,3 +1,16 @@
+2018-01-20  Jer Noble  <jer.no...@apple.com>
+
+        Release ASSERT when reloading Vimeo page @ WebCore: WebCore::Document::updateLayout
+        https://bugs.webkit.org/show_bug.cgi?id=181840
+        <rdar://problem/36186214>
+
+        Reviewed by Simon Fraser.
+
+        Updating layout while the document is suspended or stopped is unsafe.
+
+        * WebProcess/cocoa/VideoFullscreenManager.mm:
+        (WebKit::inlineVideoFrame):
+
 2018-01-20  Chris Dumez  <cdu...@apple.com>
 
         DOMCache data sometimes not properly removed when clearing data for a given origin

Modified: trunk/Source/WebKit/WebProcess/cocoa/VideoFullscreenManager.mm (227271 => 227272)


--- trunk/Source/WebKit/WebProcess/cocoa/VideoFullscreenManager.mm	2018-01-20 12:53:52 UTC (rev 227271)
+++ trunk/Source/WebKit/WebProcess/cocoa/VideoFullscreenManager.mm	2018-01-20 16:55:45 UTC (rev 227272)
@@ -58,7 +58,11 @@
 
 static IntRect inlineVideoFrame(HTMLVideoElement& element)
 {
-    element.document().updateLayoutIgnorePendingStylesheets();
+    auto& document = element.document();
+    if (!document.isSafeToUpdateStyleOrLayout())
+        return { };
+
+    document.updateLayoutIgnorePendingStylesheets();
     auto* renderer = element.renderer();
     if (!renderer)
         return { };
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to