Bug 212214

Summary: Serious canvas memory leak in Safari (both iOS / macOS)
Product: WebKit Reporter: kaz.namba
Component: CanvasAssignee: Nobody <webkit-unassigned>
Status: NEW ---    
Severity: Critical CC: cdumez, davy.de.durpel, dino, simon.fraser, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: Safari 13   
Hardware: All   
OS: All   
URL: https://gist.github.com/kulikala/039d7c94f46ee860f1f9e2714104cb90
See Also: https://bugs.webkit.org/show_bug.cgi?id=203990
https://bugs.webkit.org/show_bug.cgi?id=134355
Attachments:
Description Flags
An HTML code to reproduce none

Description kaz.namba 2020-05-21 08:52:16 PDT
Created attachment 399958 [details]
An HTML code to reproduce

Safari crashes because of memory leak.
This issue occurs both on iOS and macOS.

I attached the reproduction code, also put it on the Gist.
https://gist.github.com/kulikala/039d7c94f46ee860f1f9e2714104cb90

Trigger condition is same with the following issue:
https://bugs.webkit.org/show_bug.cgi?id=134355

> ctx.drawImage(anotherCanvas, clipX, clipY, clipW, clipH, x, y, w, h) --> memory leak.
> ctx.drawImage(anotherCanvas, x, y, w, h) --> no memory leak.

There's a slight difference with my reproduction code: the image source is switched to HTMLVideoElement.

I confirmed this memory leak via Web Inspector's Timelines tab.
Page category of memory instrument keeps growing and reaches 3GB (my MacBook Pro has 16GB memory).
Comment 1 Alexey Proskuryakov 2020-05-21 10:53:46 PDT
Safari kills the page for using too much memory in a few seconds.
Comment 2 Radar WebKit Bug Importer 2020-05-21 10:53:57 PDT
<rdar://problem/63500557>
Comment 3 Simon Fraser (smfr) 2020-05-21 13:31:15 PDT
What macOS/iOS versions are you reproducing this on?
Comment 4 kaz.namba 2020-05-21 13:46:12 PDT
I confirmed the reproduction on

macOS: Catalina v10.15.4
  Safari: v13.1 (15609.1.20.111.8)

iOS: v13.5