Does linkWithMesh have serious performance issues on mobile devices?

Hi!

I’m using BabylonJS to create an application targeting mobile devices. In my case, that’s iPad and Android Tablets. When using linkWithMesh on a single TextBlock, the performance will drop significantly.

To test it, you can use an official BabylonJS demo, like the GUI Demo: https://www.babylonjs-playground.com/#3VMTI9#126

In line 88, 126 and 137 linkWithMesh is used. In the link above they already should be commented. If you enable one of them (I suggest using the one in line 126 oder 137), the FPS will drop significantly. In my case from 50-55 FPS to 40 FPS. I’ve recorded a little video showing the problem: YouTube

Is there anything I can do to not have that drop? The application I’m creating is in need of having TextBlocks linked to meshes.

Thanks!

I did a perf analysis and nothing seems wrong:
image

Can you run a perf analysis with and without the linkToMesh on your device?

Did you do a perf analysis for both cases (with and without linkWithMesh)?

On iPad, I did both, with and without linkWithMesh. If you take a look at the upper graph, you can see clearly, that the frame times are longer, resulting in lower FPS. When changing back to the usage without linkWithMesh, the frame times are shorter, resulting in higher FPS.

However, I’ve hard time figuring out, why exactly that happens, since within the frames different codepaths are executed. So you’d need to check it frame by frame.

I’ve uploaded the perf recording from Safari here: https://raubi.eu/safari-perf.zip You can import them to the Safari Web Dev Tools.

It only seems, that this issues persists on an iPad Safari, and not on Android tablets.

I have no mac :slight_smile:
Can you show me the hot path on a specific frame? Which function is the most expensive when link is enabled

That’s hard to say, because the frame’s executed code path change heavily from frame to frame. Without having much knowledge about the internals of BabylonJS, it’s hard to provide the necessary info needed.

However, I used linkWithMesh only for positioning a TextBlock in the middle of a mesh. I’ve implemented the same functionality now without using linkWithMesh (by basically calculating the position by myself), which leads to having a performance increase of 10-12 FPS resulting almost 30 FPS now (which has been 10-12 before).

The think is that I cannot repro which does not help
The linkWithMesh should not be expensive as it only runs that code:

It has a lot of performance problems on Firefox.
https://www.babylonjs.com/demos/gui/

1 Like

Can you tell us more? What is slowing things down? Maybe a profile?

I’m not sure if this helps, but the GUI demo does seem to run at about 30FPS on Firefox (docked to one corner of a 4k screen) and I got this flame graph from the profiler:

I don’t know anything about Babylon internals but the updateDynamicTexture method seems to be taking up a fair chunk of the frame.

Edit: I forgot to add that I’m on a work laptop with only an integrated GPU so maybe it’s a Firefox optimisation issue. For the record I get between 45-50FPS on Chrome for the same demo.

This is totally an issue with ff :smiley: Updating the dynamictexture takes TOOOOOO long

This is something that FF should be interested by (if you want to file a bug on their db)


This is Google. fps Stability 60
image
This is Firefox.
The hardware configuration is i7 6700 + GTX 1060 6g
I’ve tested it with my partner computer; the performance difference is 10-20fps, and the rotating camera can’t reach 60fps in Firefox; this small demo can’t reach 60fps is a very strange problem.

yes this is a good candidate to file a bug for Firefox