performance - Android game loop: Draw / Update strategy (API 16+) -


im working on android 2d game (+ own simple engine) , try figure out best approach schedule drawing/updating mechanisms (api 16+) game motions smooth.

im using custom view make use of hardware acceleration. surfaceview implementations werent convincing. studied android graphics architecture introduced idea of using choreographer me, not sure if makes sense combined custom view , postinvalidate(). note postinvalidate() executed on ui thread.

here different approaches tried far :

  1. update thread (constantly running ellapsedtimeinmillis timing) + draw thread calls postinvalidate() every 16ms (with thread.sleep(restframetime))
  2. update thread (constantly running ellapsedtimeinmillis timing) + draw thread looper handler , custom view implementing choreographer.framecallback calls doframe(), calls postinvalidate()
  3. only 1 thread updating , drawing withchoreographer.framecallback , 1 state-update every frame timing-information of doframe(long frametimenanos). drawing postinvalidate().

im struggling find best approach because performance tracing (traceview, systrace, gltracing...) hard understand , different different devices , settings(e.g. power-save-mode). considered using postinvalidateonanimation() thought redundant using choreographer.framecallback

what opinon on topic? think best approach buttery smooth jank-free 60 fps game performance api 16+? doing entirely wrong? hard find detailed instructions choreographer implementation especially.


Comments

Popular posts from this blog

sequelize.js - Sequelize group by with association includes id -

android - Robolectric "INTERNET permission is required" -

java - Android raising EPERM (Operation not permitted) when attempting to send UDP packet after network connection -