Babylon Gizmos and Performance

Greetings!

We are big fans of the Babylon Gizmos because with just a few lines of code we can give users precise controls over the transforms of assets in the scene. Incredible, inspiring stuff here.

One thing we are noticing, though, is that showing the Gizmos entails a fairly significant performance cost, especially if we are showing the Bounding Box Gizmo at the same time as showing the position and rotation axis gizmos. The reason we do this is because while drag and drop is good with the pointerdragbehavior, we also want users to be able to move assets along a specific axis for more precise control. So weā€™ve experimented with showing the Bounding Box Gizmo at the same time as the position and rotation gizmos, but even if these gizmos are showing up on one particular asset, this will take my FPS down from around 120 to 40. We are using the Gizmo Manager to enable a few gizmos at once.

Iā€™m wondering if this is the expected performance cost of showing multiple gizmos at once, or if we might be doing something wrong with our utillayer or gizmo manager?

Thanks for any help!

2 Likes

Adding @Cedric who will be able to have a look at the gizmo after the break.

1 Like

@gabrieljbaker

No, such performance drop is not expected. Can you repro this issue inside a PG? Do you get this drop when dragging a gizmo? Or simply adding them is the scene is enough?

1 Like

Will get this going in a PG as best as I can tomorrow, for sure!

We get this just by enabling them all at once in the GizmoManager and then attaching the GizmoManager to a mesh.

1 Like

Hi @Cedric , sorry so late in responding here. Weā€™ve actually been quite in the weeds trying to figure out what is up with our code that might be causing our Gizmos to cause such a performance drop, especially given that we canā€™t really repro it very well on any playground.

We do notice on a PG like this: https://playground.babylonjs.com/#4TBMBR#33 that when you add gizmos, the ā€œabsolute fpsā€ in the inspector gets progressively worse the more that get layered on there, while the general fps stays static. In our build, though, both the absolute FPS and the FPS go down dramatically. We also see in Inspector that the ā€œFrame totalā€ metric shoots from 4 to 14 as soon as the gizmos are loaded in the scene. Iā€™m actually not entirely clear what that metric means, but it doesnā€™t look good when it goes up, heh. Any insight there either?

Are there things relative to the Utility Layer that we should be looking at perhaps?

Thanks again!

Some explanation on the absolute FPS vs FPS vs Frame total:
A frame doesnā€™t take 16.6ms to compute. Itā€™s usually less than that. For example, the pointed PG takes 1.4ms to compute a frame on my PC. 1000ms/1.4ms = ~700 frames (absolute FPS). Thatā€™s the maximum number of frames that can be computed and displayed when the VSync is disabled.
But because VSync is on in the browser, the framerate is maxed at 60. The ā€˜paddingā€™ time is named inter-frame in the inspector. Itā€™s time spent waiting.
So, itā€™s a normal behavior to see the frame total time to increase when you add new things (new meshes, gizmos, more animation, physics,ā€¦) and as a consequence, the absolute fps will also drop. As long as itā€™s greater than 60FPS, the FPS will not decrease.

1 Like