ReactViewGroup.dispatchDraw NullPointerException handling

Summary: Add a catch statement for NPE around ViewGroup's dispatchDraw and log it

Reviewed By: mdvacca

Differential Revision: D13554441

fbshipit-source-id: a94d3db71678e17ef6bcda46689a069b85e460c5
This commit is contained in:
Luna Wei
2018-12-28 10:31:45 -08:00
committed by Facebook Github Bot
parent f3e5cce474
commit 3407a74957
2 changed files with 5 additions and 0 deletions

View File

@@ -8,6 +8,7 @@ rn_android_library(
],
deps = [
YOGA_TARGET,
react_native_dep("libraries/fbcore/src/main/java/com/facebook/common/logging:logging"),
react_native_dep("third-party/java/infer-annotations:infer-annotations"),
react_native_dep("third-party/java/jsr-305:jsr-305"),
react_native_target("java/com/facebook/react/bridge:bridge"),

View File

@@ -20,9 +20,11 @@ import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.Animation;
import com.facebook.common.logging.FLog;
import com.facebook.infer.annotation.Assertions;
import com.facebook.react.bridge.ReactContext;
import com.facebook.react.common.annotations.VisibleForTesting;
import com.facebook.react.common.ReactConstants;
import com.facebook.react.modules.i18nmanager.I18nUtil;
import com.facebook.react.touch.OnInterceptTouchEventListener;
import com.facebook.react.touch.ReactHitSlopView;
@@ -670,6 +672,8 @@ public class ReactViewGroup extends ViewGroup implements
try {
dispatchOverflowDraw(canvas);
super.dispatchDraw(canvas);
} catch (NullPointerException e) {
FLog.e(ReactConstants.TAG, "NullPointerException when executing ViewGroup.dispatchDraw method", e);
} catch (StackOverflowError e) {
// Adding special exception management for StackOverflowError for logging purposes.
// This will be removed in the future.