<?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>134355</bug_id>
          
          <creation_ts>2014-06-26 12:42:21 -0700</creation_ts>
          <short_desc>Serious canvas memory leak in iOS 7.1.1.</short_desc>
          <delta_ts>2020-05-21 10:53:46 -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>528+ (Nightly build)</version>
          <rep_platform>iPhone / iPad</rep_platform>
          <op_sys>iOS 7.0</op_sys>
          <bug_status>NEW</bug_status>
          <resolution></resolution>
          
          <see_also>https://bugs.webkit.org/show_bug.cgi?id=212214</see_also>
          <bug_file_loc>http://stackoverflow.com/questions/24387541/ios-7-1-1-canvas-drawimage-memory-leak/</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>aga</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>dino</cc>
    
    <cc>jonlee</cc>
    
    <cc>nicolas.ramz</cc>
    
    <cc>public</cc>
    
    <cc>simon.fraser</cc>
    
    <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1018711</commentid>
    <comment_count>0</comment_count>
    <who name="">aga</who>
    <bug_when>2014-06-26 12:42:21 -0700</bug_when>
    <thetext>Not sure if this is an internal iOS issue or not, but in Safari on iOS 7.1.1 there is a serious canvas memory leak:

http://stackoverflow.com/questions/24387541/ios-7-1-1-canvas-drawimage-memory-leak/ :

ctx.drawImage(anotherCanvas, clipX, clipY, clipW, clipH, x, y, w, h) --&gt; memory leak.
ctx.drawImage(anotherCanvas, x, y, w, h) --&gt; no memory leak.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1018808</commentid>
    <comment_count>1</comment_count>
    <who name="Simon Fraser (smfr)">simon.fraser</who>
    <bug_when>2014-06-26 17:10:53 -0700</bug_when>
    <thetext>How did you determine that this causes a memory leak?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1019175</commentid>
    <comment_count>2</comment_count>
    <who name="">aga</who>
    <bug_when>2014-06-27 20:45:32 -0700</bug_when>
    <thetext>I may have been a bit hasty. This may not be a memory leak... I did find an audio memory leak in my web-app... I think that is the problem... although this might be a problem in and of itself.

https://bugs.webkit.org/show_bug.cgi?id=134425</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1023555</commentid>
    <comment_count>3</comment_count>
      <attachid>235190</attachid>
    <who name="M. Hanselmann">public</who>
    <bug_when>2014-07-20 12:47:34 -0700</bug_when>
    <thetext>Created attachment 235190
Test case

A customer of mine reported an issue application using UIWebView. It would become slow and eventually crash after quite some time. I have since investigated the issue and have to confirm the original report. Tests were done using iOS 7.1.2.

If the allocation traces by Instruments.app are to be believed, the leaks is in the vicinity of WebCore/platform/graphics/cg/ImageSourceCG.cpp, but I&apos;m not familiar enough with WebKit/WebCore to be certain. It may also be an issue in Apple prorietary code.

The attached test case can be used to reproduce the issue reliably. The test image was a PNG file with 768×576px. Another test used a file with 981×820px.

I haven&apos;t succeeded in getting allocation traces using Mobile Safari, but in a custom application the memory consumption increased at a steady 1.2-1.4 MB per 1&apos;000 frames.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1025059</commentid>
    <comment_count>4</comment_count>
    <who name="M. Hanselmann">public</who>
    <bug_when>2014-07-27 15:12:36 -0700</bug_when>
    <thetext>Since my last update I did a few more tests using an iPhone 4 running iOS 7.1.2. Here&apos;s how to reproduce the issue without Cordova/PhoneGap:

