Babylon heavy performance lose after exiting XR

The mandatory sample: and in this case the issue is not as easy to be described so I’ve preferred to record a video:

By the way, it has the same problem in several platforms, not only Windows or Chrome, including other browsers and devices (Quest 2).
Thank you in advance.

adding @RaananW


The issue here is the mouse picking of this complex scene. Babylon runs a picking function on each frame, which uses your current mouse position over the canvas. when dealing with complex meshes it might take quite some time, because it runs picking against the actual triangle of each mesh it collides with (or better - with its bounding box/sphere). To eliminate this you can set each mesh you loaded to be not-pickable (or at least the more complex meshes). isPickable is set to true per default so you will need to actively set it to false.
Now, saince you are using the emulator, the mouse events are still executed on the canvas. this is why the FPS drops even when you are in XR. when outside of the emulator you won’t have the mouse issue, BUT you will still experience the same behavior when moving your xr controllers. that it because the xr controllers are emulating the pointer system! And they technically work the same as a mouse, but in the 3D space (as opposed to the mouse that works on the 2D canvas and always points “forward”). To disable this behavior you can detach the pointer system (which is part of the default xr experience), or, just like in the case of the mouse, make all meshes not-pickable (line 9, a very simple approach that you might want to adjust in your scenes):

Hill Valley in WebXR using Babylon.js | Babylon.js Playground (

Sorry, I think that my video was not clear enough, I don’t care about the initial performance with the same geometry where Babylon is making great work.

The problem is that AFTER you enter and exit from WebXR the performance is much worse than in the initial case, it seems that entering into WebXR mode makes something dirty in the pick system since if I disable picking in all the objects this behavior is no longer happening.

I am probably not detaching the control from the canvas (which can be seen by the fact that the mouse is still influencing the canvas), and then re-attaching. I’ll look into that.


Updating here - this was solved in this PR - [XR] detach and attach non-xr camera by RaananW · Pull Request #10950 · BabylonJS/Babylon.js (

1 Like