This repository has been archived by the owner on Aug 8, 2023. It is now read-only.
Use frame time for map animations #2674
Labels
Android
Mapbox Maps SDK for Android
performance
Speed, stability, CPU usage, memory usage, or power usage
I want to bring back something along the lines of #2410
Basically a way to pass into the
Map
the current "frame time" that it uses for all animations instead ofClock::now()
. This will help ensure animations like map pans are smooth and not jerky.I will explain why using
now()
is bad for animations:To get a smooth animation between point A and point B you need to update it's position 60 times per second to match the screen vsync. Each time point should be accurately 1/60 second apart.
Using
Clock::now()
provides no guarantee that you will get an exact multiple of 1/60 second intervals (I say multiple in case we drop a frame). This is because the exact time it executes varies depending on the CPU workload and scheduling.To solve this problem both Android and iOS provide access to a very accurate "frame time" that is captured from the screen vysnc hardware. As this is a hardware timer it will be as close to exactly 1/60 second intervals as you can get.
This is what the rest of the OS uses to run animations in their respective "native" views. Which also will allow users to easily sync map animations to any animations in their UIs.
/cc @1ec5
The text was updated successfully, but these errors were encountered: