Freeze and Unfreeze - Babylon React Native

Hello,
I am using the below two functions to freeze and unfreeze the mesh materials in order to improve the FPS. However, on freezing the mesh I don’t see any gain in FPS. However, as per the document the below methods should help optimize the scene and reduce the load on CPU which isn’t the case. Could you please help me understand what I am doing wrong here?

const freeze = () => {
scene
?.getTransformNodeByName(‘RootNode’)
?.getChildMeshes()
.forEach((meshes) => {
meshes.material?.freeze();
meshes.doNotSyncBoundingInfo = true;
meshes.freezeWorldMatrix();
meshes.cullingStrategy =
AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION;
});
};

const unfreeze = () => {
scene
?.getTransformNodeByName(‘RootNode’)
?.getChildMeshes()
.forEach((meshes) => {
meshes.material?.unfreeze();
meshes.doNotSyncBoundingInfo = false;
meshes.unfreezeWorldMatrix();
meshes.cullingStrategy = AbstractMesh.CULLINGSTRATEGY_STANDARD;
});
};

pinging @cedric or @bghgary

cc @ryantrem

I don’t think we’ve tried this yet. Performance in Babylon Native and Babylon React Native is still a WIP.

That said, freezing the meshes should result in less work as it runs less calculations per frame. What FPS are you getting before and after? How complex is the scene? What platform are you running on?

I am getting the same FPS before and after, that is around 4-7. I just have a model loaded in my scene. The model has 941 meshes. The platform is Android. I have added touch based rotation. On freezing the rotation doesn’t work (as it is supposed to) but the FPS remains the same.

Depending on what is the bottleneck, freezing may not help much. We certainly still have performance issues. Would it be possible to share your model? Also, how well does the model perform in the mobile browser on the same device (e.g. load the model with the sandbox)?

Hey,
In mobile browser as well as in PC browser I am getting a constant 50+ FPS while in native I am getting a FPS sub 10. Unfortunately, I won’t be able to shared the model. The model consist of more than 900 + meshes. On trying with a different model with a relatively less number of meshes (100 odd messhes), I was getting FPS more than 50 in native.

Ok, thanks. We have an issue for perf Understand performance characteristics · Issue #499 · BabylonJS/BabylonNative (github.com). Feel free to add info about what you are seeing to that issue. We still have work to do here. :slight_smile:

1 Like