Bug 233328

Summary: ANGLE Metal: The memory backing IOSurfaces of former client buffer pbuffers is leaked
Product: WebKit Reporter: Kimmo Kinnunen <kkinnunen>
Component: WebGLAssignee: Kimmo Kinnunen <kkinnunen>
Status: RESOLVED FIXED    
Severity: Normal CC: dino, ews-watchlist, geofflang, gman, jonahr, kbr, kkinnunen, koivisto, kondapallykalyan, kpiddington, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: Other   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on:    
Bug Blocks: 234356    
Attachments:
Description Flags
Patch
ews-feeder: commit-queue-
Patch
ews-feeder: commit-queue-
Patch for landing none

Description Kimmo Kinnunen 2021-11-18 12:27:02 PST
ANGLE Metal: The memory backing IOSurfaces of former client buffer pbuffers is leaked

This affects mainly WebGL GPU process.

To repro:
Set "WebGL via Metal" and "GPU Process: WebGL"
Navigate to https://webglsamples.org/aquarium/aquarium.html and observe GPUP memory consumption go up.

footprint $(pgrep GPU.Development)
 
GPU Process uses m_context->markDisplayBufferInUse(); to destroy each WebGL drawing buffer PBuffer before sending the IOSurface to WebContent process for compositing.
This should detach the IOSurface from the EGL pbuffer and as such the pbuffer from the GL texture.

Somehow the memory is still leaking through GPU process.

Note: 
This leaking memory is leaked as "something something graphics memory" (via footprint tool).

Normal IOSurfaces are marked as "IOSurface" by footprint.

The leak doesn't exist in OpenGL backend.
Comment 1 Radar WebKit Bug Importer 2021-11-18 12:32:48 PST
<rdar://problem/85563187>
Comment 2 Kenneth Russell 2021-11-18 18:49:18 PST
Yikes. Please tell us if it looks like this leak is inside ANGLE.
Comment 3 Kimmo Kinnunen 2021-11-24 04:53:09 PST
Created attachment 445088 [details]
Patch
Comment 4 Kimmo Kinnunen 2021-11-24 05:50:21 PST
Created attachment 445092 [details]
Patch
Comment 5 Kimmo Kinnunen 2021-11-24 06:08:25 PST
Created attachment 445096 [details]
Patch for landing
Comment 6 Kimmo Kinnunen 2021-11-25 00:59:06 PST
> Yikes. Please tell us if it looks like this leak is inside ANGLE.
No, this one was in WebKit, one of my added features.
Comment 7 EWS 2021-11-25 01:17:53 PST
Committed r286160 (244544@main): <https://commits.webkit.org/244544@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 445096 [details].