Skip to content

[Bug]: Unexpectedly found nil while implicitly unwrapping an Optional value #4189

@w8ight

Description

@w8ight

Mapbox Version

default

React Native Version

0.84.1

Platform

iOS

@rnmapbox/maps version

10.3.0

Standalone component to reproduce

import React from 'react';
import {
  Images,
  MapView,
  ShapeSource,
  LineLayer,
  Camera,
} from '@rnmapbox/maps';

const aLine = {
  type: 'LineString',
  coordinates: [
    [-74.00597, 40.71427],
    [-74.00697, 40.71527],
  ],
};

class BugReportExample extends React.Component {
  render(props) {
    return (
      <MapView style={{flex: 1}}>
        {/* real images object should be passed with at least one png */}
        <Images images={{}} />
        <Camera centerCoordinate={[-74.00597, 40.71427]} zoomLevel={14} />

        <ShapeSource id="idStreetLayer" shape={aLine}>
          <LineLayer id="idStreetLayer" />
        </ShapeSource>
      </MapView>
    );
  }
}

Observed behavior and steps to reproduce

After upgrading to RN 0.84.1, app on iOS started crashing immediately due to usage of the <Images images={images} /> component with a native error saying Unexpectedly found nil while implicitly unwrapping an Optional value. Images object can be as simple as {icon: importedPngIcon}

Does not crash if no images are passed into component

Tried using both images/nativeAssetImages

Happens in both debug and release modes

Xcode 26.4, but happened on 26.3 version as well

import React from 'react';
import {
  Images,
  MapView,
  ShapeSource,
  LineLayer,
  Camera,
} from '@rnmapbox/maps';

const aLine = {
  type: 'LineString',
  coordinates: [
    [-74.00597, 40.71427],
    [-74.00697, 40.71527],
  ],
};

class BugReportExample extends React.Component {
  render(props) {
    return (
      <MapView style={{flex: 1}}>
        {/* real images object should be passed with at least one png */}
        <Images images={{}} />
        <Camera centerCoordinate={[-74.00597, 40.71427]} zoomLevel={14} />

        <ShapeSource id="idStreetLayer" shape={aLine}>
          <LineLayer id="idStreetLayer" />
        </ShapeSource>
      </MapView>
    );
  }
}
Image

Expected behavior

App should not crash

Notes / preliminary analysis

No response

Additional links and references

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug 🪲Something isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions