Debug rn native crash

From LedgerHQ/ledger-live · View interactive version

Debug rn native crash is an AI agent skill from the GitHub repository LedgerHQ/ledger-live. Investigate native React Native crashes (Fabric/Hermes/iOS) in ledger-live-mobile when JS error logs are missing or unhelpful. Use when the app dies silently, throws an NSException on iOS, or shows only a native stack trace.

How to use this skill

Skill file

Debug RN native crash

Trigger

The mobile app crashes with one of:

If the JS console already gives a clear stack, don't use this skill — read the JS error.

Workflow

1. Capture the native exception from the simulator

xcrun simctl list devices booted   # get the booted sim UDID
xcrun simctl spawn <UDID> log show --last 5m --style compact \
  --predicate 'processImagePath CONTAINS "ledgerlivemobile" AND (eventMessage CONTAINS "Assertion failure" OR eventMessage CONTAINS "Attempt to unmount" OR eventMessage CONTAINS "Terminating app")'

Extract the exception message, native stack, and any view descriptors (frame, tag, backgroundColor, alpha). These already tell you a lot — see reference.md "Anatomy of a Fabric assertion message".

2. Reproduce under Xcode debugger

open apps/ledger-live-mobile/ios/ledgerlivemobile.xcworkspace

3. Identify the offending React component

In the lldb console at the bottom of Xcode:

  1. Pick the frame that has the offending C++/ObjC code:

```

bt # full backtrace, find the frame in RN code

frame select N # N = the RN frame (often RCTPerformMountInstructions)

```

  1. Inspect the views referenced by the failed instruction. Variable names depend on the frame — read the source displayed in Xcode. Common ones:

```

po parentViewDescriptor.view

po oldChildViewDescriptor.view

p mutation.parentTag

p mutation.index

p oldChildShadowView.componentName

```

  1. Find where the orphan child is actually attached vs where Fabric thinks:

```

po [oldChildViewDescriptor.view superview]

po [oldChildViewDescriptor.view accessibilityIdentifier] # = RN testID

po [parentViewDescriptor.view superview]

po [[parentViewDescriptor.view superview] accessibilityIdentifier]

po [parentViewDescriptor.view subviews]

```

  1. Climb the superview chain until you hit a accessibilityIdentifier (= RN testID) you recognise in source. Grep for it:

```bash

grep -rn 'testID="<identifier>"' apps/ledger-live-mobile/src libs/ui

```

That's the RN component family. From there, read the JSX and find the conditional render / animation / library that produced the mismatch.

4. Map the native cause to a code pattern

The vast majority of Fabric assertions come from a small set of patterns. See reference.md "Common Fabric crash patterns".

5. Fix and verify Metro actually serves the fix

A common trap: Metro's file watcher dies on EMFILE: too many open files. Edits silently never reach the bundle. Always confirm Metro logged a fresh Compiled ios in Xs line after each edit (in the terminal running pnpm mobile start:ios, or wherever Metro's stdout is streaming).

If the watcher is broken, restart Metro with --reset-cache. Reload the app (Cmd+R in sim or shake → Reload).

Guardrails

Output

Reference

See reference.md in this folder for:

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.