Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Profile performance #13

Open
46bit opened this issue Aug 27, 2020 · 1 comment
Open

Profile performance #13

46bit opened this issue Aug 27, 2020 · 1 comment
Labels
enhancement New feature or request in progress

Comments

@46bit
Copy link
Owner

46bit commented Aug 27, 2020

RTT is already quite resource intensive and unhappy in a single thread. Ideally it would use a Web Worker for state updates and rendering, but not many browsers support writing to a canvas from a Web Worker (and passing data from a Web Worker to the main thread is surprisingly slow when trying to do 30-60fps.)

So instead I should look at where CPU cycles are going. Maybe I won't fix it but it would be great to have data on what is expensive and what is cheap.

@46bit 46bit added the idea label Sep 3, 2020
@46bit 46bit added enhancement New feature or request in progress and removed idea labels Oct 3, 2020
@46bit
Copy link
Owner Author

46bit commented Oct 3, 2020

Started in a branch: https://github.com/46bit/rtt/tree/profile-performance. This already led me to switch navmesh (pathfinding) libraries: 535e37a.

@46bit 46bit mentioned this issue Oct 4, 2020
46bit added a commit that referenced this issue Oct 5, 2020
I've been getting frustrated by the jittery, difficult performance
that RTT has shown recently. I already did some profiling in the
`profile-performance` branch to start tracking it down, and that led
to a major pathfinding improvement. This is all part of #13.

To help track things down I added the THREE.js Stats visualiser [1].
To my complete surprise, I was not using `requestAnimationFrame` to
schedule updates. Instead I was using `setTimeout` and aiming for
30fps.

I think I found strange `requestAnimationFrame` behaviour when frames
regularly took a long time to compute, but that is no longer the case.
Switching back to `requestAnimationFrame` shows an enormous
improvement in game experience! :)

[1] https://www.npmjs.com/package/stats-js
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request in progress
Projects
None yet
Development

No branches or pull requests

1 participant