<?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>228860</bug_id>
          
          <creation_ts>2021-08-06 03:36:27 -0700</creation_ts>
          <short_desc>Safari automatically reloads page when takes photos in max resolution on iPhone 7, iPhone 7 Plus.</short_desc>
          <delta_ts>2021-08-13 09:20:03 -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>Safari 14</version>
          <rep_platform>iPhone / iPad</rep_platform>
          <op_sys>iOS 14</op_sys>
          <bug_status>NEW</bug_status>
          <resolution></resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Minor</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Andrew">andrew.zaitsev.crtr</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>webkit-bug-importer</cc>
    
    <cc>youennf</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1782464</commentid>
    <comment_count>0</comment_count>
    <who name="Andrew">andrew.zaitsev.crtr</who>
    <bug_when>2021-08-06 03:36:27 -0700</bug_when>
    <thetext>There is a Web RTC video stream with max resolution and video tag which shows the stream from the camera.

async function setStream() {
  const stream = await window.navigator.mediaDevices.getUserMedia({
        video: {
          facingMode: &apos;user&apos;,
          width: {
            min: 960,
            ideal: resolution.width,
          },
          height: {
            min: 720,
            ideal: resolution.height,
          },
          frameRate: {
            min: 30,
          },
          aspectRatio: {
            ideal: RESOLUTION_ASPECT_RATIO,
          },
        },
        audio: false,
      });

  videoNode.srcObject = stream;
}

It&apos;s possible to take photos by clicking on the button, this code will be run:

function takePhoto() {
    const canvasNode = document.createElement(&apos;canvas&apos;);
    canvasNode.width = videoWidth;
    canvasNode.height = videoHeight;

    const context = canvasNode.getContext(&apos;2d&apos;)!;

    context.drawImage(videoNode, 0, 0, videoWidth, videoHeight);

    const photo = canvasNode.toDataURL(&apos;image/jpeg&apos;, 1.0);
}

After that, will close all tracks:

stream.getTracks().forEach((track) =&gt; track.stop());

Next will show the taken image. 

There are three the same steps, step by step in my flow.

Issue: 
Sometimes Safari will reload the page. How I can resolve this issue?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1782467</commentid>
    <comment_count>1</comment_count>
    <who name="youenn fablet">youennf</who>
    <bug_when>2021-08-06 04:17:53 -0700</bug_when>
    <thetext>This might be a similar issue as https://bugs.webkit.org/show_bug.cgi?id=228816.
Can you provide a jsfiddle that shows the issue so that I validate it is the same issue as bug 228816?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1784069</commentid>
    <comment_count>2</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2021-08-13 03:37:15 -0700</bug_when>
    <thetext>&lt;rdar://problem/81892761&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1784083</commentid>
    <comment_count>3</comment_count>
    <who name="Andrew">andrew.zaitsev.crtr</who>
    <bug_when>2021-08-13 05:07:05 -0700</bug_when>
    <thetext>There is an example:

https://codesandbox.io/s/epic-volhard-qi9ho?file=/src/App.js</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1784084</commentid>
    <comment_count>4</comment_count>
    <who name="Andrew">andrew.zaitsev.crtr</who>
    <bug_when>2021-08-13 05:07:50 -0700</bug_when>
    <thetext>(In reply to youenn fablet from comment #1)
&gt; This might be a similar issue as
&gt; https://bugs.webkit.org/show_bug.cgi?id=228816.
&gt; Can you provide a jsfiddle that shows the issue so that I validate it is the
&gt; same issue as bug 228816?

There is an example:

https://codesandbox.io/s/epic-volhard-qi9ho?file=/src/App.js</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1784091</commentid>
    <comment_count>5</comment_count>
    <who name="Andrew">andrew.zaitsev.crtr</who>
    <bug_when>2021-08-13 06:08:19 -0700</bug_when>
    <thetext>(In reply to youenn fablet from comment #1)
&gt; This might be a similar issue as
&gt; https://bugs.webkit.org/show_bug.cgi?id=228816.
&gt; Can you provide a jsfiddle that shows the issue so that I validate it is the
&gt; same issue as bug 228816?

There is example without react:
https://codesandbox.io/s/elated-franklin-kkjkk?file=/src/index.js</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1784094</commentid>
    <comment_count>6</comment_count>
    <who name="youenn fablet">youennf</who>
    <bug_when>2021-08-13 06:56:26 -0700</bug_when>
    <thetext>This does not seem to be the same issue as https://bugs.webkit.org/show_bug.cgi?id=228816.
Given the page reload, it seems like the web process is jetsamed so maybe the page is taking too much memory.
You can send me (youenn@apple.com) a sysdiagnose so that I validate this.

Is https://jsfiddle.net/njv0sftz/ also reloading on your devices?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1784108</commentid>
    <comment_count>7</comment_count>
    <who name="Andrew">andrew.zaitsev.crtr</who>
    <bug_when>2021-08-13 07:58:46 -0700</bug_when>
    <thetext>(In reply to youenn fablet from comment #6)
&gt; This does not seem to be the same issue as
&gt; https://bugs.webkit.org/show_bug.cgi?id=228816.
&gt; Given the page reload, it seems like the web process is jetsamed so maybe
&gt; the page is taking too much memory.
&gt; You can send me (youenn@apple.com) a sysdiagnose so that I validate this.
&gt; 
&gt; Is https://jsfiddle.net/njv0sftz/ also reloading on your devices?

Ok. I&apos;m going to send you sysdiagnose.

Your example has a lower quality for the camera, and it works. But, for my application, I should use the maximum quality of the camera. Maybe do you have a word of advice for me?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1784118</commentid>
    <comment_count>8</comment_count>
    <who name="youenn fablet">youennf</who>
    <bug_when>2021-08-13 09:20:03 -0700</bug_when>
    <thetext>(In reply to Andrew from comment #7)
&gt; (In reply to youenn fablet from comment #6)
&gt; &gt; This does not seem to be the same issue as
&gt; &gt; https://bugs.webkit.org/show_bug.cgi?id=228816.
&gt; &gt; Given the page reload, it seems like the web process is jetsamed so maybe
&gt; &gt; the page is taking too much memory.
&gt; &gt; You can send me (youenn@apple.com) a sysdiagnose so that I validate this.
&gt; &gt; 
&gt; &gt; Is https://jsfiddle.net/njv0sftz/ also reloading on your devices?
&gt; 
&gt; Ok. I&apos;m going to send you sysdiagnose.
&gt; 
&gt; Your example has a lower quality for the camera, and it works. But, for my
&gt; application, I should use the maximum quality of the camera. Maybe do you
&gt; have a word of advice for me?

https://jsfiddle.net/qm84rgd6/1/ should get the highest size.
Would it work in your devices?

I&apos;ll check the sysdiagnose to validate if the process gets jetsamed or something else is going on.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>