<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[284741] trunk</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/284741">284741</a></dd>
<dt>Author</dt> <dd>jya@apple.com</dd>
<dt>Date</dt> <dd>2021-10-22 22:58:14 -0700 (Fri, 22 Oct 2021)</dd>
</dl>

<h3>Log Message</h3>
<pre>video appears blank with only audio playing if video element isn't appended to the dom tree
https://bugs.webkit.org/show_bug.cgi?id=232124
rdar://83438282

Reviewed by Eric Carlson.

Source/WebCore:

If the renderer isn't accelerated, the current playback policity is to
not have the video tracks visible on screen.
The HTMLMediaElement could only check if the renderer was accelerated if
it was part of the DOM.
On iPhone, for historical reasons, inline playback isn't allowed but
will play fullscreen instead.

This is a temporary workaround until bug 232125 is comlpeted which would provide
a more elegant and universal solution.

Test: media/video-element-fullscreen-not-in-dom-accelerated-iphone.html

* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::mediaPlayerRenderingCanBeAccelerated):
* html/HTMLMediaElement.h:
* testing/Internals.cpp:
(WebCore::Internals::mediaPlayerRenderingCanBeAccelerated):
* testing/Internals.h:
* testing/Internals.idl:

Source/WebKit:

Ensure that we inform the GPU process whenever
MediaPlayer::renderingCanBeAccelerated value could have changed.

* WebProcess/GPU/media/MediaPlayerPrivateRemote.cpp:
(WebKit::MediaPlayerPrivateRemote::load):
(WebKit::MediaPlayerPrivateRemote::readyStateChanged):
(WebKit::MediaPlayerPrivateRemote::checkAcceleratedRenderingState):
(WebKit::MediaPlayerPrivateRemote::updateConfiguration):
(WebKit::MediaPlayerPrivateRemote::setVideoFullscreenLayer):
(WebKit::MediaPlayerPrivateRemote::setVideoFullscreenGravity):
* WebProcess/GPU/media/MediaPlayerPrivateRemote.h:

LayoutTests:

