rnmapbox / rnmapbox/maps

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

Open
#4,189 4 comments 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug 🪲
Dominant language
Kotlin
Stars
2.9k
Forks
947
Avg merge
6d 37m
Merged PRs (30d)
1

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the standalone reproduction, especially the Images component using images={{}} and the alternative nativeAssetImages path. Trace the Images component's iOS native handling and reproduce the crash in both debug and release modes; done means the example no longer crashes when images are supplied or omitted.

Written by the indexing model from the issue text.

Assessment

Tech stack
ios, javascript, react-native
Domain
mobile
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.