mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Attempt to fix crash during app termination
Summary: changelog: Attempt to fix a crash during app termination on iOS in the new renderer We need to stop all surfaces before it is terminated to prevent app from crashing. The crash happens on background thread. The app crashes because it is probably accessing static variable that has been deallocated by the main thread. How can main thread deallocate things when background thread is still running? Because main thread is attached to our app's process, background thread is provided by the system and continues to live. Reviewed By: ShikaSD Differential Revision: D33977161 fbshipit-source-id: 87546d7b70d1aa465e63f0d37b70bae1fffa2304
This commit is contained in:
committed by
Facebook GitHub Bot
parent
70062c1322
commit
9cd43340a7
@@ -99,6 +99,14 @@ static BackgroundExecutor RCTGetBackgroundExecutor()
|
||||
_observers = [NSMutableArray array];
|
||||
|
||||
_scheduler = [self _createScheduler];
|
||||
|
||||
auto reactNativeConfig = _contextContainer->at<std::shared_ptr<ReactNativeConfig const>>("ReactNativeConfig");
|
||||
if (reactNativeConfig->getBool("react_native_new_architecture:suspend_before_app_termination")) {
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||
selector:@selector(_applicationWillTerminate)
|
||||
name:UIApplicationWillTerminateNotification
|
||||
object:nil];
|
||||
}
|
||||
}
|
||||
|
||||
return self;
|
||||
@@ -327,6 +335,11 @@ static BackgroundExecutor RCTGetBackgroundExecutor()
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)_applicationWillTerminate
|
||||
{
|
||||
[self suspend];
|
||||
}
|
||||
|
||||
#pragma mark - RCTSchedulerDelegate
|
||||
|
||||
- (void)schedulerDidFinishTransaction:(MountingCoordinator::Shared const &)mountingCoordinator
|
||||
|
||||
Reference in New Issue
Block a user