Skip to content

Commit e5ee39c

Browse files
Abbondanzofacebook-github-bot
authored andcommitted
Pause RedBox auto-retry reload while app is backgrounded (#57593)
Summary: The RedBox auto-retry timer could fire a reload while the app was in the background. That reload restarts the instance and re-initializes native modules; a module requiring main-queue setup is dispatched synchronously onto the main queue, which is itself blocked inside the reload, deadlocking the app until the watchdog terminates it. Gate the countdown in `autoRetryTick` on foreground state, so the timer only advances (and eventually reloads) while the app is active. In app extensions `RCTSharedApplication()` is nil, which reads as active and preserves the prior behavior. Changelog: [iOS][Fixed] - Prevent RedBox auto-retry from reloading while backgrounded Differential Revision: D112543586
1 parent 7825d51 commit e5ee39c

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

packages/react-native/React/CoreModules/RCTRedBox2Controller.mm

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,12 @@ - (void)stopAutoRetry
373373

374374
- (void)autoRetryTick
375375
{
376+
// Don't reload while backgrounded: it re-inits TurboModules, and a
377+
// requiresMainQueueSetup module dispatch_syncs onto the blocked main queue,
378+
// deadlocking until the watchdog kills the app.
379+
if (RCTSharedApplication().applicationState != UIApplicationStateActive) {
380+
return;
381+
}
376382
_autoRetryCountdown--;
377383
if (_autoRetryCountdown <= 0) {
378384
[self stopAutoRetry];

0 commit comments

Comments
 (0)