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 :
- update thread (constantly running ellapsedtimeinmillis timing) + draw thread calls
postinvalidate()
every 16ms (withthread.sleep(restframetime)
) - update thread (constantly running ellapsedtimeinmillis timing) + draw thread looper handler , custom view implementing
choreographer.framecallback
callsdoframe()
, callspostinvalidate()
- only 1 thread updating , drawing with
choreographer.framecallback
, 1 state-update every frame timing-information ofdoframe(long frametimenanos)
. drawingpostinvalidate()
.
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
Post a Comment