<?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>172533</bug_id>
          
          <creation_ts>2017-05-23 19:54:41 -0700</creation_ts>
          <short_desc>Camera/Canvas file input crash: A Problem Occurred with this Webpage so it was Reloaded</short_desc>
          <delta_ts>2022-07-28 09:38:50 -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>Canvas</component>
          <version>Safari 10</version>
          <rep_platform>iPhone / iPad</rep_platform>
          <op_sys>iOS 10</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>WORKSFORME</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="zac spitzer">zac.spitzer</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>alban.seurat</cc>
    
    <cc>dhsttryy</cc>
    
    <cc>dino</cc>
    
    <cc>fnicolicds</cc>
    
    <cc>ixevix</cc>
    
    <cc>jwhn91</cc>
    
    <cc>manian</cc>
    
    <cc>rmondello</cc>
    
    <cc>robert</cc>
    
    <cc>sabouhallawa</cc>
    
    <cc>simon.fraser</cc>
    
    <cc>thorton</cc>
    
    <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1312171</commentid>
    <comment_count>0</comment_count>
    <who name="zac spitzer">zac.spitzer</who>
    <bug_when>2017-05-23 19:54:41 -0700</bug_when>
    <thetext>When taking a photo using HTML file input with an iPhone, Safari often crashes cryptically 
with the &quot;A Problem Occurred with this Webpage so it was Reloaded&quot;. It seems this is due 
to an out of memory error, crash logs include reason:vm-thrashing

It may be related to canvas resizing, as the captured image, especially with 
the iPhone&apos;s higher megapixel camera producing much larger files that usually 
need to be resized before uploading

I did some research on github and people have been experiencing similar problems

https://github.com/kobotoolbox/enketo-express/issues/398
https://github.com/scottcheng/cropit/issues/226
https://github.com/Foliotek/Croppie/issues/243

this blog post goes into a lot of detail about this problem
http://digitalservicescompany.com/blog/case-study-image-resize-in-a-browser/</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1312191</commentid>
    <comment_count>1</comment_count>
    <who name="Simon Fraser (smfr)">simon.fraser</who>
    <bug_when>2017-05-23 22:08:50 -0700</bug_when>
    <thetext>What iOS versions and which iOS devices show the problem?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1312196</commentid>
    <comment_count>2</comment_count>
    <who name="zac spitzer">zac.spitzer</who>
    <bug_when>2017-05-23 22:26:57 -0700</bug_when>
    <thetext>Been seeing this problem occur on a iPhone 6 running 10.3.1, one user dropped back to an iPhone 5 with 10.3.1 and it didn&apos;t happen for a while, but then it started happening again. I can&apos;t reproduce this on an iPad (guessing due to smaller camera)

It was also happening with 9.3.x</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1312348</commentid>
    <comment_count>3</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2017-05-24 12:01:33 -0700</bug_when>
    <thetext>&lt;rdar://problem/32383118&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1313631</commentid>
    <comment_count>4</comment_count>
    <who name="zac spitzer">zac.spitzer</who>
    <bug_when>2017-05-29 21:14:52 -0700</bug_when>
    <thetext>another crash example
https://github.com/kangax/fabric.js/issues/3693</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1313840</commentid>
    <comment_count>5</comment_count>
    <who name="Simon Fraser (smfr)">simon.fraser</who>
    <bug_when>2017-05-30 13:32:42 -0700</bug_when>
    <thetext>I filed bug 172728 about https://github.com/kangax/fabric.js/issues/3693</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1313973</commentid>
    <comment_count>6</comment_count>
    <who name="Simon Fraser (smfr)">simon.fraser</who>
    <bug_when>2017-05-30 19:12:50 -0700</bug_when>
    <thetext>It would be helpful to provide URLs where the issues reported in the links in the first comment can be reproduced.

