From 03448715af55a52a67fd218f55cfc218e8d2591b Mon Sep 17 00:00:00 2001 From: Joshua Gross Date: Fri, 18 Sep 2020 16:35:46 -0700 Subject: [PATCH] Have BatchMountItem log the exact item that crashes Summary: Because BatchMountItem executes many items, sometimes it's unclear which MountItem causes a crash. Catch and log the exact item. This shouldn't cause perf regressions because we have a try/catch block in FabricUIManager where execute is called. Changelog: [Internal] Reviewed By: shergin Differential Revision: D23775500 fbshipit-source-id: c878e085c23d3d3a7ef02a34e5aca57759376aa6 --- .../mounting/mountitems/BatchMountItem.java | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/mountitems/BatchMountItem.java b/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/mountitems/BatchMountItem.java index d685be1ae02..fc908e2deed 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/mountitems/BatchMountItem.java +++ b/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/mountitems/BatchMountItem.java @@ -8,6 +8,7 @@ package com.facebook.react.fabric.mounting.mountitems; import androidx.annotation.NonNull; +import com.facebook.common.logging.FLog; import com.facebook.proguard.annotations.DoNotStrip; import com.facebook.react.bridge.ReactMarker; import com.facebook.react.bridge.ReactMarkerConstants; @@ -70,8 +71,20 @@ public class BatchMountItem implements MountItem { public void execute(@NonNull MountingManager mountingManager) { beginMarkers("mountViews"); - for (int mountItemIndex = 0; mountItemIndex < mSize; mountItemIndex++) { - mMountItems[mountItemIndex].execute(mountingManager); + int mountItemIndex = 0; + try { + for (; mountItemIndex < mSize; mountItemIndex++) { + mMountItems[mountItemIndex].execute(mountingManager); + } + } catch (RuntimeException e) { + FLog.e( + TAG, + "Caught exception executing mountItem @" + + mountItemIndex + + ": " + + mMountItems[mountItemIndex].toString(), + e); + throw e; } endMarkers();