[Bug]: High CPU usage and crash when Background Modes Location updates is turned on
Nobody has claimed this yet.
- Dominant language
- Kotlin
- Stars
- 2.9k
- Forks
- 947
- Avg merge
- 6d 37m
- Merged PRs (30d)
- 1
Description
Mapbox Implementation
Mapbox
Mapbox Version
10.19.0
React Native Version
0.76.0
Platform
iOS
@rnmapbox/maps version
10.1.33
Standalone component to reproduce
import React from 'react';
import Mapbox from '@rnmapbox/maps';
Mapbox.setAccessToken('TOKEN');
class App extends React.Component {
render() {
return (
<Mapbox.MapView style={{flex: 1}}>
<Mapbox.Camera followUserLocation followZoomLevel={16} />
</Mapbox.MapView>
)
}
}
export default App;
Observed behavior and steps to reproduce
When Background Modes: Current location is enabled in Xcode, Mapbox’s com.mapbox.common.location.sharedRunLoop goes to 100% CPU as soon as it starts. This is causing significant battery drain and crashes when the app is in the background as the system shuts the app down due to high CPU usage.
Expected behavior
com.mapbox.common.location.sharedRunLoop doesn’t use so much CPU
Notes / preliminary analysis
No changes to Example app code @rnmapbox/maps/example
Occasionally the issue seems to be timing dependent, like it happens more consistently the earlier Mapbox is loaded. If that’s the case in your testing, update example/src/App.js’s render method to the standalone component above.
Additional links and references
No response
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
Reproduce the issue with the standalone component in the report, or update example/src/App.js’s render method as suggested, with Background Modes: Current location enabled in Xcode. Observe com.mapbox.common.location.sharedRunLoop when the Mapbox camera follows the user, including timing differences in when Mapbox loads. Done means the shared run loop no longer reaches excessive CPU usage and the app does not crash in the background.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ios, javascript, react-native
- Domain
- mobile
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100