After analyzing https://github.com/kangax/fabric.js/issues/3693 in some detail, I believe it&apos;s not directly related, unless all the other sites are using the fabric canvas library.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1313977</commentid>
    <comment_count>7</comment_count>
    <who name="zac spitzer">zac.spitzer</who>
    <bug_when>2017-05-30 19:22:13 -0700</bug_when>
    <thetext>I just reproduced the crash on the &quot;Upload Example (with exif orientation compatability)&quot; demo here http://foliotek.github.io/Croppie/ (near the bottom of the page)  with an iPad running 10.3.2, you need to take quite a few photos (sorry I didn&apos;t keep an exact count!) and then it reloads</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1313978</commentid>
    <comment_count>8</comment_count>
    <who name="zac spitzer">zac.spitzer</who>
    <bug_when>2017-05-30 19:25:49 -0700</bug_when>
    <thetext>this also crashes after taking 5 photos http://scottcheng.github.io/cropit/ using the first demo on the page, iPad 10.3.2</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1314083</commentid>
    <comment_count>9</comment_count>
    <who name="Simon Fraser (smfr)">simon.fraser</who>
    <bug_when>2017-05-30 21:12:13 -0700</bug_when>
    <thetext>Thanks, I&apos;ll try those.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1314311</commentid>
    <comment_count>10</comment_count>
    <who name="Simon Fraser (smfr)">simon.fraser</who>
    <bug_when>2017-05-31 14:02:10 -0700</bug_when>
    <thetext>(In reply to zac spitzer from comment #8)
&gt; this also crashes after taking 5 photos http://scottcheng.github.io/cropit/
&gt; using the first demo on the page, iPad 10.3.2

Do you mean that you tap the &quot;Choose File&quot; button once, take a photo, and then take 4 more photos using the &quot;Retake&quot; button in the camera UI? Or something else?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1314324</commentid>
    <comment_count>11</comment_count>
    <who name="Simon Fraser (smfr)">simon.fraser</who>
    <bug_when>2017-05-31 14:31:14 -0700</bug_when>
    <thetext>(In reply to zac spitzer from comment #7)
&gt; I just reproduced the crash on the &quot;Upload Example (with exif orientation
&gt; compatability)&quot; demo here http://foliotek.github.io/Croppie/ (near the
&gt; bottom of the page)  with an iPad running 10.3.2, you need to take quite a
&gt; few photos (sorry I didn&apos;t keep an exact count!) and then it reloads

I reproduced it here. Thanks!</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1314465</commentid>
    <comment_count>12</comment_count>
    <who name="zac spitzer">zac.spitzer</who>
    <bug_when>2017-05-31 17:24:30 -0700</bug_when>
    <thetext>another similar problem with some detailed investigation via xcode
https://github.com/mapbox/mapbox-gl-js/issues/4695#issuecomment-305304043</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1314469</commentid>
    <comment_count>13</comment_count>
    <who name="Simon Fraser (smfr)">simon.fraser</who>
    <bug_when>2017-05-31 17:37:10 -0700</bug_when>
    <thetext>Interesting but let&apos;s not pile everything onto this bug. Please file a new bug for https://github.com/mapbox/mapbox-gl-js/issues/4695</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1320630</commentid>
    <comment_count>14</comment_count>
    <who name="Krister Bäckman">ixevix</who>
    <bug_when>2017-06-19 01:58:05 -0700</bug_when>
    <thetext>Happens on iOS 9.3.5 as well</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1323178</commentid>
    <comment_count>15</comment_count>
    <who name="Simon Fraser (smfr)">simon.fraser</who>
    <bug_when>2017-06-27 11:34:57 -0700</bug_when>
    <thetext>http://foliotek.github.io/Croppie/ creates a 3024x4032 canvas, which is 418MB, which is one reason why the web process gets killed.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1323378</commentid>
    <comment_count>16</comment_count>
    <who name="Simon Fraser (smfr)">simon.fraser</who>
    <bug_when>2017-06-27 19:47:46 -0700</bug_when>
    <thetext>http://foliotek.github.io/Croppie/ also has an &lt;img clas=&quot;cr-image&quot;&gt; with a 3D transforms and a 1280 x 720 image, which creates a layer of 2x or 3x that size (depending on device resolution), which also eats a lot of memory. So I think the http://foliotek.github.io/Croppie page is just using too much memory for images, layer backing store and and canvas.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1323380</commentid>
    <comment_count>17</comment_count>
    <who name="Simon Fraser (smfr)">simon.fraser</who>
    <bug_when>2017-06-27 19:51:37 -0700</bug_when>
    <thetext>http://scottcheng.github.io/cropit/ is also very memory hungry, with &lt;img class=&quot;cropit-preview-background&quot;&gt; taking 209MB, and &lt;img class=&quot;cropit-preview-image&quot;&gt; taking 188MB.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1323381</commentid>
    <comment_count>18</comment_count>
    <who name="zac spitzer">zac.spitzer</who>
    <bug_when>2017-06-27 19:54:06 -0700</bug_when>
    <thetext>But they work first time, why does it crash only after several attempts?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1323384</commentid>
    <comment_count>19</comment_count>
    <who name="Simon Fraser (smfr)">simon.fraser</who>
    <bug_when>2017-06-27 19:55:27 -0700</bug_when>
    <thetext>I haven&apos;t figure that part out yet :)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1336376</commentid>
    <comment_count>20</comment_count>
    <who name="zac spitzer">zac.spitzer</who>
    <bug_when>2017-08-07 22:58:17 -0700</bug_when>
    <thetext>Sorry to pester, but any progress on this? 

