Skip to content

[Bug]: [iOS] Crash on app launch with v10.2.8: Codegen bug in RasterArraySource and RasterParticleLayer component registration #4101

@NathanNovak

Description

@NathanNovak

Mapbox Implementation

Mapbox

Mapbox Version

10.2.8

React Native Version

0.79.1

React Native Architecture

New Architecture (Fabric/TurboModules)

Platform

iOS

@rnmapbox/maps version

10.2.8

Observed behavior and steps to reproduce

Environment

  • @rnmapbox/maps version: 10.2.8
  • React Native version: 0.79.1
  • Platform: iOS (New Architecture enabled)
  • Mapbox SDK version: 11.16.2 (default from 10.2.8)
  • Xcode version: 16.3
  • iOS deployment target: 14.0+

Description

App crashes immediately on launch when using @rnmapbox/maps v10.2.8 on iOS with the New Architecture enabled. The crash occurs during Fabric component registration,
before any JavaScript code executes.

Root Cause

The codegen process incorrectly parses the class names for RNMBXRasterArraySource and RNMBXRasterParticleLayer components in the generated
RCTThirdPartyComponentsProvider.mm file. Instead of extracting just the class name, it includes the entire conditional compilation block (#else // !RNMBX_11 and
subsequent stub implementation code) as part of the class name string.

Evidence

In the generated file at ios/build/generated/ios/RCTThirdPartyComponentsProvider.mm, lines 47 and 50 show:

@"RNMBXRasterArraySource": NSClassFromString(@"RNMBXRasterArraySourceComponentView.class;,},,#else // !RNMBX_11,,// RasterArraySource is only available in Mapbox
v11+,// Provide a stub implementation for v10 builds,,@interface RNMBXRasterArraySourceComponentView () ,@EnD,,@implementation
RNMBXRasterArraySourceComponentView,,+ (void)load,{, [super load];,},,- (instancetype)initWithFrame:(CGRect)frame,{, if (self = [super initWithFrame:frame]) {,
static const auto defaultProps = std::make_shared();, _props = defaultProps;, }, return self;,},,+
(ComponentDescriptorProvider)componentDescriptorProvider,{, return concreteComponentDescriptorProvider();,},,-
(void)updateProps:(const Props::Shared &)props oldProps:(const Props::Shared &)oldProps,{, [super updateProps:props
oldProps:oldProps];,},,@EnD,,Class RNMBXRasterArraySourceCls(void),{, return RNMBXRasterArraySourceComponentView"),

This corrupted string causes NSClassFromString() to return nil, which triggers the crash when attempting to create the components dictionary.

Steps to Reproduce

  1. Create a new React Native 0.79.1 project with New Architecture enabled
  2. Install @rnmapbox/maps@10.2.8
  3. Follow the installation instructions (pod install, etc.)
  4. Try to run the iOS app
  5. App crashes immediately on launch

Error Message

*** -[__NSPlaceholderDictionary initWithObjects:forKeys:count:]: attempt to insert nil object from objects[24]

Stack Trace

Key frames:
#10 0x0000000186a951e8 in -[__NSPlaceholderDictionary initWithObjects:forKeys:count:]
#11 0x0000000186a46680 in +[NSDictionary dictionaryWithObjects:forKeys:count:]
#12 0x0000000106657ac4 in __61+[RCTThirdPartyComponentsProvider thirdPartyFabricComponents]_block_invoke
at RCTThirdPartyComponentsProvider.mm:22

Expected behavior

The app should launch successfully with properly registered Mapbox components, with the generated RCTThirdPartyComponentsProvider.mm containing clean class names
like:

@"RNMBXRasterArraySource": NSClassFromString(@"RNMBXRasterArraySourceComponentView"),
@"RNMBXRasterParticleLayer": NSClassFromString(@"RNMBXRasterParticleLayerComponentView"),

Actual Behavior

The codegen incorrectly includes conditional compilation directives and stub implementation code in the class name strings, causing NSClassFromString() to fail and
the app to crash.

Workaround

Downgrade to version 10.1.45:
"@rnmapbox/maps": "10.1.45"

This version doesn't include the problematic v11-only components and works correctly.

Additional Context

  • This issue only affects the two new Mapbox v11 components: RNMBXRasterArraySource and RNMBXRasterParticleLayer
  • The issue appears to be in how React Native's codegen parses the component files at ios/RNMBX/RNMBXRasterArraySourceComponentView.mm and
    ios/RNMBX/RNMBXRasterParticleLayerComponentView.mm
  • These files use #if RNMBX_11 / #else / #endif blocks, which seem to confuse the codegen parser
  • This blocks adoption of v10.2.8, which is needed for Android 16KB page size support

Possible Fix

The issue may be in the component provider generation script or in how the .mm files expose the component class names. The RNMBXRasterArraySourceCls() and
RNMBXRasterParticleLayerCls() functions appear both inside the #if RNMBX_11 block and the #else block, which might be confusing the parser.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions