Significant recast.js performance degrade from cdn version to preview

Hi @Cedric,

I notice a significant increase of computation time when calling new recast.NavMesh().build() using preview version of recast.js. I can reproduce the issue in the following PGs.

There is only 2-3 seconds delay when using

Exactly same code but point to You can make your coffee and come back later:

The problem is not noticeable if the “ground” mesh has small size like width: 16, height: 16.

It might be related to the way memory gets allocated. I’ll do a test before end of week!


I can repro but it’s related to the flag I was thinking of. This is weird because it’s the same compilation flags as before. I’m investigating …


This is getting interesting!
When I get weird things, I usually check if anyone experienced the same issue.
I got to this GitHub issue:

So, I naively tried with -O0 build … and it’s 10 times faster than -O3. (output .js is 3Mb instead of 700Kb btw)
So, Emscripten is definitely doing some crap optimization because of some code. I need to find what’s causing that now.

1 Like

Buiding with C++ 17 fixed it! It might even be a little faster than previous version and build size is also smaller.
I’m doing the PRs now …

1 Like

I spoke too fast. C++ flag is not enough. still digging …

PR recastjs with embedded WASM by CedricGuillemet · Pull Request #11129 · BabylonJS/Babylon.js · GitHub