Bug 232122

Summary: REGRESSION (iOS 15): Canvas resizing causes webpage to jetsam
Product: WebKit Reporter: akul
Component: WebGLAssignee: Nobody <webkit-unassigned>
Status: NEW ---    
Severity: Normal CC: declan, dino, jonlee, kbr, kkinnunen, kpiddington, sabouhallawa, simon.fraser, smoley, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: Safari 15   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on:    
Bug Blocks: 231180    
Attachments:
Description Flags
reduced testacy none

Description akul 2021-10-21 17:43:54 PDT
Repro app: https://jsfiddle.net/5an01w6d/

Works on ios14.3
Failed on ios 15

Repro steps: Click both buttons (which call their respective canvas resize methods). On ios14 this does not cause a page reload. On ios15 the webpage crashes and reloads with both. 

No logs from console were outputted.
Comment 1 Alexey Proskuryakov 2021-10-22 10:10:17 PDT
I can reproduce with iOS 15.1 beta. This is a jetsam, i.e. running out of memory.
Comment 2 Radar WebKit Bug Importer 2021-10-22 10:10:29 PDT
<rdar://problem/84553912>
Comment 3 Declan Johnson 2021-10-22 11:59:52 PDT
This bug is causing an experience ContinuumXR made for the Immersive Van Gogh Art Gallery in New York, Denver, and Las Vegas to no longer work. Users with ios 15 are no longer able to experience the pocket gallery exhibit.
Comment 4 Kimmo Kinnunen 2021-12-07 04:34:16 PST
Created attachment 446159 [details]
reduced testacy
Comment 5 Kimmo Kinnunen 2021-12-07 04:40:00 PST
So the test jetsams because depth or stencil buffers are being allocated and they consume too much memory.
The buffers are freed eventually, but not during the test resize iteration.
The logic is:
  for (int i=0;i<10000;++i)
    resize()

The buffers do not seem to leak permanently, temporarily.

Maybe the buffers are retained in the command buffer, and we are clearing too many buffers without waiting for the previous buffer clears to complete.
Comment 6 Kimmo Kinnunen 2021-12-07 04:41:18 PST
To workaround, the reporters can check if they need stencil and depth buffers for the default Framebuffer. If not, switching those off should work around this crash.
Comment 7 Jon Lee 2022-01-10 16:30:07 PST
Is this sample code a reduction of something that's out there in public? Is this the pattern being used by the Van Gogh art gallery, for example?
Comment 8 Kenneth Russell 2022-01-10 18:35:02 PST
Not sure whether the patch was intended for this bug, but this upstream patch to ANGLE seems to be addressing a similar concern:

Metal: Canvas resizing causes webpage to run out of memory
https://chromium-review.googlesource.com/c/angle/angle/+/3369922