[Bug]: invisible LocationPuck causing high CPU load
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
me too!
When I launch rnmapbox and use it while moving for about 20 minutes, the CPU processing freezes. The map itself can still be operated, suggesting that map operations might be processed by the GPU.
I'm using the latest versions of rnmapbox (10.1.37) and mapbox-maps-ios (11.10.1).
Any thoughts on this from your side @mfazekas ? As mentioned I have no idea why the empty image is in place and from my testing it is fine to set location.options.puckType to nil. Should I do a PR removing the empty image and just setting location.options.puckType = nil?
@g4rb4g3 I think the reason for empty image, is I think that follow user location was only working if there was a location puck. Not sure if it's still the case.
@g4rb4g3 also why don't you just remove the LocationPuck component?
{false && <LocationPuck puckBearingEnabled={true} visible={false} />}
add a console.log to onMapIdle - my phone turned into a heating pad for a second..
onMapIdle(state) {
console.log("onMapIdle called")
}