From b0ec3505685a15495d53eae2749b0da40c33b0d9 Mon Sep 17 00:00:00 2001 From: Joshua Gross Date: Thu, 28 Jan 2021 16:19:03 -0800 Subject: [PATCH] Detect startSurface race-conditions and warn silently Summary: Crash in debug, log a warning and continue in production. Changelog: [Internal] Differential Revision: D26133167 fbshipit-source-id: 60279363a3e90d592e7ddbde188c13cda89c28c6 --- .../react/fabric/mounting/SurfaceMountingManager.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/SurfaceMountingManager.java b/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/SurfaceMountingManager.java index 0231061f4a2..d5d937f8eda 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/SurfaceMountingManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/SurfaceMountingManager.java @@ -147,7 +147,14 @@ public class SurfaceMountingManager { return; } - if (rootView.getId() != View.NO_ID) { + if (rootView.getId() == mSurfaceId) { + ReactSoftException.logSoftException( + TAG, + new IllegalViewOperationException( + "Race condition in addRootView detected. Trying to set an id of [" + + mSurfaceId + + "] on the RootView, but that id has already been set. ")); + } else if (rootView.getId() != View.NO_ID) { FLog.e( TAG, "Trying to add RootTag to RootView that already has a tag: existing tag: [%d] new tag: [%d]",