filbs111 / box2d-learning

0 stars 0 forks source link

improve framerate on mobile #20

Closed filbs111 closed 7 years ago

filbs111 commented 7 years ago

runs at 4fps on elephone s2! find out whether due to rendering or mechanics (can use dat.gui to toggle graphics rendering on/off) likely source of slowness : rendering (canvas), mechanics (box2d). if graphics the problem, #1 hopefully improve this (webgl), or svg renderer if more convenient. if mechanics is the problem, web worker?

filbs111 commented 7 years ago
added P to pause so can see framerate when no mechanics update (box2d)
testing on chuwi hi12, get ~10fps with mechanics, ~30fps without, which faster but still slow, suggesting that neither drawing nor mechanics are fast. 
Currently 60fps mechanics (timeStep=1000/60~17), and have maxUpdatesPerFrame = 5, which may be hitting currently.
If increase timeStep to 70, get ~35fps (does pause work as expected???)
However, get problems like achieve speed cap when flying, so bullets can't go any faster. possible can solve this by changing scale, or world parameters.
In short - may be able to cure speed problem without changing rendering.
filbs111 commented 7 years ago

after scaling world down and reducing mechanics framerate by a factor 3, now get 40fps display on chuwi hi12, which seems fine. on elephone s2, still starts at ~4fps, then increases to ~20. possibly reducing mechanics rate further will help. rotation of player looks steppy now. interpolation should help.

filbs111 commented 7 years ago

interpolated rotation and dropped mechanics to 15fps. runs at 30+fps on elephone s2 though still starts at ~4. now see obvious judder when accelerating when running on smooth machine (at 120fps). Maybe want quadratic interpolation, or might be only due to camera motion (TODO test with simple locked to player camera)

filbs111 commented 7 years ago

camera issue fixed in f2eb371ab88383e42cb5e9aadcb8b6b9a8fb5429 performance is much improved on less capable machines now. closed.