You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Aug 8, 2023. It is now read-only.
Repository navigation
This repository was archived by the owner on Aug 8, 2023. It is now read-only.
Did some testing. Currently pans and animations are mostly limited to 60fps I assume because of the touch input update rate. However with two finger rotate it jumps towards 200fps.
I found on TextureView that postInvalidate and onDraw to not work.
However postOnAnimation seems promising but only on API 16.
postAnimation makes panning rather janky whereas currently it is smooth. It does lower the rotation frame rate but it seems to still spike rather high.
I wonder if the problem is that two finger touch activates both rotate and zoom gesture listeners which set two different map properties and this then generates two render frames.
@jfirebaugh If map.scaleBy and map.zoomBy are both called at 60 times per second, do I get two frames rendered thus 120 FPS?
The frequency of calling scaleBy and zoomBy doesn't directly translate to a frame rate. These calls post updates via uv_async which has a built in form of deduplication.
It creates a SurfaceTextre we use with EGL to render too.
Every time we finish a render and eglSwapBuffers() it will return us a recycled Surface buffer to render into. It will keep providing new buffers as fast as we call eglSwapBuffers(). Basically we cannot rely on eglSwapBuffers() for frame limiting.
When TextureView.draw() is called each vsync frame, it grabs whatever buffer is the latest, and draws this to the View. It then calls invalidate() to trigger a new draw() on the next vsync, then calls SurfaceTextureListener.onSurfaceTextureUpdated(). Currently our onSurfaceTextureUpdated() does nothing.
It seems we need to use onSurfaceTextureUpdated() as a signal when our previous frame made it to the screen, and should be the basis of our draw timing.
I ended up using postOnAnimate() as it gives good results. I created a dirty flag in the Android side and removed the dirty flag that was in NativeMapView C++ side.
Going to need alternative to postOnAnimate() for pre-Jellybean devices. Likely one of the timer based methods.
Activity
ljbade commentedon Sep 23, 2015
Possibly
eglSwapIntervalor the Android view invalidate process.ljbade commentedon Sep 23, 2015
http://developer.android.com/reference/android/view/Choreographer.FrameCallback.html
ljbade commentedon Sep 23, 2015
If you read https://source.android.com/devices/graphics/architecture.html#texture it seems we need to use View invalidate as swap buffers will never stall.
ljbade commentedon Sep 23, 2015
Did some testing. Currently pans and animations are mostly limited to 60fps I assume because of the touch input update rate. However with two finger rotate it jumps towards 200fps.
I found on
TextureViewthatpostInvalidateandonDrawto not work.However
postOnAnimationseems promising but only on API 16.ljbade commentedon Sep 23, 2015
postAnimationmakes panning rather janky whereas currently it is smooth. It does lower the rotation frame rate but it seems to still spike rather high.ljbade commentedon Sep 23, 2015
I wonder if the problem is that two finger touch activates both rotate and zoom gesture listeners which set two different map properties and this then generates two render frames.
@jfirebaugh If
map.scaleByandmap.zoomByare both called at 60 times per second, do I get two frames rendered thus 120 FPS?jfirebaugh commentedon Sep 23, 2015
The frequency of calling
scaleByandzoomBydoesn't directly translate to a frame rate. These calls post updates via uv_async which has a built in form of deduplication.mikemorris commentedon Sep 23, 2015
Is there something going on here where the framerate is not independent of user input processing?
https://www.scirra.com/tutorials/67/delta-time-and-framerate-independence
http://gafferongames.com/game-physics/fix-your-timestep/
ljbade commentedon Sep 23, 2015
@mikemorris It appears so. The frame rate for rotation gestures is much higher than for pan gestures.
ljbade commentedon Sep 24, 2015
Also noting that my Samsung S6 is currently flagging Mapbox GL as slowing the phone down and recommending I delete it.
Not good for customer's apps.
ljbade commentedon Sep 24, 2015
@jfirebaugh Is that dedupe reliable? What happens if we manage to process one render frame so quickly the second frame isn't a dupe?
ljbade commentedon Sep 24, 2015
Confirmed disabling the zoom gesture drops frame rate to 60. Seems to be a result of updating the map twice per frame.
ljbade commentedon Sep 24, 2015
@kkaefer What would be the best way to limit how many times the map redraws per frame?
I might be able to work around this specific problem by combining scale and rotate updates into one call.ljbade commentedon Sep 24, 2015
Worked out the behaviour
TextureView:SurfaceTextrewe use with EGL to render too.eglSwapBuffers()it will return us a recycledSurfacebuffer to render into. It will keep providing new buffers as fast as we calleglSwapBuffers(). Basically we cannot rely oneglSwapBuffers()for frame limiting.TextureView.draw()is called each vsync frame, it grabs whatever buffer is the latest, and draws this to the View. It then callsinvalidate()to trigger a newdraw()on the next vsync, then callsSurfaceTextureListener.onSurfaceTextureUpdated(). Currently ouronSurfaceTextureUpdated()does nothing.It seems we need to use
onSurfaceTextureUpdated()as a signal when our previous frame made it to the screen, and should be the basis of our draw timing.ljbade commentedon Sep 24, 2015
I ended up using
postOnAnimate()as it gives good results. I created a dirty flag in the Android side and removed the dirty flag that was inNativeMapViewC++ side.Going to need alternative to
postOnAnimate()for pre-Jellybean devices. Likely one of the timer based methods.ljbade commentedon Sep 24, 2015
At some stage we should look at plumping
Choreographer's frame times into the map animation system to get smoother animations.Will also look at fixing GPS dot sync.
ljbade commentedon Sep 24, 2015
Creating PR
Refactor Android render loop to limit frame rate to 60 FPS