-
Notifications
You must be signed in to change notification settings - Fork 321
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
Context restoration #7662
Context restoration #7662
Conversation
4ce2d23
to
9f8464a
Compare
QA: 🟢 |
That log is quite strange. @hubertp, you pressed Ctrl+Alt+Shift+X once after the machine awoke from suspend, right? The result looks unlike anything I've seen on the machines I've tested. Would you mind testing synthetic context loss and restoration by pressing Ctrl+Alt+Shift+X twice, without any suspend? I'd like to compare the logs. |
No, I didn't press anything. I just suspended and woke it up. @kazcw Same manifestation without suspend: |
Ah, ok. The error ( I've tested this PR on several devices in order to try to reproduce this issue, and to check for any other OS/driver-specific problems. My findings:
As pertains to this PR, there are no observed cases of receiving the @hubertp, I'm not sure what to make of the issue you've observed. It looks like on your device the browser isn't giving us a |
I believe we only need it to work in the Electron app. The fact that it does or does not work in any other browser does not matter much. |
This is a big change, and it should not make any regressions (before it, we haven't handled context losses anyway), so I propose to merge it ASAP, and make another issue about losing context on some machines. |
Add support for recovering from GL context loss. When the context is restored, the loading spinner is shown until shaders finish recompiling. [vokoscreenNG-2023-08-25_09-39-11.webm](https://github.com/enso-org/enso/assets/1047859/cfa90ec5-72a1-41e6-bafa-177fa5e85fb2) *While the context is missing, the loading spinner is rendered in the 0% state. (This condition will not normally be observed, except momentarily, as the browser should restore the context immediately if it is lost while the page is visible.) When we receive a new context, the spinner switches to the 90% state until restoration completes. Restoration is fast, as we don't need to do much work except recompiling shaders.* # Important Notes - A new debug hotkey, Ctrl+Alt+Shift+X, causes context loss for testing. Pressing it a second time causes context restoration. - `Texture` is still a CPU-bound texture. It now uses the "immutable" `texStorage/texSubImage` API, which is a ["preferred alternative"](https://registry.khronos.org/webgl/specs/latest/2.0/#3.7.6) to the `texImage` API because it can be more efficient. - The type for texture uniforms is now `Uniform<Option<Texture>>`. Texture uniforms are decoupled from the context. - A new `ContextLost` error type can be returned by functions that cannot complete if the context is lost. - Fix some crashes that could occur when context was lost. - Clarify ownership of some rendering-related types: Externalize, and where possible eliminate, `Rc/RefCell`s.
Pull Request Description
Add support for recovering from GL context loss. When the context is restored, the loading spinner is shown until shaders finish recompiling.
vokoscreenNG-2023-08-25_09-39-11.webm
While the context is missing, the loading spinner is rendered in the 0% state. (This condition will not normally be observed, except momentarily, as the browser should restore the context immediately if it is lost while the page is visible.) When we receive a new context, the spinner switches to the 90% state until restoration completes. Restoration is fast, as we don't need to do much work except recompiling shaders.
Important Notes
Texture
is still a CPU-bound texture. It now uses the "immutable"texStorage/texSubImage
API, which is a "preferred alternative" to thetexImage
API because it can be more efficient.Uniform<Option<Texture>>
. Texture uniforms are decoupled from the context.ContextLost
error type can be returned by functions that cannot complete if the context is lost.Rc/RefCell
s.Checklist
Please ensure that the following checklist has been satisfied before submitting the PR:
Scala,
Java,
and
Rust
style guides. In case you are using a language not listed above, follow the Rust style guide.
./run ide build
.