mapbox / mapbox/mapbox-maps-android
MapView.setMaximumFps not working properly on secondary screens (Android Auto)
Nobody has claimed this yet.
- Dominant language
- Kotlin
- Stars
- 578
- Forks
- 161
- PR merge metrics
- No merged PRs in 30d
Description
## Environment
- Android OS version: 15
- Devices affected: Probably all Android devices, tested with a Pixel 6 Pro
- Maps SDK Version: 11.8.0
## Observed behavior and steps to reproduce
When having multiple displays and calling MapView.setMaximumFps the framerate is not applied properly when doing this for any other screen then the primary one.
I'm running an app with up to 3 MapViews, one on the phone screen and up to 2 on Android Auto (head unit and cluster display).
I added some simple logging using onRenderFrameFinished to calculate the fps and compared this to what I specified on setMaximumFps and it is always off by the factor of 2 until I disable "Smooth display" in Android Settings (so limiting the primary screen to 60 Hz).
FpsManager is initialized with the proper refresh rate of the actual display, I can see screenRefreshRate being 60 Hz for the Android Auto screen even when the phone has "Smooth display" enabled (so running at 120 Hz).
https://github.com/mapbox/mapbox-maps-android/blob/main/maps-sdk/src/main/java/com/mapbox/maps/MapView.kt#L233
But somewhere in the map rendering the userToScreenRefreshRateRatio seems to be applied to the primary screens refresh rate instead to the actual screen the map is rendered on.
On these logs you can see the initial ~120fps rendering, then I try to limit it to 30fps but it is actually ~60fps then.
2025-07-08 21:09:08.490 16469-16469 RNMBXMapView D *** 120 fps
2025-07-08 21:09:09.491 16469-16469 RNMBXMapView D *** 119 fps
2025-07-08 21:09:21.520 16469-17333 Mapbox I [maps-android\Mbgl-FpsManager]: User set max FPS to 30
2025-07-08 21:09:30.404 16469-17333 Mapbox I [maps-android\Mbgl-FpsManager]: User defined ratio is 0.5
2025-07-08 21:09:31.447 16469-16469 RNMBXMapView D *** 56 fps
2025-07-08 21:09:32.454 16469-16469 RNMBXMapView D *** 59 fps
2025-07-08 21:09:33.462 16469-16469 RNMBXMapView D *** 59 fps
## Expected behavior
Calling MapView.setMaximumFps should limit the fps on the display/screen the map is rendered on properly. So specifying 30fps should not lead to 60fps.
## Notes / preliminary analysis
## Additional links and references
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in maps-sdk/src/main/java/com/mapbox/maps/MapView.kt around line 233 and trace how FpsManager obtains screenRefreshRate and applies userToScreenRefreshRateRatio. Reproduce with MapView.setMaximumFps on a secondary Android Auto display while observing onRenderFrameFinished and the FpsManager logs. Done means the requested limit, such as 30 fps, is applied to the display rendering that map rather than the primary screen’s refresh rate.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, kotlin
- Domain
- mobile-dev, performance
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100