Bug 222723

Summary: Canvas Memory Leak
Product: WebKit Reporter: Roman Nikitin <roman.n>
Component: CanvasAssignee: Nobody <webkit-unassigned>
Status: NEW ---    
Severity: Blocker CC: dino, rniwa, sabouhallawa, simon.fraser, webkit-bug-importer, ysuzuki
Priority: P1 Keywords: InRadar
Version: Safari 14   
Hardware: Mac (Intel)   
OS: macOS 11   
Attachments:
Description Flags
memory usage screenshot
none
Profile file
none
Chrome profile
none
Safari profile none

Description Roman Nikitin 2021-03-04 01:44:56 PST
Created attachment 422201 [details]
memory usage screenshot

In Canvas with big count of elements memory reaches limit. It can be about 2GB. Unfortunately, I can't profile it, because dev tools fails. But in Chromium same canvas takes about 200mb. 
I found old tickets about the same problem, but they are not solved. This problem is critical for our product.
Comment 2 Alexey Proskuryakov 2021-03-05 13:35:05 PST
Could you please provide a test that reproduces this issue?
Comment 3 Roman Nikitin 2021-03-08 22:37:39 PST
Created attachment 422665 [details]
Profile file
Comment 4 Roman Nikitin 2021-03-08 22:38:19 PST
I've added profile file. Did you mean it?
Comment 5 Simon Fraser (smfr) 2021-03-09 10:05:47 PST
We need a link to a web page which we can load ourselves to investigate the issue.
Comment 6 Roman Nikitin 2021-03-11 00:05:10 PST
We are preparing example with not sensitive information, wait please
Comment 7 Radar WebKit Bug Importer 2021-03-11 01:45:22 PST
<rdar://problem/75307418>
Comment 8 Roman Nikitin 2021-03-11 03:35:44 PST
I've prepared link where leak happens https://miro.com/app/board/o9J_lQfOEOc=/

My actions:
 - I see all "frames" in board
 - I try to zoom to one "frame"

In safari memory it takes about 2gb memory - limit was reached
In chrome memory it takes 200mb in peak

I've added new profile files
Comment 9 Roman Nikitin 2021-03-11 03:36:22 PST
Created attachment 422919 [details]
Chrome profile
Comment 10 Roman Nikitin 2021-03-11 03:37:14 PST
Created attachment 422920 [details]
Safari profile
Comment 11 Roman Nikitin 2021-03-15 22:42:44 PDT
Do you have any updates?
Comment 12 Simon Fraser (smfr) 2021-03-16 11:44:22 PDT
What version of Safari are you testing, and on what OS version?
Comment 13 Roman Nikitin 2021-03-16 12:02:16 PDT
I have MacOS 11.2.2 and Safari 14.0.3
Comment 14 Said Abou-Hallawa 2021-03-16 12:50:28 PDT
When doing little editing in https://miro.com/app/board/o9J_lQfOEOc=/, Safari can reach 1GB on my machine.

Chrome uses three processes when opening this page (Google Chrome, Google Chrome Helper "Renderer" and Google Chrome Helper "GPU"). The total memory of these processes is about 880MB.

So Safari takes 16% more than Chrome. But regardless of this, 1GB memory is a huge amount of memory to be taken by one page.
Comment 15 Roman Nikitin 2021-03-17 00:51:40 PDT
If I understand correctly, Chrome can parallel some processes and because it works faster them Safari? And now webkit doesn't have problems with memory and garbage collection. Could you confirm it?
Comment 16 Said Abou-Hallawa 2021-03-19 13:00:25 PDT
The page https://miro.com/app/board/o9J_lQfOEOc=/ has three full screen canvases. On my iMacPro, each takes 5120 x 2776 pixels. The size of each backing IOSurface is 56,852,480 bytes. This is almost 57MB.
Comment 17 Roman Nikitin 2021-03-19 13:25:39 PDT
Okay, thanks. I will try to find more information about memory using. If I find something, can I write here?