Skip to content

Commit d58ba82

Browse files
mdvaccafacebook-github-bot
authored andcommitted
Avoid app crashing when a StackOverflowError is thrown when rendering deep RN view hierarcy
Reviewed By: achen1 Differential Revision: D7400906 fbshipit-source-id: faaf701a88440f89390518f00e6a35f19e9203db
1 parent 4906f8d commit d58ba82

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

ReactAndroid/src/main/java/com/facebook/react/views/view/ReactViewGroup.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import android.view.ViewGroup;
2222
import android.view.animation.Animation;
2323
import com.facebook.infer.annotation.Assertions;
24+
import com.facebook.react.bridge.ReactContext;
2425
import com.facebook.react.common.annotations.VisibleForTesting;
2526
import com.facebook.react.modules.i18nmanager.I18nUtil;
2627
import com.facebook.react.touch.OnInterceptTouchEventListener;
@@ -668,7 +669,12 @@ protected void dispatchDraw(Canvas canvas) {
668669
if (rootView != null) {
669670
rootView.handleException(e);
670671
} else {
671-
throw e;
672+
if (getContext() instanceof ReactContext) {
673+
ReactContext reactContext = (ReactContext) getContext();
674+
reactContext.handleException(new IllegalViewOperationException("StackOverflowException", this, e));
675+
} else {
676+
throw e;
677+
}
672678
}
673679
}
674680
}

0 commit comments

Comments
 (0)