Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle WebGL context loss/restore events in WebGL renderer. #4075

Merged
merged 2 commits into from
Aug 31, 2022

Conversation

kenrussell
Copy link
Contributor

@kenrussell kenrussell commented Aug 26, 2022

If the context is restored within a brief period of time (3 seconds),
recreate members dependent on WebGL state, and fire onRequestRedraw to
the renderer's listeners.

Handle changes to the char atlas better in the demo client.

Tested in Chrome Canary on macOS by running the demo in one window,
and visiting the internal URL about:gpucrash in another window. The
terminal now recovers and redraws properly.

@kenrussell
Copy link
Contributor Author

Note to maintainers: this was originally developed in the context of VS Code's embedded terminal, attempting to make it more robust. It's expected that context losses would be rare, but they can happen due to issues out of the browser's control.

If this PR is accepted, I'd be interested in rolling forward VS Code's xterm.js reference and upstreaming the needed patch there to respond to the new onNeedsRedraw event.

@kenrussell kenrussell force-pushed the context-restoration branch from a27d32a to 9857457 Compare August 27, 2022 00:01
@kenrussell
Copy link
Contributor Author

@Tyriar would you be able to review this? It improves robustness of the Terminal in the face of external graphics issues.

@kenrussell kenrussell force-pushed the context-restoration branch from 9857457 to 23e0f3a Compare August 29, 2022 21:04
Copy link
Member

@Tyriar Tyriar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Idea looks good overall 👍. Also I didn't know about about:gpucrash, pretty handy!

addons/xterm-addon-webgl/src/WebglRenderer.ts Outdated Show resolved Hide resolved
addons/xterm-addon-webgl/src/WebglRenderer.ts Show resolved Hide resolved
addons/xterm-addon-webgl/src/WebglRenderer.ts Outdated Show resolved Hide resolved
@Tyriar Tyriar added this to the 5.0.0 milestone Aug 30, 2022
@Tyriar Tyriar self-assigned this Aug 30, 2022
If the context is restored within a brief period of time (3 seconds),
recreate members dependent on WebGL state, and fire onRequestRedraw to
the renderer's listeners.

Handle changes to the char atlas better in the demo client.

Tested in Chrome Canary on macOS by running the demo in one window,
and visiting the internal URL about:gpucrash in another window. The
terminal now recovers and redraws properly.
@kenrussell kenrussell force-pushed the context-restoration branch from 23e0f3a to 9459553 Compare August 31, 2022 02:49
@kenrussell kenrussell changed the title Handle WebGL context loss/restore events in WebGL addon. Handle WebGL context loss/restore events in WebGL renderer. Aug 31, 2022
@kenrussell
Copy link
Contributor Author

Thanks for your review! All feedback addressed. It's much simpler and completely self-contained now!

Copy link
Member

@Tyriar Tyriar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks!

@Tyriar Tyriar merged commit 151a5d8 into xtermjs:master Aug 31, 2022
@kenrussell kenrussell deleted the context-restoration branch August 31, 2022 17:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants