<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>176439</bug_id>
          
          <creation_ts>2017-09-05 21:15:40 -0700</creation_ts>
          <short_desc>Safari on iOS11 Freezes when viewing a cropped remote video</short_desc>
          <delta_ts>2018-05-23 20:10:10 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>WebRTC</component>
          <version>Other</version>
          <rep_platform>iPhone / iPad</rep_platform>
          <op_sys>iOS 11</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Critical</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Adam">adam</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>andj2223</cc>
    
    <cc>ben.browitt</cc>
    
    <cc>gabor</cc>
    
    <cc>info</cc>
    
    <cc>mikeblock</cc>
    
    <cc>philipp.weissensteiner</cc>
    
    <cc>shamun</cc>
    
    <cc>szmydadam</cc>
    
    <cc>webkit-bug-importer</cc>
    
    <cc>youennf</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1345797</commentid>
    <comment_count>0</comment_count>
    <who name="Adam">adam</who>
    <bug_when>2017-09-05 21:15:40 -0700</bug_when>
    <thetext>Steps to reproduce:

1. Visit https://output.jsbin.com/pihucav in Chrome on a Mac and allow access to your camera
2. Visit https://output.jsbin.com/pihucav in Safari on iOS and allow access to your camera

Result: After a few seconds (the timing seems to change) your whole iPhone/iPad will freeze. You have to force restart it.

A few other observations:

1. This does not happen with this sample app: https://jsbin.com/mizarag which is identical except that it is using the fitMode &apos;contain&apos; on the Video Element. It also doesn&apos;t happen if the Video is sized to the right aspect ratio. It seems to have something to do with cropping the video.
2. It doesn&apos;t happen if the other party is using Safari, either on iOS or Mac. It does happen if the other party is Chrome or Firefox though.
3. This does not happen if the iPhone or iPad is in Landscape mode. It only seems to happen in Portrait.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1345802</commentid>
    <comment_count>1</comment_count>
    <who name="Adam">adam</who>
    <bug_when>2017-09-05 21:33:42 -0700</bug_when>
    <thetext>It also happens if the video is too wide to fit inside the browser window.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1345954</commentid>
    <comment_count>2</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2017-09-06 09:25:26 -0700</bug_when>
    <thetext>&lt;rdar://problem/34281364&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1345956</commentid>
    <comment_count>3</comment_count>
    <who name="youenn fablet">youennf</who>
    <bug_when>2017-09-06 09:31:31 -0700</bug_when>
    <thetext>https://output.jsbin.com/pihucav does not work for me now, I&apos;ll retry later on.
