[SOLVED] How does Playcanvas use AmmoJS?

So it’s clear that Playcanvas uses AmmoJS for everything physics related, but it seems like it uses it for non-physics related operations as well. I’m wondering if PC uses some fast linear math operations or other under-the-hood AmmoJS operations? Here’s my problem-

I’ve created projects where none of my code does anything related to physics yet when I uncheck the ‘Enable’ in the Physics options my app runs 10x slower. Everything functions as expected, it’s just really laggy when the camera moves around.

Looking at the GPU thread in my browser console I’ve found that the ‘compose’ step takes the entire 16ms when physics isn’t enabled! How is this possible when I’m not using anything related to physics in my projects? I really want to be able to remove my dependency on AmmoJS because it’s huge and it’s not particularly useful for this project.

I was also considering putting together a minimal build of AmmoJS as a possible solution, but I don’t know which functions are used by Playcanvas. I did a code coverage test and found that my app uses pretty much none of the code in AmmoJS (as expected), but I still haven’t been able to hone in on the exact functions.

Anyhow, I would love some feedback from someone who has dealt with this. Thank you!

Ammo is only used for physics. I haven’t encountered the issue where just enabling it causes massive slowdown.

Does this happen on a blank project?

1 Like

So I checked again with the project that was having the issue (a few months ago) and it seems like there is no longer an issue. I have completely removed the ammojs dependency and the render time seems to be stable at <16ms as expected. I will let you know if I come across the issue again. Thanks!

1 Like