Skip to content

[Bug]: invisible LocationPuck causing high CPU load #3787

Closed

Description

@g4rb4g3

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.

Image

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

Activity

  1. added
    bug 🪲
    on Feb 21, 2025
  2. kaito0228 commented on Feb 25, 2025

    @kaito0228

    me too!

  3. kaito0228 commented on Feb 28, 2025

    @kaito0228

    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).

  4. g4rb4g3 commented on Apr 5, 2025

    @g4rb4g3
    ContributorAuthor

    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?

  5. mfazekas commented on Oct 18, 2025

    @mfazekas
    Contributor

    @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.

  6. added
    iOS
    on Oct 18, 2025
  7. mfazekas commented on Oct 18, 2025

    @mfazekas
    Contributor

    @g4rb4g3 also why don't you just remove the LocationPuck component?

    {false && <LocationPuck puckBearingEnabled={true} visible={false} />}
    
  8. warmfire540 commented on Oct 18, 2025

    @warmfire540

    add a console.log to onMapIdle - my phone turned into a heating pad for a second..

    onMapIdle(state) {
      console.log("onMapIdle called")
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug 🪲iOS

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions