Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save dominicstop/352d3ebc4bdbd04079ef9029a053ca38 to your computer and use it in GitHub Desktop.

Select an option

Save dominicstop/352d3ebc4bdbd04079ef9029a053ca38 to your computer and use it in GitHub Desktop.

2025-03-18 - react-native-ios-utilities - Crash Investigation

Gist URL


Things to check:

  • AppDelegate
  • Package Config - Dependencies
  • Package Config - Codegen
  • React Native Config
  • Metro Config



  • In the RN template, the AppDelegate inherits from RCTAppDelegate.
  • A newly added property called: RCTAppDelegate.dependencyProvider is initialized with an instance of RCTAppDependencyProvider
    • This property accepts an object that conforms to RCTDependencyProvider
    • It essential acts as a registry for class names and their corresponding class types.
    • The requirements for this protocol defines properties that hold dictionaries (i.e. mapping from string to class types), or arrays that hold class names that conform to some protocol (e.g. (NSArray<NSString *> *)imageURLLoaderClassNames).
    • The registry/map for the "third party components" are in the RCTComponentViewProtocol.thirdPartyFabricComponents property, and is defined as a "string to class type" dictionary (i.e. NSDictionary<NSString *, Class<RCTComponentViewProtocol>>).
    • I.e. a mapping of the "component handle" (class name), to the class types that conform to RCTComponentViewProtocol.

  • Since RCTAppDelegate.dependencyProvider is initialized with an instance of RCTAppDependencyProvider, it conforms to RCTDependencyProvider.
  • The RCTAppDependencyProvider.thirdPartyFabricComponents is a computed lazy static property (lazily initialized once).
    • This is because it uses a dispatch_once_t token, and uses a dispatch_once block to cache _thirdPartyFabricComponents ivar.
    • As such every time RCTAppDependencyProvider.thirdPartyFabricComponents is invoked, it just returns the cache value from _thirdPartyFabricComponents ivar.
    • The value returned from this computed static property is from: RCTThirdPartyComponentsProvider.thirdPartyFabricComponents (important).

  • The initialization of RCTAppDependencyProvider.thirdPartyFabricComponents is where the crash originates.
    • Error Message: com.facebook.react.runtime.JavaScript (18): "-[__NSPlaceholderDictionary initWithObjects:forKeys:count:]: attempt to insert nil object from objects[17].
    • Error Desc: "An abort signal terminated the process. Such crashes often happen because of an uncaught exception or unrecoverable error or calling the abort() function"
    • For whatever reason, whenever RCTAppDependencyProvider.thirdPartyFabricComponents is "read" for the first time, it triggers a crash related to a dictionary being empty (or in this case, being malformed).

Screenshot 2025-03-18 at 7 31 16 AM



  • We know that RCTThirdPartyComponentsProvider.thirdPartyFabricComponents comes from codegen/turbo modules.
    • To recap, when codegen runs during pod install, It generates stubs and implementations for all the fabric components (defined via the turbo module system).
    • Codegen searches for all the files that ends with: NativeComponent.ts and reads the codegenNativeComponent config/spec defined for the given fabric component.
    • Additionally, in codegenConfig property in your library package.json defines extra settings, most notably: codegenConfig.componentProvider (Record<string, string>).
    • So the crash originates from codegen, specifically the mapping between the handle. i.e. name of the fabric component to its associated class type (component registry).

  • If we check RCTThirdPartyComponentsProvider.mm (in this particular project, it's located at: example/ios/build/generated/ios/RCTThirdPartyComponentsProvider.mm), we can see the mapping the codegen generates.
    • From screenshot, we can see the generated dict. is malformed.

Screenshot 2025-03-24 at 8 50 33 AM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment