Which 2D operation loses the canvas
Pages on this site that use only 2D canvases have lost their canvases, or the whole tab, on a phone (Chrome 159 on Android), and not in the test browser. Each row below does one thing that those pages have in common, alone, for about four seconds. Press "Run every trial" on the device that has the problem. It loads this page once for each trial, so that a trial which loses the canvases can't change the result of the next. If the tab dies, open this page again: the row that was running says so, and the run goes on with the next trial.
Nothing has run. The small canvas beside the buttons stays on the page through every trial: a trial that loses it has lost every accelerated canvas.
Live checks
Each trial is a check that waits for a press. A result is stored in this browser before the trial starts and after it ends, and sent to the site's report log, so a result survives a tab that dies.
| Result | Trial | Detail |
|---|
Show the code one trial, the loss listeners, the stored result
- The canvas of a trial. A drawable 2D canvas with one drawable child, sized once.
- The paint loop. A paint is asked for on every frame, and the element changes each time.
- The trials. Each changes one thing in that loop, or does one thing outside it.
- Running one. The result is stored as "running" first. A
contextlostlistener on every canvas of the trial, and on the canvas that stays, counts the losses.
How it works
- A trial builds its canvases in the box above, runs for about four seconds, removes them and gives them to
window.__gfx.retire(). "Run every trial" then loads the page again for the next trial (?run=<id>&chain=1): after a loss the guard stopspaintevents on a page, and a trial run after that would report the stop and not its own result. - Before a trial starts, its row is written to
localStorageas "running". When it ends the row is written again with the outcome. A page load that finds a row still "running" reports that the tab stopped during that trial. - Every canvas of a trial has a
contextlostlistener. So has one plain 2D canvas that is made at load and never removed. Accelerated 2D canvases share one connection to the GPU process, so a trial that loses that connection loses this canvas too. - Each start and each outcome is also sent with
window.__gfx.report('trial', …)to/api/reports, with the user agent.npm run reports -- --type trial --listprints them. - While trials run the page sets
window.__checkStateto "running", so the guard counts their readbacks as asked for.
Findings
From Chromium 157 with software rendering, 2026-11-21. The rows above say what your browser does.
- Measured: no trial loses a canvas in the test browser. All twenty-one end with "no loss". That browser keeps canvases in ordinary memory, so this says the trials run, not that they're safe.
- Reported from Chrome 159 on Android 10, 2026-11-21: a
willReadFrequentlydrawable canvas loses every 2D canvas. The ten trials before it ended with "no loss". The "read once" trial lost its own canvas and the canvas that stays, 35 ms after one draw and one readback, and again about every half second with no further call, until the guard stopped drawing. Live check fixtures across this site were made that way. A page with no site scripts then showed, in a page load for each case, that the draw alone is enough and that reads without the option lose nothing. - Fix: the guard removes the option.
/shared/context-guard.jsnow takeswillReadFrequentlyoff a drawable canvas. Not verified on the phone: the two "guard" trials say whether that holds, and the readback, copy, snapshot and float trials haven't run there yet. - Reported from the same phone, 2026-11-21: a second
getImageData()on a drawable canvas loses every 2D canvas. The trial that reads one pixel every 300 ms from a drawable canvas in a paint loop lost its canvas and the canvas that stays 7 ms after the second read, and again after every second read. One read loses nothing. The guard now answersgetImageData()on a drawable canvas from adrawImage()copy. - Reported from the same phone at 20:20 UTC on 2026-11-21, a page load for each trial: both fixes hold. All 21 trials ran. 17 ended with no loss, including the three that go through the guard ("removed by the guard", "with the guard's fix", "sent through a copy by the guard"), twelve reads of a
drawImage()copy, sixty open snapshots and the two float trials. The four that bypass the guard lost the canvases: twelve direct reads (12 losses), onewillReadFrequentlycanvas (10), twelve such fixtures freed (11) and not freed (86). - Limit: one operation at a time. A loss that needs two of these together, or more than four seconds, isn't found by this page.