maplibre / maplibre/maplibre-react-native

Android: NativeUserLocation without "mode" keeps the map rendering every frame (native default is COMPASS)

Open Beginner friendly
#1,621 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
661
Forks
124
Avg merge
1d 2h
Merged PRs (30d)
30

Description

What happens

A completely static map with a plain <NativeUserLocation /> keeps MapLibre's
render thread pinned at ~100% of a core, forever. Nothing on screen moves, JS is
fully idle (React profiler shows zero commits), the map is just quietly cooking
a CPU core in the background. Lowkey a battery killer on real devices, since the
loop runs the whole time the map is visible. iOS is not affected.

Repro
  1. Render a MapView with <NativeUserLocation /> and no mode prop on Android
  2. Grant location permission
  3. Run adb shell top -H -p <app pid> and watch a RenderThread N thread sit at ~100%

Reproducible with the library's own UserLocation example, nothing app-specific
needed.

Why

The docs say mode defaults to "default", but the @ReactProp setter only
runs when the prop is actually passed, so the view's internal default wins, and
that is RenderMode.COMPASS:
https://github.com/maplibre/maplibre-react-native/blob/2921af64b2c6/package/android/src/main/java/org/maplibre/reactnative/components/location/MLRNNativeUserLocation.kt#L24

COMPASS subscribes to the compass sensor, and every sensor tick re-animates the
puck bearing, so the map never stops drawing (it even burns with no location fix
and no visible puck). On iOS the codegen default is Default, so the two
platforms currently ship different defaults for the same prop.

Workaround

Pass mode="default" explicitly. Render thread drops to 0% on a static map.

Suggested fix

Flip the internal Android default to RenderMode.NORMAL so it matches the docs
and iOS.

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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 the internal render-mode default, then reproduce the UserLocation example and observe RenderThread with adb shell top. Done means an unconfigured NativeUserLocation uses the documented default on Android and a static map no longer continuously renders or pins a core.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, kotlin, react-native
Domain
mobile, performance
Issue type
Bug
Difficulty
1/5
Estimated time
Under an hour
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
88/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.