Avoid app crashing when a StackOverflowError is thrown when rendering deep RN view hierarcy

Reviewed By: achen1

Differential Revision: D7400906

fbshipit-source-id: faaf701a88440f89390518f00e6a35f19e9203db
This commit is contained in:
David Vacca 2018-03-31 23:20:52 -07:00 коммит произвёл Facebook Github Bot
Родитель 4906f8d28c
Коммит d58ba8242b
1 изменённых файлов: 7 добавлений и 1 удалений

Просмотреть файл

@ -21,6 +21,7 @@ import android.view.View;
import android.view.ViewGroup;
import android.view.animation.Animation;
import com.facebook.infer.annotation.Assertions;
import com.facebook.react.bridge.ReactContext;
import com.facebook.react.common.annotations.VisibleForTesting;
import com.facebook.react.modules.i18nmanager.I18nUtil;
import com.facebook.react.touch.OnInterceptTouchEventListener;
@ -667,11 +668,16 @@ public class ReactViewGroup extends ViewGroup implements
RootView rootView = RootViewUtil.getRootView(ReactViewGroup.this);
if (rootView != null) {
rootView.handleException(e);
} else {
if (getContext() instanceof ReactContext) {
ReactContext reactContext = (ReactContext) getContext();
reactContext.handleException(new IllegalViewOperationException("StackOverflowException", this, e));
} else {
throw e;
}
}
}
}
private void dispatchOverflowDraw(Canvas canvas) {
if (mOverflow != null) {