fix(android) avoid exception in onHostPause

YOLO.
This commit is contained in:
Saúl Ibarra Corretgé 2021-08-26 15:12:11 +02:00 committed by Saúl Ibarra Corretgé
parent eb4aefbca1
commit 7d6365c5e0
1 changed files with 8 additions and 5 deletions

View File

@ -116,12 +116,15 @@ public class JitsiMeetActivityDelegate {
= ReactInstanceManagerHolder.getReactInstanceManager(); = ReactInstanceManagerHolder.getReactInstanceManager();
if (reactInstanceManager != null) { if (reactInstanceManager != null) {
// Try to avoid a crash because some devices trip on this assert: try {
// https://github.com/facebook/react-native/blob/df4e67fe75d781d1eb264128cadf079989542755/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManager.java#L512
// Why this happens is a mystery wrapped in an enigma.
ReactContext reactContext = reactInstanceManager.getCurrentReactContext();
if (reactContext != null && activity == reactContext.getCurrentActivity()) {
reactInstanceManager.onHostPause(activity); reactInstanceManager.onHostPause(activity);
} catch (AssertionError e) {
// There seems to be a problem in RN when resuming an Activity when
// rotation is involved and the planets align. There doesn't seem to
// be a proper solution, but since the activity is going away anyway,
// we'll YOLO-ignore the exception and hope fo the best.
// Ref: https://github.com/facebook/react-native/search?q=Pausing+an+activity+that+is+not+the+current+activity%2C+this+is+incorrect%21&type=issues
JitsiMeetLogger.e(e, "Error running onHostPause, ignoring");
} }
} }
} }