Discussion about this post

User's avatar
Steve's avatar

I love the battle mechanic.

Expand full comment
bxxsxx's avatar

I could reproduce the performance issues, they just appeared after a while, even without walking around. Causing (temporary) frame drops, for example by resizing/minimizing, seems to speed up reproduction.

Digging deeper, I narrowed the slowdown I observed down to this logic in the Kaplay library:

https://github.com/kaplayjs/kaplay/blob/master/src/app/app.ts#L373

fixedUpdate is getting called in a loop there, but under normal circumstances should run about once per frame (every 1/50 secs). If frames are drawn <50fps, it will be called a few times to catch-up, say 2 or 3 times. However, when reproducing the slow down, it was getting called hundreds of times per frame, and again each subsequent frame.

The problem is that `fixedAccumulatedDt` keeps increasing over time. It's not properly reset after doing the catch-up, so on the next frame it's going to do all the same catch-up again. The offending line is this, I think:

https://github.com/kaplayjs/kaplay/blob/master/src/app/app.ts#L385

`accumulatedDt` decremented a (small) fixed amount, regardless of the catch-up done. Next frame the remainder is added to fixedAccumulatedDt again, growing it indefinitely:

https://github.com/kaplayjs/kaplay/blob/master/src/app/app.ts#L370

Expand full comment
7 more comments...

No posts