Repository navigation
Description
Mapbox Implementation
Mapbox GL
Mapbox Version
default
React Native Version
0.78.2
Platform
Android
@rnmapbox/maps version
10.1.42
Standalone component to reproduce
import React, {useState} from "react";
import MapboxGL, {Camera, MapView, UserLocation} from "@rnmapbox/maps";
import {ActivityIndicator, Platform, View} from "react-native";
Platform.OS === "android" && MapboxGL.requestAndroidLocationPermissions();
export const START_ZOOM_LEVEL = 15;
export const MAX_ZOOM_LEVEL = 18;
export const MIN_ZOOM_LEVEL = 1;
const DEFAULT_LOCATION = {
latitude: 52.52,
longitude: 13.405,
};
export default function AppMap() {
const [mapLoaded, setMapLoaded] = useState(false);
return (
<View style={{flex: 1}}>
{!mapLoaded && (
<View
style={{
position: "absolute",
zIndex: 200,
bottom: "50%",
alignSelf: "center",
}}>
<View
style={{
backgroundColor: "white",
padding: 8,
borderRadius: 9999,
}}>
<ActivityIndicator size={48} />
</View>
</View>
)}
<MapView
logoEnabled={true}
attributionEnabled={true}
rotateEnabled={false}
zoomEnabled
scrollEnabled
pitchEnabled={false}
scaleBarEnabled={false}
onDidFinishLoadingMap={() => {
setMapLoaded(true);
}}
style={{flex: 1}}>
<>
<Camera
minZoomLevel={MIN_ZOOM_LEVEL}
maxZoomLevel={MAX_ZOOM_LEVEL}
allowUpdates={true}
animationMode="none"
defaultSettings={{
centerCoordinate: [
DEFAULT_LOCATION.longitude,
DEFAULT_LOCATION.latitude,
],
zoomLevel: START_ZOOM_LEVEL,
}}
/>
<UserLocation
androidRenderMode="normal"
requestsAlwaysUse
minDisplacement={10}
visible={true}
onUpdate={res => {
console.log("User location updated:", res);
}}
/>
</>
</MapView>
</View>
);
}Observed behavior and steps to reproduce
Steps to reproduce
- Open the app and display the map with UserLocation.
- Start some kind of a android foregroundService that works even when the app is closed
- Restart the app.
- Observe that the user location updates only a couple of times and then stops.
- Switch to the deprecated renderMode={UserLocationRenderMode.Native} and notice that the location updates correctly, but onUpdate remains non-functional.
Expected behavior
The map should continuously update the user’s location while the foreground service is running, even after the app is restarted.
Notes / preliminary analysis
When I start a foregroundService with android:foregroundServiceType="location", my location on the map stops updating after restarting the app. The position is retrieved at most twice and then stops completely.
If I use the deprecated renderMode={UserLocationRenderMode.Native} in UserLocation, the location on the map updates correctly, but the onUpdate callback still doesn’t return anything.
It looks like the issue is related to the interaction between Mapbox and Android foreground services. From what I’ve tested, the specific type of foregroundService doesn’t seem to make a difference.
Additional links and references
No response
Activity
[-][Bug]: UserLocation stops updating after restarting app[/-][+][Bug]: UserLocation stops updating after restarting app with background foregroundService on Android[/+]RyanTG commentedon Sep 21, 2025
Just curious: are you seeing this on Android 16 only, or all Android? Just asking because we’re experiencing an Android 16 issue where it works fine in initial start, but then the map spins if you close and re-open the app. Still diagnosing, but it sounds similar to yours.
RyanTG commentedon Sep 23, 2025
The issue we experienced was solved here expo/expo#39851. It was an issue with Expo-Location, wherein requesting
requestForegroundPermissionsAsyncwhen that permission was already granted produced a problem. That issue has a workaround.Does this resolve your issue?
mfazekas commentedon Oct 18, 2025
@Slo1k can you post a step by step instructions, to reproduce?
Can you provide a concrete example for this:
Also have to looked into this: #3965 (comment) ?
mfazekas commentedon Oct 12, 2026
Closing as we haven't heard back. If this still happens on the latest release, please reopen with a standalone reproducer and the steps to trigger it.