Using 'camera-access' feature in WebXR causes context loss and flickering screen issues

I’ve been having some trouble with my WebXR project where adding the optional ‘camera-access’ feature has been causing a few issues. It crashes pretty frequently where I receive a WebGL context lost error. Sometimes it will lose context in the first 10 seconds or sometimes it takes a minute or so. Additionally, I occasionally get these WebGl errors, though I’m not sure if they’re relevant to the context loss issues:

[.WebGL-0x20975cd00]GL ERROR :GL_INVALID_OPERATION : DoBeginSharedImageAccessCHROMIUM: Unable to begin access
[.WebGL-0x20975cd00]GL ERROR :GL_INVALID_OPERATION : DoEndSharedImageAccessCHROMIUM: shared image is not being accessed

The screen also usually starts flickering grey every number of seconds when this happens.

Whenever I remove the ‘camera-access’ option I get no issues.

I’ve created a very simple playground replicating how I’m initialising it in my project and have been able to replicate the issue here. I’m not sure if there is a better way to set this feature up or if there’s a bug with using camera-access.

The device I am using is a Pixel 6 Pro, Android Version 14. I haven’t been able to replicate it on my other Android device though, so there’s a possibility that it’s a device-specific issue.

UPDATE: I managed to replicate it on another device - Xiaomi 13T, Android 14. I’ve also made a simpler playground where I can replicate it, its just using the createDefaultXRExperienceAsync helper and adding camera-access.

1 Like

I can’t reproduce that on my device, but of course I believe you that it is failing on yours. You are actually not using babylon in your code. All you are doing is asking the feature to be enabled. So everything happening here is out of our control - we don’t add the feature to the render loop, we don’t consume the webgl texture generated by the browser.

What I do wonder is - you are enabling a feature, but you are not using it. Have you tried using the babylon feature for that? Does it fail when you use the feature?

Yep, it fails when I use the feature, not just enabling it.
It works perfectly using this barebones example though (not using Babylon): Barebones WebXR Camera Access

I’m wondering how enabling or using the camera within a basic setup in the Babylon project is failing often, but using it any other way, like the test above, isn’t. Is there something else happening with Babylon under the hood I might not be aware of? Or is there somewhere I should be looking in particular to try and resolve it?

Babylon doesn’t do any magical things under the hood We are simply calling the WebXR API. It might be a combination of reference space and feature enabled. But it is hard to say that, especially since I can’t reproduce this on 4 different devices.
Can I ask what version of browser are you using to reproduce this? standard chrome?

Ok I see. Yeah it’s strange, I can’t replicate it on one of my devices, but the other two I can.
I am just using the standard chrome on both devices, the versions are 126.0.6478.122 and 125.0.6422.72.

Actually after running the Barebones WebXR demo I sent above a few more times, I’ve been able to replicate a crash after an hour or so of running the app. So might be a bug with the WebXR module after all, I’ll have to keep investigating.

1 Like

btw, we have logged the issue with Chromium here.

if anyone else experiences losing the WebGL context (or simply WebXR restarting) while using camera-access, please comment on this thread. it would be good to understand the extent of this issue and how many devices it effects.

1 Like

thanks a lot for the follow up!
Would be great to know which devices are failing for future reference.

I can say that none of the samsung devices I am using are failing (S8, S10 and S22)