Open Bug 1883399 Opened 1 year ago Updated 1 year ago

Canvas demo can spend 13s in HTMLCanvasElementObserver::UnregisterObserverEvents() (4m+ in extreme case)

Categories

(Core :: Graphics: Canvas2D, defect)

defect

Tracking

()

People

(Reporter: mayankleoboy1, Unassigned)

References

()

Details

Attachments

(2 files)

  1. Go to https://ondras.github.io/primitive.js/
  2. Select the attached image file as the input
  3. Set the box (3rd column, 2 row) slider to maximum value - 1000
    Extreme 3. (For the "extreme" version, do the above and then set the first slider to maximum value - 500)
  4. Click "Lets Go"

AR:
Extreme version: https://share.firefox.dev/3T0sGJF
Normal version (skia-canvas): https://share.firefox.dev/48Nao4M
Normal version (gpu-canvas): https://share.firefox.dev/3TkYhXZ

ER: Maybe something to improve?

(This sounds like it may be bug 1870765 and thus may end up being a dupe.)

cc smaug and continuation
Can repro on a build from Jan2022, so not a recent regression

Attached file about:support
See Also: → 1870765
Summary: Canvas demo can spend 13s in CC (4m+ in extreme case) → Canvas demo can spend 13s in CC (4m+ CC slice spent in "Collect White" in extreme case)

It looks like the time is all under HTMLCanvasElementObserver::UnregisterObserverEvents(). The cycle collector itself can't do anything about it. I'm guessing there's quadratic behavior in that code somehow.

Component: Cycle Collector → Graphics: Canvas2D
Summary: Canvas demo can spend 13s in CC (4m+ CC slice spent in "Collect White" in extreme case) → Canvas demo can spend 13s in HTMLCanvasElementObserver::UnregisterObserverEvents() (4m+ in extreme case)

Is there a lot of canvas objects? Removing the observer removes from an unordered list so it could be quadratic. We had a similar problem with ImageBitmaps, so we just used a hastset to keep track of imagebitmaps that observed shutdown.

Yeah, I see 116000 calls to HTMLCanvasElementObserver::UnregisterObserverEvents.

Triage - rating as S3, if this appears on websites that aren't merely demos I would consider S2.

Severity: -- → S3

With gpu-canvas, this also manifests as a "system-level" exponential increase in memory use that will OOM the browser/machine.
Example profile : https://share.firefox.dev/48SgsZw (system-level memory was about 10GB from a baseline of 5.5GB)

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

Attachment

General

Creator:
Created:
Updated:
Size: