<!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>[204492] 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/204492">204492</a></dd>
<dt>Author</dt> <dd>dbates@webkit.org</dd>
<dt>Date</dt> <dd>2016-08-15 19:06:45 -0700 (Mon, 15 Aug 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>ASSERTION FAILURE: [[videoLayer delegate] isKindOfClass:getUIViewClass()] in WebAVPlayerLayerView_videoView()
https://bugs.webkit.org/show_bug.cgi?id=160433

Reviewed by Eric Carlson.

Source/WebCore:

Early return from WebAVPlayerLayerView_videoView() if the PiP layer does not have a non-nil delegate view.

Test: media/controls/close-page-with-picture-in-picture-video-assertion-failure.html

* platform/ios/WebVideoFullscreenInterfaceAVKit.mm:
(WebAVPlayerLayerView_videoView):

LayoutTests:

Add a layout test to ensure that we do not cause an assertion failure when exiting PiP by closing the tab.

* TestExpectations: Skip media/control/ipad tests on all ports. We will re-enable these tests for iOS.
* media/controls/close-page-with-picture-in-picture-video-assertion-failure-expected.txt: Added.
* media/controls/close-page-with-picture-in-picture-video-assertion-failure.html: Added.
* media/controls/resources/picture-in-picture.html: Added.
* platform/ios-simulator/TestExpectations: Mark tests media/control/ipad  as Pass so that we run them
in the iPad simulator.</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="#trunkLayoutTestsplatformiossimulatorTestExpectations">trunk/LayoutTests/platform/ios-simulator/TestExpectations</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreplatformiosWebVideoFullscreenInterfaceAVKitmm">trunk/Source/WebCore/platform/ios/WebVideoFullscreenInterfaceAVKit.mm</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li>trunk/LayoutTests/media/controls/ipad/</li>
<li><a href="#trunkLayoutTestsmediacontrolsipadclosepagewithpictureinpicturevideoassertionfailureexpectedtxt">trunk/LayoutTests/media/controls/ipad/close-page-with-picture-in-picture-video-assertion-failure-expected.txt</a></li>
<li><a href="#trunkLayoutTestsmediacontrolsipadclosepagewithpictureinpicturevideoassertionfailurehtml">trunk/LayoutTests/media/controls/ipad/close-page-with-picture-in-picture-video-assertion-failure.html</a></li>
<li>trunk/LayoutTests/media/controls/ipad/resources/</li>
<li><a href="#trunkLayoutTestsmediacontrolsipadresourcespictureinpicturehtml">trunk/LayoutTests/media/controls/ipad/resources/picture-in-picture.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (204491 => 204492)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2016-08-16 01:43:31 UTC (rev 204491)
+++ trunk/LayoutTests/ChangeLog        2016-08-16 02:06:45 UTC (rev 204492)
</span><span class="lines">@@ -1,3 +1,19 @@
</span><ins>+2016-08-15  Daniel Bates  &lt;dabates@apple.com&gt;
+
+        ASSERTION FAILURE: [[videoLayer delegate] isKindOfClass:getUIViewClass()] in WebAVPlayerLayerView_videoView()
+        https://bugs.webkit.org/show_bug.cgi?id=160433
+
+        Reviewed by Eric Carlson.
+
+        Add a layout test to ensure that we do not cause an assertion failure when exiting PiP by closing the tab.
+
+        * TestExpectations: Skip media/control/ipad tests on all ports. We will re-enable these tests for iOS.
+        * media/controls/close-page-with-picture-in-picture-video-assertion-failure-expected.txt: Added.
+        * media/controls/close-page-with-picture-in-picture-video-assertion-failure.html: Added.
+        * media/controls/resources/picture-in-picture.html: Added.
+        * platform/ios-simulator/TestExpectations: Mark tests media/control/ipad  as Pass so that we run them
+        in the iPad simulator.
+
</ins><span class="cx"> 2016-08-15  Jiewen Tan  &lt;jiewen_tan@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Expose crypto.getRandomValues to Web Workers
</span></span></pre></div>
<a id="trunkLayoutTestsTestExpectations"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/TestExpectations (204491 => 204492)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/TestExpectations        2016-08-16 01:43:31 UTC (rev 204491)
+++ trunk/LayoutTests/TestExpectations        2016-08-16 02:06:45 UTC (rev 204492)
</span><span class="lines">@@ -24,6 +24,7 @@
</span><span class="cx"> fast/scrolling/ios [ Skip ]
</span><span class="cx"> fast/content-observation [ Skip ]
</span><span class="cx"> media/mac [ Skip ]
</span><ins>+media/controls/ipad [ Skip ]
</ins><span class="cx"> 
</span><span class="cx"> fast/forms/attributed-strings.html [ Skip ]
</span><span class="cx"> fast/scrolling/latching [ Skip ]
</span></span></pre></div>
<a id="trunkLayoutTestsmediacontrolsipadclosepagewithpictureinpicturevideoassertionfailureexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/media/controls/ipad/close-page-with-picture-in-picture-video-assertion-failure-expected.txt (0 => 204492)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/media/controls/ipad/close-page-with-picture-in-picture-video-assertion-failure-expected.txt                                (rev 0)
+++ trunk/LayoutTests/media/controls/ipad/close-page-with-picture-in-picture-video-assertion-failure-expected.txt        2016-08-16 02:06:45 UTC (rev 204492)
</span><span class="lines">@@ -0,0 +1,10 @@
</span><ins>+This tests that closing a window that is presenting a video in picture-in-picture does not cause an assertion failure in a debug build. To run this test by hand, click the Open new window button then click the picture-in-picture button (tap the video on iOS).
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+PASS did not cause an assertion failure.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestsmediacontrolsipadclosepagewithpictureinpicturevideoassertionfailurehtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/media/controls/ipad/close-page-with-picture-in-picture-video-assertion-failure.html (0 => 204492)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/media/controls/ipad/close-page-with-picture-in-picture-video-assertion-failure.html                                (rev 0)
+++ trunk/LayoutTests/media/controls/ipad/close-page-with-picture-in-picture-video-assertion-failure.html        2016-08-16 02:06:45 UTC (rev 204492)
</span><span class="lines">@@ -0,0 +1,54 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;script src=&quot;../../../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+&lt;script&gt;
+window.jsTestIsAsync = true;
+
+var child;
+
+if (window.testRunner) {
+    testRunner.setCanOpenWindows(true);
+    testRunner.setCloseRemainingWindowsWhenComplete(true);
+}
+
+// Called by resources/picture-in-picture.html
+function notifyDidChangePresentationMode()
+{
+    // For some reason waiting ~200ms to allow the video to transition from the page to its
+    // picture-in-picture window seems to make triggering the assertion more reliable (why?).
+    function closeWindowAndDone()
+    {
+        child.close(); // Trigger assertion failure
+        testPassed(&quot;did not cause an assertion failure.&quot;);
+        // For some reason waiting ~500ms after closing the window seems to make triggering the assertion more reliable (why?).
+        window.setTimeout(finishJSTest, 500);
+    }
+    window.setTimeout(closeWindowAndDone, 200);
+}
+
+function openNewWindow()
+{
+    child = window.open(&quot;resources/picture-in-picture.html&quot;);
+    document.body.removeChild(openNewWindowButton);
+}
+
+window.onload = function () {
+    var openNewWindowButton = document.getElementById(&quot;openNewWindowButton&quot;);
+    if (window.testRunner)
+        openNewWindow();
+    else
+        openNewWindowButton.onclick = openNewWindow;
+}
+&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;p id=&quot;description&quot;&gt;&lt;/p&gt;
+&lt;div id=&quot;console&quot;&gt;&lt;/div&gt;
+&lt;script&gt;
+description(&quot;This tests that closing a window that is presenting a video in picture-in-picture does not cause an assertion failure in a debug build. To run this test by hand, click the Open new window button then click the picture-in-picture button (tap the video on iOS).&quot;);
+&lt;/script&gt;
+&lt;button id=&quot;openNewWindowButton&quot;&gt;Open new window&lt;/button&gt;
+&lt;script src=&quot;../../../resources/js-test-post.js&quot;&gt;&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsmediacontrolsipadresourcespictureinpicturehtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/media/controls/ipad/resources/picture-in-picture.html (0 => 204492)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/media/controls/ipad/resources/picture-in-picture.html                                (rev 0)
+++ trunk/LayoutTests/media/controls/ipad/resources/picture-in-picture.html        2016-08-16 02:06:45 UTC (rev 204492)
</span><span class="lines">@@ -0,0 +1,25 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;script src=&quot;../../../media-file.js&quot;&gt;&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;video controls&gt;&lt;/video&gt;
+&lt;script&gt;
+if (window.internals)
+    internals.settings.setAllowsPictureInPictureMediaPlayback(true);
+
+function dispatchDidChangePresentationMode()
+{
+    window.opener.notifyDidChangePresentationMode();
+}
+
+var video = document.querySelector(&quot;video&quot;);
+if (window.internals)
+    internals.setMediaElementRestrictions(video, &quot;NoRestrictions&quot;);
+video.addEventListener(&quot;webkitpresentationmodechanged&quot;, dispatchDidChangePresentationMode, false);
+video.addEventListener(&quot;canplaythrough&quot;, function () { video.webkitSetPresentationMode(&quot;picture-in-picture&quot;); }, false);
+video.src = findMediaFile(&quot;video&quot;, &quot;../../../content/test&quot;);
+&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsplatformiossimulatorTestExpectations"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/platform/ios-simulator/TestExpectations (204491 => 204492)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/ios-simulator/TestExpectations        2016-08-16 01:43:31 UTC (rev 204491)
+++ trunk/LayoutTests/platform/ios-simulator/TestExpectations        2016-08-16 02:06:45 UTC (rev 204492)
</span><span class="lines">@@ -10,6 +10,7 @@
</span><span class="cx"> displaylists [ Pass ]
</span><span class="cx"> quicklook [ Pass ]
</span><span class="cx"> http/tests/quicklook [ Pass ]
</span><ins>+media/controls/ipad [ Pass ]
</ins><span class="cx"> 
</span><span class="cx"> fast/text-autosizing/ios [ Pass ]
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (204491 => 204492)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-08-16 01:43:31 UTC (rev 204491)
+++ trunk/Source/WebCore/ChangeLog        2016-08-16 02:06:45 UTC (rev 204492)
</span><span class="lines">@@ -1,3 +1,17 @@
</span><ins>+2016-08-15  Daniel Bates  &lt;dabates@apple.com&gt;
+
+        ASSERTION FAILURE: [[videoLayer delegate] isKindOfClass:getUIViewClass()] in WebAVPlayerLayerView_videoView()
+        https://bugs.webkit.org/show_bug.cgi?id=160433
+
+        Reviewed by Eric Carlson.
+
+        Early return from WebAVPlayerLayerView_videoView() if the PiP layer does not have a non-nil delegate view.
+
+        Test: media/controls/close-page-with-picture-in-picture-video-assertion-failure.html
+
+        * platform/ios/WebVideoFullscreenInterfaceAVKit.mm:
+        (WebAVPlayerLayerView_videoView):
+
</ins><span class="cx"> 2016-08-15  Alex Christensen  &lt;achristensen@webkit.org&gt;
</span><span class="cx"> 
</span><span class="cx">         Rename SocketStreamHandleBase to SocketStreamHandle and SocketStreamHandle to SocketStreamHandleImpl
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformiosWebVideoFullscreenInterfaceAVKitmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/ios/WebVideoFullscreenInterfaceAVKit.mm (204491 => 204492)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/ios/WebVideoFullscreenInterfaceAVKit.mm        2016-08-16 01:43:31 UTC (rev 204491)
+++ trunk/Source/WebCore/platform/ios/WebVideoFullscreenInterfaceAVKit.mm        2016-08-16 02:06:45 UTC (rev 204492)
</span><span class="lines">@@ -397,7 +397,7 @@
</span><span class="cx">     __AVPlayerLayerView *playerLayer = aSelf;
</span><span class="cx">     WebAVPlayerLayer *webAVPlayerLayer = (WebAVPlayerLayer *)[playerLayer playerLayer];
</span><span class="cx">     CALayer* videoLayer = [webAVPlayerLayer videoSublayer];
</span><del>-    if (!videoLayer)
</del><ins>+    if (!videoLayer || !videoLayer.delegate)
</ins><span class="cx">         return nil;
</span><span class="cx">     ASSERT([[videoLayer delegate] isKindOfClass:getUIViewClass()]);
</span><span class="cx">     return (UIView *)[videoLayer delegate];
</span><span class="lines">@@ -430,7 +430,8 @@
</span><span class="cx"> static void WebAVPlayerLayerView_stopRoutingVideoToPictureInPicturePlayerLayerView(id aSelf, SEL)
</span><span class="cx"> {
</span><span class="cx">     WebAVPlayerLayerView *playerLayerView = aSelf;
</span><del>-    [playerLayerView addSubview:playerLayerView.videoView];
</del><ins>+    if (UIView *videoView = playerLayerView.videoView)
+        [playerLayerView addSubview:videoView];
</ins><span class="cx">     WebAVPictureInPicturePlayerLayerView *pipView = (WebAVPictureInPicturePlayerLayerView *)[playerLayerView pictureInPicturePlayerLayerView];
</span><span class="cx">     WebAVPlayerLayer *playerLayer = (WebAVPlayerLayer *)[playerLayerView playerLayer];
</span><span class="cx">     WebAVPlayerLayer *pipPlayerLayer = (WebAVPlayerLayer *)[pipView layer];
</span></span></pre>
</div>
</div>

</body>
</html>