Implement context loss for CanvasRenderingContext2D
Categories
(Core :: Graphics: Canvas2D, enhancement)
Tracking
()
People
(Reporter: aosmond, Assigned: aosmond)
References
Details
(Keywords: dev-doc-complete)
Attachments
(1 file)
48 bytes,
text/x-phabricator-request
|
RyanVM
:
approval-mozilla-beta+
|
Details | Review |
Assignee | ||
Comment 1•10 months ago
|
||
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.
Assignee | ||
Comment 2•10 months ago
|
||
This should allow us to reach parity with Chrome in these recovery scenarios and completely fix bug 1882573.
Assignee | ||
Updated•10 months ago
|
Assignee | ||
Comment 4•10 months ago
|
||
(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.
Comment 5•10 months ago
|
||
Backed out for causing failures at test_accelerated_canvas_context_loss.html.
Backout link: https://hg.mozilla.org/integration/autoland/rev/f6f6a567ed1c4cf5c46b4dc136cff4941df68a01
Push with failures: https://treeherder.mozilla.org/jobs?repo=autoland&resultStatus=testfailed%2Cbusted%2Cexception%2Cretry%2Cusercancel&revision=40fa8e4b06c85e9e241da6e56b62a0b2bde7427c
Failure log: https://treeherder.mozilla.org/logviewer?job_id=452619047&repo=autoland&lineNumber=2396
Assignee | ||
Comment 6•10 months ago
|
||
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.
Comment 8•10 months ago
|
||
bugherder |
Assignee | ||
Comment 9•10 months ago
|
||
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
Assignee | ||
Comment 10•10 months ago
|
||
I manually verified on the latest nightly.
Assignee | ||
Updated•10 months ago
|
Assignee | ||
Updated•10 months ago
|
Assignee | ||
Comment 11•10 months ago
•
|
||
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
Comment 12•10 months ago
|
||
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?
Assignee | ||
Comment 13•10 months ago
•
|
||
(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.
Updated•10 months ago
|
Comment 14•10 months ago
|
||
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.
Updated•10 months ago
|
Comment 15•10 months ago
|
||
uplift |
Comment 17•9 months ago
|
||
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)
Description
•