Skip to content

Commit 4eda300

Browse files
tomekzawclaude
andauthored
fix: Don't crash on iOS double reload when surface presenter has no scheduler (#9672)
## Summary On a double reload (e.g. during an OTA update, when the app is reloaded right after evaluating the bundle) React Native can momentarily leave the surface presenter without a scheduler. `installTurboModule` then hit a `react_native_assert` on the nil scheduler and aborted with `SIGABRT`. This nil scheduler is just another symptom of the same non-fatal reload race already handled by `hasReactNativeFailedReload`, so we detect it there and bail out with `@NO` instead of asserting. ## Test plan - Run the fabric-example app on iOS (debug build). - Trigger a double reload — two fast reloads in a row, or reload immediately after launch (mimicking the OTA-update timing). - Before: `SIGABRT` at the `scheduler != nil` assert in `ReanimatedModule.mm`. After: the app reloads cleanly. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 30e0492 commit 4eda300

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

packages/react-native-reanimated/apple/reanimated/apple/ReanimatedModule.mm

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,18 @@ - (void)sendEventWithName:(NSString *)eventName body:(id)body
163163
- (BOOL)hasReactNativeFailedReload
164164
{
165165
id workletsModule = [_moduleRegistry moduleForName:"WorkletsModule"];
166-
return ![_moduleRegistry moduleIsInitialized:[workletsModule class]];
166+
if (![_moduleRegistry moduleIsInitialized:[workletsModule class]]) {
167+
return YES;
168+
}
169+
170+
// On a double reload React Native can momentarily leave the surface presenter without
171+
// a scheduler. This is another manifestation of the same non-fatal reload race, so we
172+
// bail on it here instead of asserting on a nil scheduler later in installTurboModule.
173+
if ([_surfacePresenter scheduler] == nil) {
174+
return YES;
175+
}
176+
177+
return NO;
167178
}
168179

169180
RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(installTurboModule)

0 commit comments

Comments
 (0)