Closed Bug 1801021 Opened 2 years ago Closed 2 years ago

Dispatching webgl commands from a worker that does not yield to its event loop causes unbound accumulation of shmems

Categories

(Core :: Graphics: CanvasWebGL, defect)

defect

Tracking

()

RESOLVED FIXED
109 Branch
Tracking Status
firefox108 --- fixed
firefox109 --- fixed

People

(Reporter: jrmuizel, Assigned: jgilbert)

References

(Blocks 1 open bug)

Details

Attachments

(1 file)

WebGL is currently using RaiiShmem for transferring command data to the GPU process. This doesn't necessarily work well with DOM workers because it relies on processing received messages to delete the shared memory that it's using.

We run into this problem when using background blur in Zoom and memory usage ends up increasing without bound.

Assignee: nobody → jgilbert
Summary: Use BigBuffer for WebGL IPC communication → Dispatching webgl commands from a worker that does not yield to its event loop causes unbound accumulation of shmems

Using ipc::Shmem causes unbounded shmem use growth until e.g. a Worker
yields to the event loop. If a Worker never yields, Shmems sent to WebGLParent
are never released.

Specifically the manager (PCanvasManager) for WebGLParent calls
DestroySharedMemory, which sends/enqueues for WebGLChild's manager a
matching call to ShmemDestroyed. However, while WebGLChild refuses to spin its
event loop (such as a no-return WASM Worker), the ShmemDestroyed events
will just pile up. Closing e.g. the tab frees the shmems, but they accumulate
unbounded until the Worker yields to the event loop.

This is true for other users of ipc::Shmem (or RaiiShmem) as well, but
entrypoints other than DispatchCommands are rarer and can be handled
later similarly.

Pushed by jmuizelaar@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/fa04ef087c24 Use BigBuffer for DispatchCommands. r=gfx-reviewers,lsalzman

Backed out changeset fa04ef087c24 (Bug 1801021) for causing bustages on WebGLChild.cpp and WebGLParent.cpp.
Backout link
Push with failures <--> Bbc
Failure Log

Flags: needinfo?(jgilbert)
Pushed by jmuizelaar@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/54624ab3a100 Use BigBuffer for DispatchCommands. r=gfx-reviewers,lsalzman
Status: NEW → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → 109 Branch

Comment on attachment 9305056 [details]
Bug 1801021 - Use BigBuffer for DispatchCommands.

Beta/Release Uplift Approval Request

  • User impact if declined: Certain use cases (e.g. Zoom background blur) cause unbounded memory allocations until use stops or navigation, which can quickly exhaust system memory.
  • Is this code covered by automated tests?: No
  • Has the fix been verified in Nightly?: Yes
  • Needs manual test from QE?: No
  • If yes, steps to reproduce:
  • List of other uplifts needed: None
  • Risk to taking this patch: Medium
  • Why is the change risky/not risky? (and alternatives if risky): Not very risky, but we do make changes to both BigBuffer and the allocation for the core mechanism for how WebGL works. We have a lot of webgl tests, but this is load-bearing enough that I don't think it's "low" risk.
  • String changes made/needed: none
  • Is Android affected?: Yes
Flags: needinfo?(jgilbert)
Attachment #9305056 - Flags: approval-mozilla-beta?

Comment on attachment 9305056 [details]
Bug 1801021 - Use BigBuffer for DispatchCommands.

Approved for 108.0b8

Attachment #9305056 - Flags: approval-mozilla-beta? → approval-mozilla-beta+

== Change summary for alert #36249 (as of Wed, 30 Nov 2022 18:55:34 GMT) ==

Improvements:

Ratio Test Platform Options Absolute values (old vs new)
6% motionmark_webgl 3DGraphics-WebGL windows10-64-shippable-qr e10s fission stylo webgl-ipc webrender 11.51 -> 12.25
6% glterrain windows10-64-shippable-qr e10s fission stylo webgl-ipc webrender 1.53 -> 1.45
5% motionmark_webgl 3DGraphics-WebGL windows10-64-shippable-qr e10s fission stylo webgl-ipc webrender 11.55 -> 12.17

For up to date results, see: https://treeherder.mozilla.org/perfherder/alerts?id=36249

Blocks: 1803366
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: