Bug 240639 - Canvas.toDataURL causes excessive GPUP memory use on Cocoa
Summary: Canvas.toDataURL causes excessive GPUP memory use on Cocoa
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Canvas (show other bugs)
Version: Safari 15
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nikos Mouchtaris
URL:
Keywords: InRadar
Depends on: 240866 241127
Blocks:
  Show dependency treegraph
 
Reported: 2022-05-19 03:46 PDT by Kimmo Kinnunen
Modified: 2022-06-30 23:40 PDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Kimmo Kinnunen 2022-05-19 03:46:08 PDT
Canvas.toDataURL causes excessive GPUP memory use on Cocoa


IOSurface -backed image -> CGBitmap copy -> 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&, std::__1::optional<double>, WebCore::PreserveResolution) const  (in WebCore) + 124  [0x113f883a0]
      +                 1 (61.0M) WebKit::RemoteRenderingBackend::getDataURLForImageBufferWithQualifiedIdentifier(WTF::String const&, std::__1::optional<double>, WebCore::PreserveResolution, WebCore::ProcessQualified<WTF::ObjectIdentifier<WebCore::RenderingResourceIdentifierType> >, WTF::CompletionHandler<void (WTF::String&&)>&&)  (in WebKit) + 124  [0x1057ac384]
      +                   1 (61.0M) void IPC::handleMessageSynchronous<Messages::RemoteRenderingBackend::GetDataURLForImageBuffer, WebKit::RemoteRenderingBackend, void (WebKit::RemoteRenderingBackend::*)(WTF::String const&, std::__1::optional<double>, WebCore::PreserveResolution, WTF::ObjectIdentifier<WebCore::RenderingResourceIdentifierType>, WTF::CompletionHandler<void (WTF::String&&)>&&)>(IPC::StreamServerConnection&, IPC::Decoder&, WebKit::RemoteRenderingBackend*, void (WebKit::RemoteRenderingBackend::*)(WTF::String const&, std::__1::optional<double>, WebCore::PreserveResolution, WTF::ObjectIdentifier<WebCore::RenderingResourceIdentifierType>, WTF::CompletionHandler<void (WTF::String&&)>&&))  (in WebKit) + 232  [0x10579cdf0]
Comment 1 Radar WebKit Bug Importer 2022-05-19 03:48:16 PDT
<rdar://problem/93567863>
Comment 2 Kimmo Kinnunen 2022-05-19 08:59:13 PDT
Should probably be fixed by removing ImageBuffer::toData / ImageBuffer::toDataURL and using data(), dataURL(), 


String dataURL(ImageBuffer&, const String& mimeType, std::optional<double> quality = std::nullopt, PreserveResolution preserveResolution)

Vector<uint8_t> toData(ImageBuffer&, const String& mimeType, std::optional<double> quality = std::nullopt)
Comment 3 Kimmo Kinnunen 2022-06-08 23:35:00 PDT
Pull request: https://github.com/WebKit/WebKit/pull/1407
Comment 4 Nikos Mouchtaris 2022-06-14 17:50:21 PDT
Pull request: https://github.com/WebKit/WebKit/pull/1528
Comment 5 Nikos Mouchtaris 2022-06-23 14:19:59 PDT
Pull request: https://github.com/WebKit/WebKit/pull/1741
Comment 6 EWS 2022-06-29 20:16:29 PDT
Committed 251974@main (bc684eeb57fb): <https://commits.webkit.org/251974@main>

Reviewed commits have been landed. Closing PR #1741 and removing active labels.
Comment 7 Claudio Saavedra 2022-06-30 04:31:49 PDT
Reopening as the change was reverted, see https://github.com/WebKit/WebKit/pull/1940
Comment 8 Nikos Mouchtaris 2022-06-30 10:36:42 PDT
Pull request: https://github.com/WebKit/WebKit/pull/1951
Comment 9 EWS 2022-06-30 23:40:02 PDT
Committed 252032@main (55390aa216e4): <https://commits.webkit.org/252032@main>

Reviewed commits have been landed. Closing PR #1951 and removing active labels.