#12239·pixijs

CanvasObserver fallback ticker listener survives destroy

Author: mf3493297-pngCreated Sep 27, 2026Updated Sep 27, 2026

CanvasObserver fallback ticker listener survives destroy

Current behavior

When ResizeObserver is unavailable, CanvasObserver uses Ticker.shared as its documented fallback. Every constructed observer adds updateTranslation to the shared ticker, but destroy() does not remove it.

A single create/destroy cycle leaves one listener behind. Ten additional cycles leave eleven listeners in total. The retained callbacks continue referencing their destroyed observer instances and DOM objects.

Expected behavior

CanvasObserver.destroy() should remove the fallback listener it added to Ticker.shared.

Reproduction

Public runnable reproduction:

Run:

bash
npm ci
npm start

Open http://127.0.0.1:4173/canvas-observer/ in Firefox. The page removes ResizeObserver, constructs and destroys observers, then prints:

REPRODUCED: {"baseline":0,"afterCreate":1,"afterDestroy":1,"afterTenCycles":11}

Verified in headed Camoufox.

Neighboring controls

  • Before construction, Ticker.shared.count is 0.
  • Constructing one fallback observer increases the count to 1, proving the fallback is active.
  • Destroying it leaves the count at 1, rather than returning to baseline.
  • Ten additional create/destroy cycles deterministically increase the count to 11.
  • The same runtime produces no page errors during the measurement.

Root cause

In src/dom/CanvasObserver.ts, the fallback branch adds the callback:

typescript
Ticker.shared.add(this.updateTranslation, this, UPDATE_PRIORITY.UTILITY);

but never sets _tickerAttached = true. destroy() removes the callback only when _tickerAttached is true:

typescript
if (this._tickerAttached)
{
    Ticker.shared.remove(this.updateTranslation, this);
    this._tickerAttached = false;
}

The cleanup branch is therefore unreachable for listeners added by the fallback path.

Environment

  • PixiJS dev commit: 27071aa0096d8749bfdb189857c58178c30cd153
  • npm package: [email protected]
  • Browser: headed Camoufox / Firefox
  • OS: Linux x86_64

Duplicate search

I searched open and closed issues/PRs for CanvasObserver, _tickerAttached, ResizeObserver fallback, Ticker destroy, and listener leaks. I did not find an issue describing this fallback cleanup failure.

If this fits the bounty program, please consider assigning a bounty label and amount before implementation work begins.