|Summary:||[GPU Process] REGRESSION: Drawing a large SVG image on a canvas may take too much memory|
|Component:||Canvas||Assignee:||Said Abou-Hallawa <sabouhallawa>|
|Severity:||Major||CC:||dino, ews-watchlist, fmalita, gsnedders, gyuyoung.kim, pdr, roman.n, sabouhallawa, schenney, sergio, simon.fraser, wart.claes, webkit-bug-importer|
|Hardware:||iPhone / iPad|
Description kaput.sts 2021-09-28 02:45:52 PDT
It seems that when downscaling a HTML canvas by factor F, and drawing an image with SVG source, upscaled by factor F, iOS 15 Safari crashes when F is large enough, even though these two factors should cancel out (1/F * F = 1). I think it will draw the SVG to an intermediate texture F times the size of the SVG, in this case (F*1000)^2 pixels => kaboom. This is a regression because it works on all other browsers, and works fine in iOS 13 and 14 Safari. To reproduce, visit https://codepen.io/Ziriax/full/LYLgYxp
Comment 1 kaput.sts 2021-09-28 02:50:04 PDT
It seems Safari TP on OSX also crashes
Comment 2 Sam Sneddon [:gsnedders] 2021-09-28 09:31:15 PDT
GPU process, maybe?
Comment 4 Alexey Proskuryakov 2021-09-29 13:12:57 PDT
I cannot reproduce this on macOS 12 beta with Safari 15.1 on Apple Silicon, nor with STP 132, for what it's worth.
Comment 5 Sam Sneddon [:gsnedders] 2021-09-30 05:00:12 PDT
I can see vastly higher memory usage on macOS 12 beta with Safari 15.1 on Intel and vastly worse performance than Firefox Nightly or Chrome Canary. On the whole my assumption is the crash is "simply" OOM. I'd presume that Firefox and Chrome are cancelling out the factors and therefore they don't actually do anything.
Comment 6 Simon Fraser (smfr) 2021-09-30 10:12:13 PDT
GPU Process forced us to draw SVGs into an image buffer and then draw that to the canvas. That's probably the cause of the regression.
Comment 7 kaput.sts 2021-10-04 04:15:38 PDT
I see, that was what I expected. So some extra logic should be added to compute the minimal size of such an intermediate texture. If the world canvas transform is known, and the dimensions of the canvas, that is not too difficult IMHO?
Comment 8 Said Abou-Hallawa 2021-10-22 15:58:42 PDT
Created attachment 442208 [details] Simple test case (Should show a green rectangle)
Comment 10 EWS 2021-10-22 21:07:19 PDT
Committed r284740 (243449@main): <https://commits.webkit.org/243449@main> All reviewed patches have been landed. Closing bug and clearing flags on attachment 442212 [details].
Comment 11 Said Abou-Hallawa 2021-11-02 14:05:47 PDT
*** Bug 231796 has been marked as a duplicate of this bug. ***
Comment 12 Roman Nikitin 2021-11-09 06:24:57 PST
Could you tip when it will be in the new safari version?