- Put test case HTML on a webserver
- Put image with at least 800×800px as “test.png” on web server (not sure if the size is relevant)
- Create new iOS Single View Application project in Xcode
- Open iOS storyboard
- Add UIWebView element
- Add outlet for web view to ViewController.m
- Add the following code to -[ViewController viewDidLoad] (make sure to use the correct URL):
  [_webview loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@&quot;http://server:8080/&quot;]]];
- Run program on iPhone and watch its memory usage using Instruments.app

When I look at the allocation summary, the IOAccelResource category keeps increasing at a rate of about 24 KB/sec (measured over 8 minutes after a warm-up period of half a minute). CGImageProvider and CGImage keep allocating memory, too.

Tests with more than one image did not, as far as I could tell, change the numbers in a significant way.

Interestingly this doesn&apos;t even seem to be the same issue that I see in my client&apos;s application. All I know is that something somewhere is leaking.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1025068</commentid>
    <comment_count>5</comment_count>
    <who name="Simon Fraser (smfr)">simon.fraser</who>
    <bug_when>2014-07-27 16:15:27 -0700</bug_when>
    <thetext>(In reply to comment #4)
&gt; Since my last update I did a few more tests using an iPhone 4 running iOS 7.1.2. Here&apos;s how to reproduce the issue without Cordova/PhoneGap:
&gt; 
&gt; - Put test case HTML on a webserver
&gt; - Put image with at least 800×800px as “test.png” on web server (not sure if the size is relevant)
&gt; - Create new iOS Single View Application project in Xcode
&gt; - Open iOS storyboard
&gt; - Add UIWebView element
&gt; - Add outlet for web view to ViewController.m
&gt; - Add the following code to -[ViewController viewDidLoad] (make sure to use the correct URL):
&gt;   [_webview loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@&quot;http://server:8080/&quot;]]];
&gt; - Run program on iPhone and watch its memory usage using Instruments.app
&gt; 
&gt; When I look at the allocation summary, the IOAccelResource category keeps increasing at a rate of about 24 KB/sec (measured over 8 minutes after a warm-up period of half a minute). CGImageProvider and CGImage keep allocating memory, too.
&gt; 
&gt; Tests with more than one image did not, as far as I could tell, change the numbers in a significant way.
&gt; 
&gt; Interestingly this doesn&apos;t even seem to be the same issue that I see in my client&apos;s application. All I know is that something somewhere is leaking.

If you haven&apos;t already, please file a bug a bugreporter.apple.com with a test application that can be run out of the box.

Have you tested any iOS 8 seeds for this bug?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1025070</commentid>
    <comment_count>6</comment_count>
    <who name="M. Hanselmann">public</who>
    <bug_when>2014-07-27 16:20:27 -0700</bug_when>
    <thetext>(In reply to comment #5)
&gt; If you haven&apos;t already, please file a bug a bugreporter.apple.com with a test application that can be run out of the box.

I&apos;m in the process of preparing that, but I wanted to document my discoveries publically. In addition I want to make a minimal example for the exact case we have in my customer&apos;s application first.

&gt; Have you tested any iOS 8 seeds for this bug?

Unfortunately not. My only test device is an iPhone 4, which isn&apos;t supported by iOS 8.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1025091</commentid>
    <comment_count>7</comment_count>
    <who name="M. Hanselmann">public</who>
    <bug_when>2014-07-27 20:25:57 -0700</bug_when>
    <thetext>(In reply to comment #5)
&gt; If you haven&apos;t already, please file a bug a bugreporter.apple.com with a test application that can be run out of the box.

I have created a report there now. The ID is 17825107.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1100539</commentid>
    <comment_count>8</comment_count>
    <who name="">nicolas.ramz</who>
    <bug_when>2015-06-08 17:58:51 -0700</bug_when>
    <thetext>I&apos;m not sure this is related, but I have a piece of code that crashes Safari on iOS 7/8 (crashes the whole app on iOS 7, crashes current tab only on iOS 8): http://experiments.warpdesign.fr/iOSCanvasBug/

It happens when calling ctx.drawImage() using a canvas as source.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1100548</commentid>
    <comment_count>9</comment_count>
    <who name="Simon Fraser (smfr)">simon.fraser</who>
    <bug_when>2015-06-08 18:28:59 -0700</bug_when>
    <thetext>Please try the iOS 9 beta.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1546314</commentid>
    <comment_count>10</comment_count>
    <who name="Jon Lee">jonlee</who>
    <bug_when>2019-06-19 17:20:12 -0700</bug_when>
    <thetext>rdar://problem/17825107</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>235190</attachid>
            <date>2014-07-20 12:47:34 -0700</date>
            <delta_ts>2014-07-20 12:47:34 -0700</delta_ts>
            <desc>Test case</desc>
            <filename>bug134355.html</filename>
            <type>text/html</type>
            <size>1082</size>
            <attacher name="M. Hanselmann">public</attacher>
            
              <data encoding="base64">PCFET0NUWVBFIGh0bWw+CjxodG1sPgo8aGVhZD4KPG1ldGEgY2hhcnNldD0idXRmLTgiIC8+Cjxt
ZXRhIG5hbWU9InZpZXdwb3J0IiBjb250ZW50PSJ3aWR0aD1kZXZpY2Utd2lkdGgsIGluaXRpYWwt
c2NhbGU9MS4wLCBtYXhpbXVtLXNjYWxlPTEuMCwgdXNlci1zY2FsYWJsZT1ubyIgLz4KPC9oZWFk
Pgo8Ym9keT4KPGNhbnZhcyBpZD0iY2FudmFzIiB3aWR0aD0iNjQwIiBoZWlnaHQ9IjQ4MCI+PC9j
YW52YXM+Cgo8c2NyaXB0IHR5cGU9InRleHQvamF2YXNjcmlwdCI+CnZhciBpbWcgPSBuZXcgSW1h
Z2U7Cgp2YXIgY2FudmFzID0gZG9jdW1lbnQuZ2V0RWxlbWVudEJ5SWQoImNhbnZhcyIpOwp2YXIg
Y3R4ID0gY2FudmFzLmdldENvbnRleHQoIjJkIik7Cgp2YXIgeG9mZiA9IDA7CnZhciB5b2ZmID0g
MDsKCnZhciBmcmFtZXMgPSAwOwoKdmFyIGYgPSBmdW5jdGlvbiAoKSB7CiAgdmFyIHcgPSBNYXRo
Lm1pbihpbWcud2lkdGggLSB4b2ZmLCBjYW52YXMud2lkdGgpOwogIHZhciBoID0gTWF0aC5taW4o
aW1nLmhlaWdodCAtIHlvZmYsIGNhbnZhcy5oZWlnaHQpOwoKICBjdHguY2xlYXJSZWN0KDAsIDAs
IGNhbnZhcy53aWR0aCwgY2FudmFzLmhlaWdodCk7CgogIGlmICgxKSB7CiAgIC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