You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
XR framebuffer creation panics when setting up texture #24083
When running the three.js webvr rollercoaster example in immersive, I get GL errors when we try to bind the texture that we've just created as part of creating an XRWebGLLayer. My theory is that the webgl commands end up being interleaved with other GL processing from webrender in such a way that the state we rely upon is messed up. I have a patch to move these operations to run in the webgl thread in an atomic unit as part of a single WebGLCommand, and this makes the GL errors go away.
Hmm, that shouldn't be happening. There shouldn't be any difference between issuing the WebGL commands directly in the webgl thread, compared to issuing them in the script thread and sending them to the webgl thread for execution.
There is a difference when the webgl thread is shared with the webrender thread - any synchronous GL API (like CreateTexture) will cause the current set of messages to be processed, allowing arbitrary WR GL calls to execute before the next set of GL messages gets processed.
The real underlying bug may be that there is some GL code in WR or webxr that modifies the state and doesn't restore what was there before. It's hard to tell.
Ah, that makes sense. WebGL maintains a lot of state that assumes it's the only owner of the GL context. This is a deeper problem than just XR initialization, any user WebGL code could hit the same problem.
@Manishearth I attempted to remove any references to StartXRFrame hours ago. Are you applying the right patch? StartXRFrame and EndXRFrame did not actually do anything, so they can be ignored.
I'm still concerned about using this approach. There's a lot of state that's kept in sync between webgl and gl, so doing anything where we execute GL commands directly rather than going via WebGL seems like a recipe for getting out of sync.
My hypothesis about why the panic occurs was wrong - the bound texture remains bound when we get a GL error executing the glTexImage2D - I'm pretty sure it's because we're hardcoding gl::RGBA, whereas the code to decide what format to use for draw buffer in rust-offscreen-rendering-context is more complex and uses different values for GLES than GL.
I verified that immersive mode works fine with the existing code on HoloLens if the texture is initialized with constants::RGB and the framebuffer attachment complete checks are updated to accept that value. I'm writing a patch that should allow this to work on all platforms.
Activity
asajeffrey commentedon Aug 28, 2019
Hmm, that shouldn't be happening. There shouldn't be any difference between issuing the WebGL commands directly in the webgl thread, compared to issuing them in the script thread and sending them to the webgl thread for execution.
asajeffrey commentedon Aug 28, 2019
IRC chat https://mozilla.logbot.info/servo/20190828#c16574986
jdm commentedon Aug 28, 2019
There is a difference when the webgl thread is shared with the webrender thread - any synchronous GL API (like CreateTexture) will cause the current set of messages to be processed, allowing arbitrary WR GL calls to execute before the next set of GL messages gets processed.
jdm commentedon Aug 28, 2019
The real underlying bug may be that there is some GL code in WR or webxr that modifies the state and doesn't restore what was there before. It's hard to tell.
asajeffrey commentedon Aug 28, 2019
Ah, that makes sense. WebGL maintains a lot of state that assumes it's the only owner of the GL context. This is a deeper problem than just XR initialization, any user WebGL code could hit the same problem.
jdm commentedon Aug 28, 2019
Indeed :/
jdm commentedon Sep 4, 2019
Patch that needs some cleaning up:
Details
Manishearth commentedon Sep 4, 2019
The servo patches don't apply, there is no StartXRFrame in webgl_thread.rs
Is there a second commit missing here?
jdm commentedon Sep 4, 2019
@Manishearth I attempted to remove any references to StartXRFrame hours ago. Are you applying the right patch? StartXRFrame and EndXRFrame did not actually do anything, so they can be ignored.
Manishearth commentedon Sep 4, 2019
Ah, i was using the patches from the issue.
Manishearth commentedon Sep 4, 2019
Applying the above patch gives me a malformed patch issue, on linux
The
@@offset numbers are all wrong, was this patch hand edited? I'll hand-edit it back and see what i getManishearth commentedon Sep 4, 2019
Managed to apply it
asajeffrey commentedon Sep 4, 2019
I'm still concerned about using this approach. There's a lot of state that's kept in sync between webgl and gl, so doing anything where we execute GL commands directly rather than going via WebGL seems like a recipe for getting out of sync.
jdm commentedon Sep 16, 2019
My hypothesis about why the panic occurs was wrong - the bound texture remains bound when we get a GL error executing the glTexImage2D - I'm pretty sure it's because we're hardcoding gl::RGBA, whereas the code to decide what format to use for draw buffer in rust-offscreen-rendering-context is more complex and uses different values for GLES than GL.
[-]Move XR framebuffer creation to webgl thread[/-][+]XR framebuffer creation panics when setting up texture[/+]jdm commentedon Sep 18, 2019
I verified that immersive mode works fine with the existing code on HoloLens if the texture is initialized with constants::RGB and the framebuffer attachment complete checks are updated to accept that value. I'm writing a patch that should allow this to work on all platforms.
Auto merge of #24242 - jdm:xr-webgllayer-format, r=asajeffrey
Auto merge of #24242 - jdm:xr-webgllayer-format, r=<try>
Auto merge of #24242 - jdm:xr-webgllayer-format, r=asajeffrey
Auto merge of #24242 - jdm:xr-webgllayer-format, r=asajeffrey
Auto merge of #24242 - jdm:xr-webgllayer-format, r=<try>
Auto merge of #24242 - jdm:xr-webgllayer-format, r=asajeffrey,nox
Auto merge of #24242 - jdm:xr-webgllayer-format, r=asajeffrey,nox
Auto merge of #24242 - jdm:xr-webgllayer-format, r=asajeffrey,nox