<?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>240639</bug_id>
          
          <creation_ts>2022-05-19 03:46:08 -0700</creation_ts>
          <short_desc>Canvas.toDataURL causes excessive GPUP memory use on Cocoa</short_desc>
          <delta_ts>2025-05-07 15: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 15</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          <see_also>https://bugs.webkit.org/show_bug.cgi?id=292651</see_also>
          <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>
          <dependson>240866</dependson>
    
    <dependson>241127</dependson>
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Kimmo Kinnunen">kkinnunen</reporter>
          <assigned_to name="Nikos Mouchtaris">nmouchtaris</assigned_to>
          <cc>csaavedra</cc>
    
    <cc>dino</cc>
    
    <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1870323</commentid>
    <comment_count>0</comment_count>
    <who name="Kimmo Kinnunen">kkinnunen</who>
    <bug_when>2022-05-19 03:46:08 -0700</bug_when>
    <thetext>Canvas.toDataURL causes excessive GPUP memory use on Cocoa


IOSurface -backed image -&gt; CGBitmap copy -&gt; compressed data string 

      1 (61.0M) CONTENT:  VM: CG raster data
      + 1 (61.0M) mmap  (in libsystem_kernel.dylib) + 0  [0x1dfc92c84]
  .....
      +       1 (61.0M) CGBitmapContextCreateImage  (in CoreGraphics) + 172  [0x1a6b6d444]
      +         1 (61.0M) WebKit::ShareableBitmap::makeCGImageCopy()  (in WebKit) + 84  [0x10544eb60]
      +           1 (61.0M) WebKit::ImageBufferShareableBitmapBackend::copyNativeImage(WebCore::BackingStoreCopy) const  (in WebKit) + 40  [0x105a7e1a4]
      +             1 (61.0M) WebCore::ImageBufferCGBackend::copyCGImageForEncoding(__CFString const*, WebCore::PreserveResolution) const  (in WebCore) + 568  [0x113f87f34]
      +               1 (61.0M) WebCore::ImageBufferCGBackend::toDataURL(WTF::String const&amp;, std::__1::optional&lt;double&gt;, WebCore::PreserveResolution) const  (in WebCore) + 124  [0x113f883a0]
      +                 1 (61.0M) WebKit::RemoteRenderingBackend::getDataURLForImageBufferWithQualifiedIdentifier(WTF::String const&amp;, std::__1::optional&lt;double&gt;, WebCore::PreserveResolution, WebCore::ProcessQualified&lt;WTF::ObjectIdentifier&lt;WebCore::RenderingResourceIdentifierType&gt; &gt;, WTF::CompletionHandler&lt;void (WTF::String&amp;&amp;)&gt;&amp;&amp;)  (in WebKit) + 124  [0x1057ac384]
      +                   1 (61.0M) void IPC::handleMessageSynchronous&lt;Messages::RemoteRenderingBackend::GetDataURLForImageBuffer, WebKit::RemoteRenderingBackend, void (WebKit::RemoteRenderingBackend::*)(WTF::String const&amp;, std::__1::optional&lt;double&gt;, WebCore::PreserveResolution, WTF::ObjectIdentifier&lt;WebCore::RenderingResourceIdentifierType&gt;, WTF::CompletionHandler&lt;void (WTF::String&amp;&amp;)&gt;&amp;&amp;)&gt;(IPC::StreamServerConnection&amp;, IPC::Decoder&amp;, WebKit::RemoteRenderingBackend*, void (WebKit::RemoteRenderingBackend::*)(WTF::String const&amp;, std::__1::optional&lt;double&gt;, WebCore::PreserveResolution, WTF::ObjectIdentifier&lt;WebCore::RenderingResourceIdentifierType&gt;, WTF::CompletionHandler&lt;void (WTF::String&amp;&amp;)&gt;&amp;&amp;))  (in WebKit) + 232  [0x10579cdf0]</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1870324</commentid>
    <comment_count>1</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2022-05-19 03:48:16 -0700</bug_when>
    <thetext>&lt;rdar://problem/93567863&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1870400</commentid>
    <comment_count>2</comment_count>
    <who name="Kimmo Kinnunen">kkinnunen</who>
    <bug_when>2022-05-19 08:59:13 -0700</bug_when>
    <thetext>Should probably be fixed by removing ImageBuffer::toData / ImageBuffer::toDataURL and using data(), dataURL(), 


String dataURL(ImageBuffer&amp;, const String&amp; mimeType, std::optional&lt;double&gt; quality = std::nullopt, PreserveResolution preserveResolution)

Vector&lt;uint8_t&gt; toData(ImageBuffer&amp;, const String&amp; mimeType, std::optional&lt;double&gt; quality = std::nullopt)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1874913</commentid>
    <comment_count>3</comment_count>
    <who name="Kimmo Kinnunen">kkinnunen</who>
    <bug_when>2022-06-08 23:35:00 -0700</bug_when>
    <thetext>Pull request: https://github.com/WebKit/WebKit/pull/1407</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1875930</commentid>
    <comment_count>4</comment_count>
    <who name="Nikos Mouchtaris">nmouchtaris</who>
    <bug_when>2022-06-14 17:50:21 -0700</bug_when>
    <thetext>Pull request: https://github.com/WebKit/WebKit/pull/1528</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1877850</commentid>
    <comment_count>5</comment_count>
    <who name="Nikos Mouchtaris">nmouchtaris</who>
    <bug_when>2022-06-23 14:19:59 -0700</bug_when>
    <thetext>Pull request: https://github.com/WebKit/WebKit/pull/1741</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1879229</commentid>
    <comment_count>6</comment_count>
    <who name="EWS">ews-feeder</who>
    <bug_when>2022-06-29 20:16:29 -0700</bug_when>
    <thetext>Committed 251974@main (bc684eeb57fb): &lt;https://commits.webkit.org/251974@main&gt;

Reviewed commits have been landed. Closing PR #1741 and removing active labels.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1879316</commentid>
    <comment_count>7</comment_count>
    <who name="Claudio Saavedra">csaavedra</who>
    <bug_when>2022-06-30 04:31:49 -0700</bug_when>
    <thetext>Reopening as the change was reverted, see https://github.com/WebKit/WebKit/pull/1940</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1879424</commentid>
    <comment_count>8</comment_count>
    <who name="Nikos Mouchtaris">nmouchtaris</who>
    <bug_when>2022-06-30 10:36:42 -0700</bug_when>
    <thetext>Pull request: https://github.com/WebKit/WebKit/pull/1951</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1879664</commentid>
    <comment_count>9</comment_count>
    <who name="EWS">ews-feeder</who>
    <bug_when>2022-06-30 23:40:02 -0700</bug_when>
    <thetext>Committed 252032@main (55390aa216e4): &lt;https://commits.webkit.org/252032@main&gt;

Reviewed commits have been landed. Closing PR #1951 and removing active labels.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>