Swapping Camera randomly causes crashes when used with XRLayers

Hello all. I’m working on a project in A-Frame where you have constellations in the sky you can look up and tap, and then flip the camera to take a selfie. This works sometimes, but often crashes, saying “Oops, something went wrong”. I’ve attached the only logs i’ve been able to get related to the crash.

I am removing and adding the attributes to stop and start AR to flip the camera, and i’ve tried with and without xrweb but it makes no difference. It seems to be related to the xrlayers and the layercontroller catching null but i don’t know why it only happens 70% of the time. I’ve also tried using scene.pause() and scene.play() before and after restarting everything, but only seemed to be a slight improvement, if any.

Any help would be awesome, and let me know if i can provide any more useful information! Thank you!

Update: I have temporarily solved this by using XRWeb and disabling world tracking and not XRLayers, which works in our specific situation, but still curious if there’s something about adding and removing xrlayers from the scene that causes issues?