* TestExpectations:
* media/remove-video-element-in-pip-from-document-expected.txt:
* media/remove-video-element-in-pip-from-document.html: update test to improve coverage.
* media/video-element-fullscreen-not-in-dom-accelerated-iphone-expected.txt: Added.
* media/video-element-fullscreen-not-in-dom-accelerated-iphone.html: Added.
* platform/ios/TestExpectations:
* platform/ipad/TestExpectations:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsTestExpectations">trunk/LayoutTests/TestExpectations</a></li>
<li><a href="#trunkLayoutTestsmediaremovevideoelementinpipfromdocumentexpectedtxt">trunk/LayoutTests/media/remove-video-element-in-pip-from-document-expected.txt</a></li>
<li><a href="#trunkLayoutTestsmediaremovevideoelementinpipfromdocumenthtml">trunk/LayoutTests/media/remove-video-element-in-pip-from-document.html</a></li>
<li><a href="#trunkLayoutTestsplatformiosTestExpectations">trunk/LayoutTests/platform/ios/TestExpectations</a></li>
<li><a href="#trunkLayoutTestsplatformipadTestExpectations">trunk/LayoutTests/platform/ipad/TestExpectations</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorehtmlHTMLMediaElementcpp">trunk/Source/WebCore/html/HTMLMediaElement.cpp</a></li>
<li><a href="#trunkSourceWebCorehtmlHTMLMediaElementh">trunk/Source/WebCore/html/HTMLMediaElement.h</a></li>
<li><a href="#trunkSourceWebCoretestingInternalscpp">trunk/Source/WebCore/testing/Internals.cpp</a></li>
<li><a href="#trunkSourceWebCoretestingInternalsh">trunk/Source/WebCore/testing/Internals.h</a></li>
<li><a href="#trunkSourceWebCoretestingInternalsidl">trunk/Source/WebCore/testing/Internals.idl</a></li>
<li><a href="#trunkSourceWebKitChangeLog">trunk/Source/WebKit/ChangeLog</a></li>
<li><a href="#trunkSourceWebKitWebProcessGPUmediaMediaPlayerPrivateRemotecpp">trunk/Source/WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.cpp</a></li>
<li><a href="#trunkSourceWebKitWebProcessGPUmediaMediaPlayerPrivateRemoteh">trunk/Source/WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.h</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsmediavideoelementfullscreennotindomacceleratediphoneexpectedtxt">trunk/LayoutTests/media/video-element-fullscreen-not-in-dom-accelerated-iphone-expected.txt</a></li>
<li><a href="#trunkLayoutTestsmediavideoelementfullscreennotindomacceleratediphonehtml">trunk/LayoutTests/media/video-element-fullscreen-not-in-dom-accelerated-iphone.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (284740 => 284741)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog      2021-10-23 04:07:11 UTC (rev 284740)
+++ trunk/LayoutTests/ChangeLog 2021-10-23 05:58:14 UTC (rev 284741)
</span><span class="lines">@@ -1,3 +1,19 @@
</span><ins>+2021-10-22  Jean-Yves Avenard  <jya@apple.com>
+
+        video appears blank with only audio playing if video element isn't appended to the dom tree
+        https://bugs.webkit.org/show_bug.cgi?id=232124
+        rdar://83438282
+
+        Reviewed by Eric Carlson.
+
+        * TestExpectations:
+        * media/remove-video-element-in-pip-from-document-expected.txt:
+        * media/remove-video-element-in-pip-from-document.html: update test to improve coverage.
+        * media/video-element-fullscreen-not-in-dom-accelerated-iphone-expected.txt: Added.
+        * media/video-element-fullscreen-not-in-dom-accelerated-iphone.html: Added.
+        * platform/ios/TestExpectations:
+        * platform/ipad/TestExpectations:
+
</ins><span class="cx"> 2021-10-22  Said Abou-Hallawa  <said@apple.com>
</span><span class="cx"> 
</span><span class="cx">         [GPU Process] REGRESSION: Drawing a large SVG image on a canvas may take too much memory
</span></span></pre></div>
<a id="trunkLayoutTestsTestExpectations"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/TestExpectations (284740 => 284741)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/TestExpectations       2021-10-23 04:07:11 UTC (rev 284740)
+++ trunk/LayoutTests/TestExpectations  2021-10-23 05:58:14 UTC (rev 284741)
</span><span class="lines">@@ -278,6 +278,8 @@
</span><span class="cx"> media/picture-in-picture [ Skip ]
</span><span class="cx"> 
</span><span class="cx"> media/remove-video-element-in-pip-from-document.html [ Skip ]
</span><ins>+# This test is only relevent on iPhone where videos always play in fullscreen.
+media/video-element-fullscreen-not-in-dom-accelerated-iphone.html [ Skip ]
</ins><span class="cx"> 
</span><span class="cx"> # Shared Workers are unsupported
</span><span class="cx"> imported/w3c/web-platform-tests/secure-contexts/basic-shared-worker.html [ Skip ]
</span></span></pre></div>
<a id="trunkLayoutTestsmediaremovevideoelementinpipfromdocumentexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/media/remove-video-element-in-pip-from-document-expected.txt (284740 => 284741)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/media/remove-video-element-in-pip-from-document-expected.txt   2021-10-23 04:07:11 UTC (rev 284740)
+++ trunk/LayoutTests/media/remove-video-element-in-pip-from-document-expected.txt      2021-10-23 05:58:14 UTC (rev 284741)
</span><span class="lines">@@ -4,6 +4,7 @@
</span><span class="cx"> RUN(internals.setMockVideoPresentationModeEnabled(true))
</span><span class="cx"> EVENT(canplaythrough)
</span><span class="cx"> EVENT(enterpictureinpicture)
</span><ins>+EXPECTED (window.internals.mediaPlayerRenderingCanBeAccelerated(video) == 'true') OK
</ins><span class="cx"> EXPECTED (pipWindow.width > '0') OK
</span><span class="cx"> EXPECTED (pipWindow.height > '0') OK
</span><span class="cx"> The video element has been removed from DOM.
</span></span></pre></div>
<a id="trunkLayoutTestsmediaremovevideoelementinpipfromdocumenthtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/media/remove-video-element-in-pip-from-document.html (284740 => 284741)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/media/remove-video-element-in-pip-from-document.html   2021-10-23 04:07:11 UTC (rev 284740)
+++ trunk/LayoutTests/media/remove-video-element-in-pip-from-document.html      2021-10-23 05:58:14 UTC (rev 284741)
</span><span class="lines">@@ -25,6 +25,7 @@
</span><span class="cx"> 
</span><span class="cx">             waitForEventOnce('enterpictureinpicture', event => {
</span><span class="cx">                 window.pipWindow = event.pictureInPictureWindow;
</span><ins>+                testExpected('window.internals.mediaPlayerRenderingCanBeAccelerated(video)', true);
</ins><span class="cx">                 testExpected('pipWindow.width', 0, '>');
</span><span class="cx">                 testExpected('pipWindow.height', 0, '>');
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkLayoutTestsmediavideoelementfullscreennotindomacceleratediphoneexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/media/video-element-fullscreen-not-in-dom-accelerated-iphone-expected.txt (0 => 284741)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/media/video-element-fullscreen-not-in-dom-accelerated-iphone-expected.txt                              (rev 0)
+++ trunk/LayoutTests/media/video-element-fullscreen-not-in-dom-accelerated-iphone-expected.txt 2021-10-23 05:58:14 UTC (rev 284741)
</span><span class="lines">@@ -0,0 +1,6 @@
</span><ins>+Test that playing a video in fullscreen is accelerated.
+
+EVENT(webkitbeginfullscreen)
+EXPECTED (window.internals.mediaPlayerRenderingCanBeAccelerated(video) == 'true') OK
+END OF TEST
+
</ins></span></pre></div>
<a id="trunkLayoutTestsmediavideoelementfullscreennotindomacceleratediphonehtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/media/video-element-fullscreen-not-in-dom-accelerated-iphone.html (0 => 284741)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/media/video-element-fullscreen-not-in-dom-accelerated-iphone.html                              (rev 0)
+++ trunk/LayoutTests/media/video-element-fullscreen-not-in-dom-accelerated-iphone.html 2021-10-23 05:58:14 UTC (rev 284741)
</span><span class="lines">@@ -0,0 +1,34 @@
</span><ins>+<!DOCTYPE html>
+<html>
+<head>
+    <script src="video-test.js"></script>
+    <script src="media-file.js"></script>
+    <script>
+        var video;
+        window.addEventListener('load', async event => {
+            if (!window.internals) {
+                failTest('This test requires window.internals.');
+                return;
+            }
+
+            internals.settings.setAllowsInlineMediaPlayback(false);
+            internals.settings.setAllowsInlineMediaPlaybackAfterFullscreen(true);
+            consoleWrite('');
+
+            video = document.createElement("video");
+            video.src = findMediaFile("video", "content/test");
+
+            video.play();
+
+            // This code can only work on iOS device as webkitEnterFullscreen will error if the video element isn't part of a document.
+            waitForEvent('webkitbeginfullscreen', () => {
+                testExpected('window.internals.mediaPlayerRenderingCanBeAccelerated(video)', true);
+                endTest();
+            }, false, true, video);
+        });
+    </script>
+</head>
+<body>
+    <div>Test that playing a video in fullscreen is accelerated.</div>
+</body>
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestsplatformiosTestExpectations"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/platform/ios/TestExpectations (284740 => 284741)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/ios/TestExpectations  2021-10-23 04:07:11 UTC (rev 284740)
+++ trunk/LayoutTests/platform/ios/TestExpectations     2021-10-23 05:58:14 UTC (rev 284741)
</span><span class="lines">@@ -224,6 +224,8 @@
</span><span class="cx"> # This test uses movie matricies, which AVFoundation and QTKit64 do not support.
</span><span class="cx"> media/video-size-intrinsic-scale.html [ WontFix ]
</span><span class="cx"> 
</span><ins>+media/video-element-fullscreen-not-in-dom-accelerated-iphone.html [ Pass ]
+
</ins><span class="cx"> # MediaSource is not currently supported on iOS.
</span><span class="cx"> media/media-source
</span><span class="cx"> http/tests/media/media-source [ Skip ]
</span></span></pre></div>
<a id="trunkLayoutTestsplatformipadTestExpectations"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/platform/ipad/TestExpectations (284740 => 284741)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/ipad/TestExpectations 2021-10-23 04:07:11 UTC (rev 284740)
+++ trunk/LayoutTests/platform/ipad/TestExpectations    2021-10-23 05:58:14 UTC (rev 284741)
</span><span class="lines">@@ -46,6 +46,9 @@
</span><span class="cx"> media/modern-media-controls/media-documents/media-document-audio-ios-sizing.html [ Skip ]
</span><span class="cx"> media/modern-media-controls/media-documents/media-document-video-iphone-sizing.html [ Skip ]
</span><span class="cx"> 
</span><ins>+# This test is designed for iPhone and would timeout on iPad
+media/video-element-fullscreen-not-in-dom-accelerated-iphone.html [ Skip ]
+
</ins><span class="cx"> # This test is iPad-specific
</span><span class="cx"> media/modern-media-controls/media-documents/media-document-video-ipad-sizing.html [ Pass ]
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (284740 => 284741)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog   2021-10-23 04:07:11 UTC (rev 284740)
+++ trunk/Source/WebCore/ChangeLog      2021-10-23 05:58:14 UTC (rev 284741)
</span><span class="lines">@@ -1,3 +1,31 @@
</span><ins>+2021-10-22  Jean-Yves Avenard  <jya@apple.com>
+
+        video appears blank with only audio playing if video element isn't appended to the dom tree
+        https://bugs.webkit.org/show_bug.cgi?id=232124
+        rdar://83438282
+
+        Reviewed by Eric Carlson.
+
+        If the renderer isn't accelerated, the current playback policity is to
+        not have the video tracks visible on screen.
+        The HTMLMediaElement could only check if the renderer was accelerated if
+        it was part of the DOM.
+        On iPhone, for historical reasons, inline playback isn't allowed but
+        will play fullscreen instead.
+
+        This is a temporary workaround until bug 232125 is comlpeted which would provide
+        a more elegant and universal solution.
+
+        Test: media/video-element-fullscreen-not-in-dom-accelerated-iphone.html
+
+        * html/HTMLMediaElement.cpp:
+        (WebCore::HTMLMediaElement::mediaPlayerRenderingCanBeAccelerated):
+        * html/HTMLMediaElement.h:
+        * testing/Internals.cpp:
+        (WebCore::Internals::mediaPlayerRenderingCanBeAccelerated):
+        * testing/Internals.h:
+        * testing/Internals.idl:
+
</ins><span class="cx"> 2021-10-22  Said Abou-Hallawa  <said@apple.com>
</span><span class="cx"> 
</span><span class="cx">         [GPU Process] REGRESSION: Drawing a large SVG image on a canvas may take too much memory
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLMediaElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLMediaElement.cpp (284740 => 284741)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLMediaElement.cpp   2021-10-23 04:07:11 UTC (rev 284740)
+++ trunk/Source/WebCore/html/HTMLMediaElement.cpp      2021-10-23 05:58:14 UTC (rev 284741)
</span><span class="lines">@@ -5212,12 +5212,14 @@
</span><span class="cx"> 
</span><span class="cx"> bool HTMLMediaElement::mediaPlayerRenderingCanBeAccelerated()
</span><span class="cx"> {
</span><ins>+#if ENABLE(VIDEO_PRESENTATION_MODE)
</ins><span class="cx">     // This function must return "true" when the video is playing in the
</span><del>-    // picture-in-picture window. Otherwise, the MediaPlayerPrivate* may
-    // destroy the video layer.
-    if (m_videoFullscreenMode == VideoFullscreenModePictureInPicture)
</del><ins>+    // picture-in-picture window or if it is in fullscreen.
+    // Otherwise, the MediaPlayerPrivate* may destroy the video layer if
+    // the no longer in the DOM.
+    if (m_videoFullscreenLayer)
</ins><span class="cx">         return true;
</span><del>-
</del><ins>+#endif
</ins><span class="cx">     auto* renderer = this->renderer();
</span><span class="cx">     return is<RenderVideo>(renderer)
</span><span class="cx">         && downcast<RenderVideo>(*renderer).view().compositor().canAccelerateVideoRendering(downcast<RenderVideo>(*renderer));
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLMediaElementh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLMediaElement.h (284740 => 284741)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLMediaElement.h     2021-10-23 04:07:11 UTC (rev 284740)
+++ trunk/Source/WebCore/html/HTMLMediaElement.h        2021-10-23 05:58:14 UTC (rev 284741)
</span><span class="lines">@@ -603,6 +603,8 @@
</span><span class="cx">     using EventTarget::dispatchEvent;
</span><span class="cx">     void dispatchEvent(Event&) override;
</span><span class="cx"> 
</span><ins>+    WEBCORE_EXPORT bool mediaPlayerRenderingCanBeAccelerated() final;
+
</ins><span class="cx"> protected:
</span><span class="cx">     HTMLMediaElement(const QualifiedName&, Document&, bool createdByParser);
</span><span class="cx">     virtual ~HTMLMediaElement();
</span><span class="lines">@@ -688,7 +690,6 @@
</span><span class="cx">     void mediaPlayerResourceNotSupported() final;
</span><span class="cx">     void mediaPlayerRepaint() final;
</span><span class="cx">     void mediaPlayerSizeChanged() final;
</span><del>-    bool mediaPlayerRenderingCanBeAccelerated() final;
</del><span class="cx">     void mediaPlayerRenderingModeChanged() final;
</span><span class="cx">     bool mediaPlayerAcceleratedCompositingEnabled() final;
</span><span class="cx">     void mediaPlayerEngineUpdated() final;
</span></span></pre></div>
<a id="trunkSourceWebCoretestingInternalscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/testing/Internals.cpp (284740 => 284741)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/testing/Internals.cpp       2021-10-23 04:07:11 UTC (rev 284740)
+++ trunk/Source/WebCore/testing/Internals.cpp  2021-10-23 05:58:14 UTC (rev 284741)
</span><span class="lines">@@ -3959,6 +3959,11 @@
</span><span class="cx">         player->endSimulatedHDCPError();
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+ExceptionOr<bool> Internals::mediaPlayerRenderingCanBeAccelerated(HTMLMediaElement& element)
+{
+    return element.mediaPlayerRenderingCanBeAccelerated();
+}
+
</ins><span class="cx"> bool Internals::elementShouldBufferData(HTMLMediaElement& element)
</span><span class="cx"> {
</span><span class="cx">     return element.bufferingPolicy() < MediaPlayer::BufferingPolicy::LimitReadAhead;
</span></span></pre></div>
<a id="trunkSourceWebCoretestingInternalsh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/testing/Internals.h (284740 => 284741)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/testing/Internals.h 2021-10-23 04:07:11 UTC (rev 284740)
+++ trunk/Source/WebCore/testing/Internals.h    2021-10-23 05:58:14 UTC (rev 284741)
</span><span class="lines">@@ -659,6 +659,7 @@
</span><span class="cx">     ExceptionOr<bool> mediaElementHasCharacteristic(HTMLMediaElement&, const String&);
</span><span class="cx">     void beginSimulatedHDCPError(HTMLMediaElement&);
</span><span class="cx">     void endSimulatedHDCPError(HTMLMediaElement&);
</span><ins>+    ExceptionOr<bool> mediaPlayerRenderingCanBeAccelerated(HTMLMediaElement&);
</ins><span class="cx"> 
</span><span class="cx">     bool elementShouldBufferData(HTMLMediaElement&);
</span><span class="cx">     String elementBufferingPolicy(HTMLMediaElement&);
</span></span></pre></div>
<a id="trunkSourceWebCoretestingInternalsidl"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/testing/Internals.idl (284740 => 284741)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/testing/Internals.idl       2021-10-23 04:07:11 UTC (rev 284740)
+++ trunk/Source/WebCore/testing/Internals.idl  2021-10-23 05:58:14 UTC (rev 284741)
</span><span class="lines">@@ -700,6 +700,7 @@
</span><span class="cx">     [Conditional=VIDEO] boolean mediaElementHasCharacteristic(HTMLMediaElement element, DOMString characteristic);
</span><span class="cx">     [Conditional=VIDEO] undefined beginSimulatedHDCPError(HTMLMediaElement media);
</span><span class="cx">     [Conditional=VIDEO] undefined endSimulatedHDCPError(HTMLMediaElement media);
</span><ins>+    [Conditional=VIDEO] boolean mediaPlayerRenderingCanBeAccelerated(HTMLMediaElement media);
</ins><span class="cx"> 
</span><span class="cx">     [Conditional=VIDEO] boolean elementShouldBufferData(HTMLMediaElement media);
</span><span class="cx">     [Conditional=VIDEO] DOMString elementBufferingPolicy(HTMLMediaElement media);
</span></span></pre></div>
<a id="trunkSourceWebKitChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/ChangeLog (284740 => 284741)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/ChangeLog    2021-10-23 04:07:11 UTC (rev 284740)
+++ trunk/Source/WebKit/ChangeLog       2021-10-23 05:58:14 UTC (rev 284741)
</span><span class="lines">@@ -1,3 +1,23 @@
</span><ins>+2021-10-22  Jean-Yves Avenard  <jya@apple.com>
+
+        video appears blank with only audio playing if video element isn't appended to the dom tree
+        https://bugs.webkit.org/show_bug.cgi?id=232124
+        rdar://83438282
+
+        Reviewed by Eric Carlson.
+
+        Ensure that we inform the GPU process whenever
+        MediaPlayer::renderingCanBeAccelerated value could have changed.
+
+        * WebProcess/GPU/media/MediaPlayerPrivateRemote.cpp:
+        (WebKit::MediaPlayerPrivateRemote::load):
+        (WebKit::MediaPlayerPrivateRemote::readyStateChanged):
+        (WebKit::MediaPlayerPrivateRemote::checkAcceleratedRenderingState):
+        (WebKit::MediaPlayerPrivateRemote::updateConfiguration):
+        (WebKit::MediaPlayerPrivateRemote::setVideoFullscreenLayer):
+        (WebKit::MediaPlayerPrivateRemote::setVideoFullscreenGravity):
+        * WebProcess/GPU/media/MediaPlayerPrivateRemote.h:
+
</ins><span class="cx"> 2021-10-22  Chris Fleizach  <cfleizach@apple.com>
</span><span class="cx"> 
</span><span class="cx">         AX: Inform AX when the injected bundle sends a synchronous message
</span></span></pre></div>
<a id="trunkSourceWebKitWebProcessGPUmediaMediaPlayerPrivateRemotecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.cpp (284740 => 284741)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.cpp    2021-10-23 04:07:11 UTC (rev 284740)
+++ trunk/Source/WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.cpp       2021-10-23 05:58:14 UTC (rev 284741)
</span><span class="lines">@@ -209,7 +209,7 @@
</span><span class="cx">         if (!player)
</span><span class="cx">             return;
</span><span class="cx"> 
</span><del>-        m_configuration = WTFMove(configuration);
</del><ins>+        updateConfiguration(WTFMove(configuration));
</ins><span class="cx">         player->mediaEngineUpdated();
</span><span class="cx">     }, m_id);
</span><span class="cx"> }
</span><span class="lines">@@ -354,9 +354,7 @@
</span><span class="cx">     updateCachedState(WTFMove(state));
</span><span class="cx">     if (RefPtr player = m_player.get()) {
</span><span class="cx">         player->readyStateChanged();
</span><del>-        bool renderingCanBeAccelerated = player->renderingCanBeAccelerated();
-        if (m_renderingCanBeAccelerated != renderingCanBeAccelerated)
-            acceleratedRenderingStateChanged();
</del><ins>+        checkAcceleratedRenderingState();
</ins><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -474,12 +472,28 @@
</span><span class="cx"> 
</span><span class="cx"> void MediaPlayerPrivateRemote::acceleratedRenderingStateChanged()
</span><span class="cx"> {
</span><del>-    if (RefPtr player = m_player.get()) {
-        m_renderingCanBeAccelerated = player->renderingCanBeAccelerated();
</del><ins>+    if (m_player) {
+        m_renderingCanBeAccelerated = m_player->renderingCanBeAccelerated();
</ins><span class="cx">         connection().send(Messages::RemoteMediaPlayerProxy::AcceleratedRenderingStateChanged(m_renderingCanBeAccelerated), m_id);
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void MediaPlayerPrivateRemote::checkAcceleratedRenderingState()
+{
+    if (m_player) {
+        bool renderingCanBeAccelerated = m_player->renderingCanBeAccelerated();
+        if (m_renderingCanBeAccelerated != renderingCanBeAccelerated)
+            acceleratedRenderingStateChanged();
+    }
+}
+
+void MediaPlayerPrivateRemote::updateConfiguration(RemoteMediaPlayerConfiguration&& configuration)
+{
+    m_configuration = WTFMove(configuration);
+    // player->renderingCanBeAccelerated() result is dependent on m_configuration.supportsAcceleratedRendering value.
+    checkAcceleratedRenderingState();
+}
+
</ins><span class="cx"> #if ENABLE(WIRELESS_PLAYBACK_TARGET)
</span><span class="cx"> bool MediaPlayerPrivateRemote::canPlayToWirelessPlaybackTarget() const
</span><span class="cx"> {
</span><span class="lines">@@ -768,7 +782,7 @@
</span><span class="cx">             if (!player)
</span><span class="cx">                 return;
</span><span class="cx"> 
</span><del>-            m_configuration = WTFMove(configuration);
</del><ins>+            updateConfiguration(WTFMove(configuration));
</ins><span class="cx">             player->mediaEngineUpdated();
</span><span class="cx">         }, m_id);
</span><span class="cx">         m_mediaSourcePrivate = MediaSourcePrivateRemote::create(m_manager.gpuProcessConnection(), identifier, m_manager.typeCache(m_remoteEngineIdentifier), *this, client);
</span><span class="lines">@@ -823,6 +837,8 @@
</span><span class="cx"> #if PLATFORM(COCOA)
</span><span class="cx">     m_videoLayerManager->setVideoFullscreenLayer(videoFullscreenLayer, WTFMove(completionHandler), nullptr);
</span><span class="cx"> #endif
</span><ins>+    // A Fullscreen layer has been set, this could update the value returned by player->renderingCanBeAccelerated().
+    checkAcceleratedRenderingState();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void MediaPlayerPrivateRemote::updateVideoFullscreenInlineImage()
</span></span></pre></div>
<a id="trunkSourceWebKitWebProcessGPUmediaMediaPlayerPrivateRemoteh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.h (284740 => 284741)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.h      2021-10-23 04:07:11 UTC (rev 284740)
+++ trunk/Source/WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.h 2021-10-23 05:58:14 UTC (rev 284741)
</span><span class="lines">@@ -314,6 +314,7 @@
</span><span class="cx"> 
</span><span class="cx">     bool supportsAcceleratedRendering() const final;
</span><span class="cx">     void acceleratedRenderingStateChanged() final;
</span><ins>+    void checkAcceleratedRenderingState();
</ins><span class="cx"> 
</span><span class="cx">     void setShouldMaintainAspectRatio(bool) final;
</span><span class="cx"> 
</span><span class="lines">@@ -397,8 +398,8 @@
</span><span class="cx">     bool supportsPauseAtHostTime() const final { return m_configuration.supportsPauseAtHostTime; }
</span><span class="cx">     bool playAtHostTime(const MonotonicTime&) final;
</span><span class="cx">     bool pauseAtHostTime(const MonotonicTime&) final;
</span><ins>+    void updateConfiguration(RemoteMediaPlayerConfiguration&&);
</ins><span class="cx"> 
</span><del>-
</del><span class="cx">     WeakPtr<WebCore::MediaPlayer> m_player;
</span><span class="cx">     Ref<WebCore::PlatformMediaResourceLoader> m_mediaResourceLoader;
</span><span class="cx"> #if PLATFORM(COCOA)
</span></span></pre>
</div>
</div>

</body>
</html>