Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: High CPU usage and crash when Background Modes Location updates is turned on #3700

Open
ryansommers opened this issue Nov 23, 2024 · 2 comments
Labels
bug 🪲 Something isn't working

Comments

@ryansommers
Copy link

ryansommers commented Nov 23, 2024

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

@ryansommers ryansommers added the bug 🪲 Something isn't working label Nov 23, 2024
@github-actions github-actions bot reopened this Nov 23, 2024
@ryansommers ryansommers changed the title [Bug]: High CPU usage when Background Modes Location updates is turned on [Bug]: High CPU usage and crash when Background Modes Location updates is turned on Nov 23, 2024
@ryansommers
Copy link
Author

Wanted to add: this same behavior happens when starting navigation with Mapbox Navigation but not using Mapbox Maps in any way, so I'm guessing it's some bit of shared location code both are using.

@ryansommers
Copy link
Author

Downgrading to rnmapbox 10.1.31 seems to fix the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🪲 Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant