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

WebGL context lost handling #1091

Open
OFFTKP opened this issue Aug 10, 2024 · 2 comments
Open

WebGL context lost handling #1091

OFFTKP opened this issue Aug 10, 2024 · 2 comments

Comments

@OFFTKP
Copy link

OFFTKP commented Aug 10, 2024

I see that emscripten_set_webglcontextlost_callback is called but the SUSPENDED event is TODO on html

It would be nice to have

@floooh
Copy link
Owner

floooh commented Aug 11, 2024

Have you actually seen a WebGL context-lost in the wild yet? The only situation where I could manage to get one was on Safari because of a bug in ANGLE Metal backend (see https://issues.chromium.org/issues/355605685).

There's not a lot of useful things sokol-app and sokol-gfx could do when the WebGL context has been lost. At best, sokol-app could create a new WebGL context, and send an event to the app code. The app code then needs to completely tear down and re-initialize sokol-gfx and everything created through sokol-gfx.

I'm open for better ideas though :)

@OFFTKP
Copy link
Author

OFFTKP commented Aug 12, 2024

Yes, but I can't reproduce it reliably. Usually when I have multiple tabs open, and the one that has the webgl context is in the background, or if I am in a different workspace.

Other than that you can run this to trigger it thankfully:
document.getElementById("canvas").getContext("webgl").getExtension("WEBGL_lose_context").loseContext();

I think what you suggested would be nice, I don't have any better ideas personally but not very familiar with webgl

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

No branches or pull requests

2 participants