I have some very frustrated clients who are contemplating buying Android devices</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1336678</commentid>
    <comment_count>21</comment_count>
    <who name="Dean Jackson">dino</who>
    <bug_when>2017-08-08 15:13:00 -0700</bug_when>
    <thetext>(In reply to zac spitzer from comment #20)
&gt; Sorry to pester, but any progress on this? 
&gt; 
&gt; I have some very frustrated clients who are contemplating buying Android
&gt; devices

Nothing to report yet. We&apos;ll get to it soon.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1394539</commentid>
    <comment_count>22</comment_count>
    <who name="zac spitzer">zac.spitzer</who>
    <bug_when>2018-01-30 07:49:27 -0800</bug_when>
    <thetext>any updates? so many developers are battling against this bug and wasting hours trying to find workarounds</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1394692</commentid>
    <comment_count>23</comment_count>
    <who name="Simon Fraser (smfr)">simon.fraser</who>
    <bug_when>2018-01-30 12:55:03 -0800</bug_when>
    <thetext>In my investigations, this was mostly caused by web pages creating very large canvas elements (or leaking canvases, in the case of Fabric.js). If this affects your content, the best option is to optimize canvas memory usage.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1394701</commentid>
    <comment_count>24</comment_count>
    <who name="zac spitzer">zac.spitzer</who>
    <bug_when>2018-01-30 13:21:36 -0800</bug_when>
    <thetext>So why is this only a problem with Safari and only after processing several images via canvas? 

I&apos;ve been using https://github.com/gokercebeci/canvasResize and have tried manually setting every canvas object to null, but Safari still just runs out of memory and crashes

Neither Chrome or Firefox on Android exhibit this problem?

Is a Native API for image resizing needed? Modern cameras produce really large images and they need to be down sized before being uploaded and currently Canvas is the only option</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1514756</commentid>
    <comment_count>25</comment_count>
    <who name="Bobby">robert</who>
    <bug_when>2019-03-11 06:48:52 -0700</bug_when>
    <thetext>Its crashing for we without canvas being used, just a pure JS target.files and POST with payload in the body. iPhone 8, iOS 12.1</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1514759</commentid>
    <comment_count>26</comment_count>
    <who name="Bobby">robert</who>
    <bug_when>2019-03-11 07:11:26 -0700</bug_when>
    <thetext>(In reply to Bobby from comment #25)
&gt; Its crashing for we without canvas being used, just a pure JS target.files
&gt; and POST with payload in the body. iPhone 8, iOS 12.1

Now tested with iOS 12.1.4, same crash. Photo size from 1.6meg to 2.4meg. First photo almost always works, subsequent photos consistently crash (second, third)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1514976</commentid>
    <comment_count>27</comment_count>
    <who name="Simon Fraser (smfr)">simon.fraser</who>
    <bug_when>2019-03-11 13:45:49 -0700</bug_when>
    <thetext>(In reply to Bobby from comment #26)
&gt; (In reply to Bobby from comment #25)
&gt; &gt; Its crashing for we without canvas being used, just a pure JS target.files
&gt; &gt; and POST with payload in the body. iPhone 8, iOS 12.1
&gt; 
&gt; Now tested with iOS 12.1.4, same crash. Photo size from 1.6meg to 2.4meg.
&gt; First photo almost always works, subsequent photos consistently crash
&gt; (second, third)

Do you have a URL we can test with?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1570552</commentid>
    <comment_count>28</comment_count>
    <who name="Alban Seurat">alban.seurat</who>
    <bug_when>2019-09-13 05:03:53 -0700</bug_when>
    <thetext>I have the same issue with my iPhone 8 with iOS 12.4.1

Any website using &lt;input type=file&gt; is crashing safari after 2 or more takes (probably depending on the memory availability at the time. 

You can simply try to take several photos (without submitting them) there for instance: 
https://www.w3schools.com/tags/tryit.asp?filename=tryhtml_input_accept</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1669506</commentid>
    <comment_count>29</comment_count>
    <who name="Said Abou-Hallawa">sabouhallawa</who>
    <bug_when>2020-07-07 13:25:22 -0700</bug_when>
    <thetext>I tried the following links 

https://www.w3schools.com/tags/tryit.asp?filename=tryhtml_input_accept
http://scottcheng.github.io/cropit/
http://foliotek.github.io/Croppie/

On iPad Air 2/trunk webkit and I could not reproduce the crash after taking at least 10 photos.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1669520</commentid>
    <comment_count>30</comment_count>
    <who name="Said Abou-Hallawa">sabouhallawa</who>
    <bug_when>2020-07-07 13:59:53 -0700</bug_when>
    <thetext>I will try these scenarios on iPhone 6 Plus which is more memory restricted.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1669570</commentid>
    <comment_count>31</comment_count>
    <who name="Said Abou-Hallawa">sabouhallawa</who>
    <bug_when>2020-07-07 15:49:55 -0700</bug_when>
    <thetext>On iPhone 6 Plus/iOS 14/Trunk WebKit, I was able to take over 20 photos with the following pages:

https://www.w3schools.com/tags/tryit.asp?filename=tryhtml_input_accept
http://foliotek.github.io/Croppie/

And no crashes happened.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1887351</commentid>
    <comment_count>32</comment_count>
    <who name="fnicolicds">fnicolicds</who>
    <bug_when>2022-07-28 09:38:50 -0700</bug_when>
    <thetext>Seems that this issue is still happening on iOS 15. I was able to make the web content process crash just by taking photos (around 40) on my iPhone X iOS 15.4.1 with the following page: https://www.w3schools.com/tags/tryit.asp?filename=tryhtml_input_accept</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>