maplibre / maplibre/maplibre-react-native
Android: androidPreferredFramesPerSecond is a silent no-op
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 661
- Forks
- 124
- Avg merge
- 1d 2h
- Merged PRs (30d)
- 30
Description
What happens
Setting androidPreferredFramesPerSecond on <NativeUserLocation /> does
nothing. Puck animation fps stays uncapped no matter the value, so the one knob
that's supposed to save battery just doesn't do anything, ngl.
Repro
- Render
<NativeUserLocation androidPreferredFramesPerSecond={10} />on Android - Trigger puck animation (location updates, or the COMPASS default from #1621)
- Observe animation/render rate is unchanged (measured via
adb shell top -H)
Why
addToMap applies the prop straight away:
https://github.com/maplibre/maplibre-react-native/blob/2921af64b2c6/package/android/src/main/java/org/maplibre/reactnative/components/location/MLRNNativeUserLocation.kt#L32
which lands in LocationComponentManager.setPreferredFramesPerSecond, where
mLocationComponent is still null (it only gets created later in
onStyleLoaded → update(style)), so the null-safe call swallows it:
https://github.com/maplibre/maplibre-react-native/blob/2921af64b2c6/package/android/src/main/java/org/maplibre/reactnative/components/location/LocationComponentManager.kt#L80
The value is never re-applied after activation. Fun bit of history: #439 was
this exact call crashing on null, and the fix in 10.0.0-beta.1 null-guarded it,
which turned the crash into today's silent no-op.
Suggested fix
Store the value in LocationComponentManager and apply it in update() once
the LocationComponent actually exists.
Environment
@maplibre/maplibre-react-native 11.3.6 (also present on current main),
RN new architecture (bridgeless), Expo SDK 57, Android emulator API 35.
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 package/android/src/main/java/org/maplibre/reactnative/components/location/MLRNNativeUserLocation.kt at addToMap, then read LocationComponentManager.kt, especially setPreferredFramesPerSecond and update(). Verify that the preferred FPS survives until onStyleLoaded creates the LocationComponent and is applied afterward; reproduce with the NativeUserLocation example and the Android steps in the issue.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- kotlin, react-native
- Domain
- mobile
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 84/100