Skip to content

Commit b587763

Browse files
Abbondanzometa-codesync[bot]
authored andcommitted
Pause RedBox auto-retry reload while app is backgrounded (#57593)
Summary: Pull Request resolved: #57593 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 Reviewed By: shwanton Differential Revision: D112543586 fbshipit-source-id: 17f0a7797c64ed312b3124138f4ec9edc10006c8
1 parent c086431 commit b587763

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)