Is it Safari that is freezing or the whole OS?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1346176</commentid>
    <comment_count>4</comment_count>
    <who name="Adam">adam</who>
    <bug_when>2017-09-06 17:38:10 -0700</bug_when>
    <thetext>(In reply to youenn fablet from comment #3)
&gt; https://output.jsbin.com/pihucav does not work for me now, I&apos;ll retry later
&gt; on.
&gt; Is it Safari that is freezing or the whole OS?

pihucav is working for me, I just checked again. This also happens with meet.tokbox.com.

The whole OS is freezing, not just Safari.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1346728</commentid>
    <comment_count>5</comment_count>
    <who name="Adam">adam</who>
    <bug_when>2017-09-07 23:16:06 -0700</bug_when>
    <thetext>Here is a stripped down WebRTC example (without using opentok.js) that reproduces the problem https://output.jsbin.com/vopimuw

1. Open the URL using Google Chrome on a Mac
2. Open it in Safari on iOS

Result: iOS freezes up completely.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1346731</commentid>
    <comment_count>6</comment_count>
    <who name="Adam">adam</who>
    <bug_when>2017-09-07 23:23:35 -0700</bug_when>
    <thetext>Actually, I want to modify the steps a little bit.

1. Visit https://output.jsbin.com/vopimuw in Google Chrome on a Mac and allow access to the camera/mic.
2. Visit https://output.jsbin.com/vopimuw in Safari on iOS. 
3. Wait for the remote stream to load before you allow access to camera/mic.
4. Once the remote stream has loaded click &quot;Allow&quot;.
5. Scroll down to view your own stream.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1346732</commentid>
    <comment_count>7</comment_count>
    <who name="Adam">adam</who>
    <bug_when>2017-09-07 23:28:03 -0700</bug_when>
    <thetext>Similarly if I set object-fit:contain on the video element I don&apos;t get the freeze. 

https://jsbin.com/nogaxe/edit?html,css,js,output</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1351148</commentid>
    <comment_count>8</comment_count>
    <who name="">andj2223</who>
    <bug_when>2017-09-21 00:29:56 -0700</bug_when>
    <thetext>Also see https://bugs.webkit.org/show_bug.cgi?id=175014
Aka rdar://problem/33781374

This is possibly a dupe of that, but I&apos;m not sure. That freeze has been known and reproducible for 3-4 betas before the final iOS 11 release, but still wasn&apos;t addressed in time for the final release.

Cross your fingers that it gets fixed soon, I guess.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1357921</commentid>
    <comment_count>9</comment_count>
    <who name="Ben">ben.browitt</who>
    <bug_when>2017-10-07 06:54:05 -0700</bug_when>
    <thetext>We get whole OS freeze in iPhone running iOS 11.02. Need hard reboot.
object-fit:contain doesn&apos;t help.
Adam, can  you suggest any other workaround?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1357922</commentid>
    <comment_count>10</comment_count>
    <who name="youenn fablet">youennf</who>
    <bug_when>2017-10-07 07:35:01 -0700</bug_when>
    <thetext>Ben, can you provide a test web site.
It might also be related to https://bugs.webkit.org/show_bug.cgi?id=175014</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1361767</commentid>
    <comment_count>11</comment_count>
    <who name="Mike Block">mikeblock</who>
    <bug_when>2017-10-18 10:33:36 -0700</bug_when>
    <thetext>I had opened another bug with the same issue:

https://bugs.webkit.org/show_bug.cgi?id=178357

If I ensure that I contain the full video in the outer container, then it seems to prevent freezing of the OS.

Latest test on 11.0.3 - no resolution yet.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1361770</commentid>
    <comment_count>12</comment_count>
    <who name="Mike Block">mikeblock</who>
    <bug_when>2017-10-18 10:39:10 -0700</bug_when>
    <thetext>Note that the local stream continues to feed to the remote peers after the screen locks up. Audio also seems to continue flowing both directions (need more testing on this). If I wait a few minutes, sometimes the device releases and starts working again, but the page needs a reload to restart.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1361889</commentid>
    <comment_count>13</comment_count>
    <who name="Ben">ben.browitt</who>
    <bug_when>2017-10-18 14:34:00 -0700</bug_when>
    <thetext>Mike, can you please explain what do you mean by this?
| contain the full video in the outer container</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1361896</commentid>
    <comment_count>14</comment_count>
    <who name="Mike Block">mikeblock</who>
    <bug_when>2017-10-18 14:38:35 -0700</bug_when>
    <thetext>It seems that the problem is managed by ensuring that none of the video is cropped within the container it resides in. For example, if I set a DIV with a 4:3 aspect ratio on the page and place a VIDEO tag inside this div, so long as the complete boundaries of the video tag do not overflow the containing DIV, it seems to be okay.

Where it reliably freezes is when I allow the video tag to be 100% of the width of the video and auto height, and use overflow: hidden in CSS to hide the parts of the video that are extending top and bottom outside the container.

Does that make sense?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1361916</commentid>
    <comment_count>15</comment_count>
    <who name="Ben">ben.browitt</who>
    <bug_when>2017-10-18 15:20:10 -0700</bug_when>
    <thetext>Thanks. I think I understand but not sure how to handle it in a real app where you can&apos;t always control the aspect ratio of the other peer.
I&apos;ve tried to remove overflow:hidden, width:100% and height:100% from several containers but it doesn&apos;t help.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1361932</commentid>
    <comment_count>16</comment_count>
    <who name="Mike Block">mikeblock</who>
    <bug_when>2017-10-18 15:35:50 -0700</bug_when>
    <thetext>@Ben the video should letterbox itself if you constrain the video tag. Try a setup like this for your test:

&lt;style&gt;
/*
fixed size for each video wrapper
*/
.video-wrap {
     width: 320px;
     height: 240px;
     position: relative;
}
/*
video ELEMENT expands to the dimensions of the wrapper
actual video will be left right letter boxed and smaller if portrait
it will fill if landscape and 4:3 source
if 16:9 source, it will be top-bottom letter boxed
*/
.video-wrap &gt; video {
     position: absolute;
     top: 0; left: 0;
     width: 100%;
     max-width: 100%;
     height: 100%;
     max-height: 100%;
}
&lt;/style&gt;
&lt;!-- add as many of these as you need and attach streams as needed --&gt;
&lt;div class=&quot;video-wrap&quot;&gt;
     &lt;video muted autoplay playsinline&gt;
&lt;/div&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1361944</commentid>
    <comment_count>17</comment_count>
    <who name="Ben">ben.browitt</who>
    <bug_when>2017-10-18 16:06:45 -0700</bug_when>
    <thetext>I gave video-wrap size 320x240 and even 160x120. I see the video element in a letterbox. The iPhone still freezes when I rotate it from portrait to landscape several times.
I might still have some problematic style or there is an additional issue.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1361948</commentid>
    <comment_count>18</comment_count>
    <who name="Mike Block">mikeblock</who>
    <bug_when>2017-10-18 16:19:24 -0700</bug_when>
    <thetext>The issue may then be with re-rendering when switching camera orientations. Not sure what to suggest.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1361949</commentid>
    <comment_count>19</comment_count>
    <who name="youenn fablet">youennf</who>
    <bug_when>2017-10-18 16:21:57 -0700</bug_when>
    <thetext>The issue might be more related to the actual video stream.
Rendering tricks might allow to reduce the risk of hitting this issue but will not probably work 100% of the time.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1361953</commentid>
    <comment_count>20</comment_count>
    <who name="Ben">ben.browitt</who>
    <bug_when>2017-10-18 16:32:43 -0700</bug_when>
    <thetext>Is there something that can be changed in the getUserMedia constraints of the other peer or the SDP to workaround it?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1363049</commentid>
    <comment_count>21</comment_count>
    <who name="Alexey Proskuryakov">ap</who>
    <bug_when>2017-10-21 12:39:15 -0700</bug_when>
    <thetext>*** Bug 178357 has been marked as a duplicate of this bug. ***</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1365092</commentid>
    <comment_count>22</comment_count>
    <who name="">andj2223</who>
    <bug_when>2017-10-26 16:28:54 -0700</bug_when>
    <thetext>This is most likely a dupe of https://bugs.webkit.org/show_bug.cgi?id=175014</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1367115</commentid>
    <comment_count>23</comment_count>
    <who name="youenn fablet">youennf</who>
    <bug_when>2017-11-01 16:47:40 -0700</bug_when>
    <thetext>Latest iOS 11.2 beta might solve the issue.
Let me known if this is still not working, otherwise I will close this bug in a few weeks.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1367117</commentid>
    <comment_count>24</comment_count>
    <who name="Adam">adam</who>
    <bug_when>2017-11-01 16:48:52 -0700</bug_when>
    <thetext>Just tested with iOS 11.2 beta and the issue is resolved for me. Thank you so much!</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1383802</commentid>
    <comment_count>25</comment_count>
    <who name="iamtesting">shamun</who>
    <bug_when>2017-12-20 13:17:27 -0800</bug_when>
    <thetext>iOS 11.2.5: Safari: Following does not work yet.

&lt;video id=&quot;localVideo&quot;  oncontextmenu=&quot;return false;&quot;&gt;&lt;/video&gt;
&lt;video id=&quot;miniVideo&quot;  oncontextmenu=&quot;return false;&quot; autoplay=&quot;autoplay&quot; muted=&quot;true&quot;&gt;&lt;/video&gt;

&lt;script&gt;
var mainVideoSeflView = document.getElementById(&apos;localVideo&apos;);//works
var pictureInPicture = document.getElementById(&apos;miniVideo&apos;);

// =============== Fail fail fail fail????? 
// (iOS iPad works, OSX Safari works, Google chrome works, Firefox works, Opera works


but not in iPhone???)

// =============== Fail fail fail fail????? 
pictureInPicture.srcObject = mainVideoSeflView.srcObject;
// FAIL FAIL FIAL

&lt;/script&gt;</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>