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
This commit is contained in:
Joshua Gross
2020-09-18 16:35:46 -07:00
committed by Facebook GitHub Bot
parent fa44c46e37
commit 03448715af
@@ -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();