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

Improve robustness of Skia OpenGL renderer in case of GL context loss #3022

Merged
merged 2 commits into from
Jun 30, 2023

Conversation

tronical
Copy link
Member

Gracefully handle a loss before destruction time and reduce the chance of hide() failing to those applications that use a rendering notifier (only those might actually be interested in this error anyway).

In the unlikely-yet-seen-before scenarion that we've lost the OpenGL context and can't make it current anymore in the destructor,
gracefully conveny this crucial information to Skia and don't panic.
Only attempt to make the GL context current if we have a rendering notifier callback.

The activation may still fail, and the API will still report it though.
@tronical tronical requested a review from ogoffart June 30, 2023 05:59
self.ensure_context_current().expect("Skia OpenGL Renderer: Failed to make OpenGL context current before deleting graphics resources");
// In the event that this fails for some reason (lost GL context), convey that to Skia so that it doesn't try to call
// glDelete***
if self.ensure_context_current().is_err() {
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't we somehow log this as an error?

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not sure. We could print something to stderr, but the actual error (context loss) happened a lot earlier.

Copy link
Member Author

Choose a reason for hiding this comment

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

Differently put: We could also always call abandon() - the resources will be deleted anyway by the context that we own. It's just us playing nice :)

@tronical
Copy link
Member Author

(I'll merge this given circumstances, but happy to continue the discussion how to fine-tune this)

@tronical tronical merged commit cb6ba2f into master Jun 30, 2023
25 checks passed
@tronical tronical deleted the simon/skia-gl-robustness branch June 30, 2023 06:21
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