Closed Bug 2093652 Opened 3 days ago Closed 3 days ago

Use a timer to drop free canvas buffers when a CanvasChild is dormant

Categories

(Core :: Graphics, task)

task

Tracking

()

RESOLVED FIXED
162 Branch
Tracking Status
firefox162 --- fixed

People

(Reporter: aosmond, Assigned: aosmond)

References

(Blocks 1 open bug)

Details

Attachments

(1 external file)

CanvasChild::EndTransaction schedules DropFreeBuffersWhenDormant with NS_DelayedDispatchToCurrentThread when there have been no non-empty transactions. That only works on the main thread: on a DOM worker, WorkerEventTarget::DelayedDispatch returns NS_ERROR_NOT_IMPLEMENTED, so the dormant cleanup never runs and the runnable (which holds a reference to the CanvasChild) is leaked.

Today a CanvasChild is only created on the main thread, because OffscreenCanvas on a worker cannot get one through ImageBridgeChild, so this is not reachable yet. It will be once accelerated OffscreenCanvas 2D is enabled on DOM workers.

Proposed fix: use a one-shot nsITimer on the current serial event target instead, which works on both the main thread and DOM workers, and cancel it in ~CanvasChild, since the callback no longer holds a reference to the CanvasChild. Main thread behaviour is unchanged.

DOM workers do not support delayed dispatch, which would fail and leak the
runnable.

Status: ASSIGNED → RESOLVED
Closed: 3 days ago
Resolution: --- → FIXED
Target Milestone: --- → 162 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: