ActionManager performance leak

Hey guys,

I’m new to babylon.js (4.1) so this question might be stupid.
As soon as I’ve created an ActionManager for my Mesh, the performance of my app went south.
On mouse move over the canvas, the frame rate would drop to 0 without even registering an action.
Chrome’s Profiling tool shows that “SubMesh._intersectTriangles” takes a lot of time.
Commenting the ground.actionManager = new ActionManager(this.scene); fixes the issue.


Hello and welcome!

This is probably expected if your mesh is complicated. When there is an action manager on a mesh, the system will cast rays to do picking to see if you are hovering your mesh for instance.

Depending on the Action Trigger, I would recommend either setting the mesh.isPickable = false or use a simplified version of your mesh for the Action manager

Maybe reproducing the issue in the Playground could help us give you more hints

I only have one ground Mesh on the screen with GridMaterial on it.
If you comment out
ground.actionManager = new BABYLON.ActionManager(scene);
the framerate goes back to normal

Your ground has 2millions faces:)

Same experience, big optimization:


Thanks a lot.
I didn’t understand what divisions is used for so i thought it should match the grid

@Deltakosh, this is really interesting about the Action Manager, and I’m a bit curious to hear more about this.

I have a simple sphere in my scene, but I’m not noticing that with isPickable = true and an ActionManager with an onPickTrigger, my scene is actually pretty laggy when I have the cursor over the sphere and I move the camera forward.

Are there performance benefits to getting a picked mesh with a ray (like here: instead of using an ActionManager? I don’t really need any hover events, because I just want the onPick event - is the ActionManager or isPickable causing a detection of hover events and causing the lag?

Yes hover is probably the culprit.
You can turn it off per mesh with mesh.enablePointerMoveEvents = false

1 Like

Yes, absolutely was! Grateful for the quick response here. Prototype rebuild of is progressing… :slight_smile: