maps icon indicating copy to clipboard operation
maps copied to clipboard

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

Open ryansommers opened this issue 1 year ago • 9 comments

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 avatar Nov 23 '24 00:11 ryansommers

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 avatar Nov 23 '24 03:11 ryansommers

Downgrading to rnmapbox 10.1.31 seems to fix the issue.

ryansommers avatar Nov 23 '24 20:11 ryansommers

Also experiencing this. Can confirm downgrading "fix" the issue.

blytung avatar Dec 09 '24 09:12 blytung

Likely related to https://github.com/mapbox/mapbox-maps-ios/issues/2261

ryansommers avatar Dec 22 '24 17:12 ryansommers

The original issue in the Mapbox Maps SDK was just resolved in 10.19.2.

OdNairy avatar Jan 23 '25 14:01 OdNairy

Any idea when this will be resolved? or any workaround for this? I am using the version 10.1.38 and the issue is still there.

avinash2407 avatar May 19 '25 16:05 avinash2407

@avinash2407 I added $RNMapboxMapsVersion = '= 10.19.4' in my Podfile to temporarily fix it.

ryansommers avatar May 19 '25 16:05 ryansommers

This works! Thanks, @ryansommers

avinash2407 avatar May 20 '25 06:05 avinash2407

Thanks @ryansommers it fixed my issue too. For people using a managed Expo project, add

[
"@rnmapbox/maps",
{
"RNMapboxMapsVersion": "10.19.4"
}
],

to your app.json

samthemagicman avatar May 21 '25 13:05 samthemagicman