When exiting AR through the native back button on Android and an anchor is removed, the page crashes.
Anchor System Android Crash | Babylon.js Playground (babylonjs.com)
I have also tried adding a delay before removing the anchor, but it still crashes.
It doesn’t crash if I call xr.baseExperience.exitXRAsync(). However, since there’s no way of preventing the user from using the native back button, I wouldn’t call that a solution.
I can say that I can reproduce this, but this seems like a browser bug. anchor.remove does nothing other than calling the native anchor.delete() function.
This is a changed behavior, as anchors used to work very well. What I can say is that in general, there is no real need to remove anchors after a session has ended, as webxr anchors are non-persistent.
My temp solution (until I fully understand what is going on) is this - [XR] Change default behavior for anchors by RaananW · Pull Request #15261 · BabylonJS/Babylon.js (github.com)
With the flag the session doesn’t crash when it ends.