[Bug]: invisible LocationPuck causing high CPU load
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
11.8.0
React Native Version
0.76.6
Platform
iOS
@rnmapbox/maps version
10.1.31
Standalone component to reproduce
import React from 'react';
import {
MapView,
ShapeSource,
LineLayer,
Camera,
LocationPuck,
} from '@rnmapbox/maps';
const aLine = {
type: 'LineString',
coordinates: [
[-74.00597, 40.71427],
[-74.00697, 40.71527],
],
};
class BugReportExample extends React.Component {
render() {
return (
<MapView style={{flex: 1}}>
<Camera centerCoordinate={[-74.00597, 40.71427]} zoomLevel={14} />
<LocationPuck puckBearingEnabled={true} visible={false} />
<ShapeSource id="idStreetLayer" shape={aLine}>
<LineLayer id="idStreetLayer" />
</ShapeSource>
</MapView>
);
}
}
Observed behavior and steps to reproduce
When adding an <LocationPuck visible={false} /> and feeding continuous GPS updates with Xcode I can see a pretty high CPU load on iOS.
Expected behavior
No additional CPU load when LocationPuck is not visible.
Notes / preliminary analysis
This is caused since an 1x1 empty image is used inside RNMBXNativeUserLocation when invisible is true. Mapbox then animates this invisible image causing a pretty high load for nothgin.
I don't know the reason for that implementation but from my point of view it should be fine to just set location.options.puckType to nil.
https://github.com/rnmapbox/maps/blob/main/ios/RNMBX/RNMBXNativeUserLocation.swift#L144
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
Start with ios/RNMBX/RNMBXNativeUserLocation.swift around line 144 and inspect how an invisible LocationPuck is configured. Reproduce the issue with the provided React Native example and continuous GPS updates on iOS; done means an invisible puck no longer adds the reported CPU load.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ios, javascript, react-native, swift
- Domain
- mobile-dev, performance
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100