Closed Bug 1887729 Opened 3 months ago Closed 3 months ago

Implement context loss for CanvasRenderingContext2D

Categories

(Core :: Graphics: Canvas2D, enhancement)

enhancement

Tracking

()

RESOLVED FIXED
126 Branch
Tracking Status
relnote-firefox --- 125+
firefox-esr115 --- wontfix
firefox124 --- wontfix
firefox125 --- fixed
firefox126 --- fixed

People

(Reporter: aosmond, Assigned: aosmond)

References

Details

(Keywords: dev-doc-complete)

Attachments

(1 file)

No description provided.

Remote canvas can run in the GPU process, and if the GPU process
crashes, we need to notify the application using canvas. Historically we
just failed, and the application may have been able to continue drawing
but with the contents prior to the crash lost. Later we regressed to
prevent the canvas from being used at all.

This patch makes it so that we can restore functionality to any
application that supports the contextlost/contextrestored events. This
will allow for a theoretical complete graceful recovery for the user
with minimal disruption.

This should allow us to reach parity with Chrome in these recovery scenarios and completely fix bug 1882573.

Blocks: 1882573
Depends on: 1886022
Pushed by aosmond@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/40fa8e4b06c8
Implement context lost/restored support for CanvasRenderingContext2D. r=webidl,gfx-reviewers,smaug,lsalzman

(In reply to Andrew Osmond [:aosmond] (he/him) from comment #2)

This should allow us to reach parity with Chrome in these recovery scenarios and completely fix bug 1882573.

Testing shows that while Google Docs is fine, Google Sheets recovery is incomplete. It appears that Google Sheets itself is choosing to only redraw part of the canvas (everything surrounding the inner cells with the user data, but not the inner cells themselves) and it is unclear why. Resizing the window, or refreshing solves the problem. Chrome does not have this problem, although both Firefox and Chrome do not recover as smooth as Google Docs do.

I believe these test failures are all because the new test predicted we would get accelerated/remote canvas with the test case, but we did not.

Flags: needinfo?(aosmond)
Pushed by aosmond@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/1c98db62bb1a
Implement context lost/restored support for CanvasRenderingContext2D. r=webidl,gfx-reviewers,smaug,lsalzman
Status: ASSIGNED → RESOLVED
Closed: 3 months ago
Resolution: --- → FIXED
Target Milestone: --- → 126 Branch

Comment on attachment 9393115 [details]
Bug 1887729 - Implement context lost/restored support for CanvasRenderingContext2D.

Beta/Release Uplift Approval Request

  • User impact if declined: When the GPU process crashes, accelerated (WebGL on Android) and remote (D2D on Windows) canvas will not repaint, and may take seconds to recover. OSX and Linux would also be impacted but they don't have a GPU process. Now properly implemented web applications can seamlessly recover from a GPU process crash, as well as avoiding the delay on recovery for all canvas users including those that don't leverage oncontextlost/restored.
  • Is this code covered by automated tests?: Yes
  • 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: Low
  • Why is the change risky/not risky? (and alternatives if risky): Most of the change is boilerplate, a new mochitest and test fuzz updates. Given the severity of the present behaviour, and the massive improvement this patch provides, I'd say it is worth it.
  • String changes made/needed:
  • Is Android affected?: Yes
Attachment #9393115 - Flags: approval-mozilla-beta?

I manually verified on the latest nightly.

Keywords: dev-doc-needed
Severity: -- → S2

Release Note Request (optional, but appreciated)
[Why is this notable]: Allows content authors using Canvas2D to recovery gracefully from a GPU process crash by listening for contextlost and contextrestored events.
[Affects Firefox for Android]: Yes
[Suggested wording]: Added support for contextlost and contextrestored events on HTMLCanvasElement and OffscreenCanvas to allow user code to recover from context loss with hardware accelerated 2d canvas.
[Links (documentation, blog post, etc)]: https://html.spec.whatwg.org/multipage/webappapis.html#context-lost-steps

relnote-firefox: --- → ?

I appreciate why this is being requested for uplift, but being that we're going into our final week of Beta and this has not had much Nightly bake time makes me very nervous. Is this strictly necessary for fixing bug 1882573 or a nice to have?

Flags: needinfo?(aosmond)

(In reply to Ryan VanderMeulen [:RyanVM] from comment #12)

I appreciate why this is being requested for uplift, but being that we're going into our final week of Beta and this has not had much Nightly bake time makes me very nervous. Is this strictly necessary for fixing bug 1882573 or a nice to have?

Strictly necessary. Additionally, if you don't want to take the uplift, then I think we need to back out bug 1886022. While bug 1886022 didn't introduce any bugs on its own, it did unearth some latent/hidden bugs elsewhere where we might freeze during GPU process recovery; this new fix should resolve the new cases of those freezes, in addition to resolving bug 1882573.

Flags: needinfo?(aosmond)
See Also: → 1888931

Comment on attachment 9393115 [details]
Bug 1887729 - Implement context lost/restored support for CanvasRenderingContext2D.

We've gotten some positive feedback from Google that this does appear to be showing the right trends in their telemetry data from Nightly builds with the fix. I'm approving this for 125.0b8 so we can get wider feedback sooner rather than later, but I will definitely appreciate prompt attention being paid to any regressions that come in due to the extremely limited timeframe we'll have to address them.

Attachment #9393115 - Flags: approval-mozilla-beta? → approval-mozilla-beta+
See Also: → 1888980
See Also: → 1889424

Added to the Fx125 relnotes.

Regressions: 1890077

MDN FF125 docs work for this can be tracked in https://github.com/mdn/content/issues/33090 (browser compat, release note, pages for the offscreen canvas events)

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

Attachment

General

Created:
Updated:
Size: