diff --git a/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/MountItemDispatcher.java b/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/MountItemDispatcher.java index 2370e84ba2f..ca2c7df44f1 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/MountItemDispatcher.java +++ b/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/MountItemDispatcher.java @@ -13,6 +13,7 @@ import static com.facebook.react.fabric.FabricUIManager.ENABLE_FABRIC_LOGS; import static com.facebook.react.fabric.FabricUIManager.IS_DEVELOPMENT_ENVIRONMENT; import android.os.SystemClock; +import android.view.View; import androidx.annotation.AnyThread; import androidx.annotation.NonNull; import androidx.annotation.Nullable; @@ -274,10 +275,17 @@ public class MountItemDispatcher { executeOrEnqueue(mountItem); } catch (Throwable e) { // If there's an exception, we want to log diagnostics in prod and rethrow. - FLog.e(TAG, "dispatchMountItems: caught exception, displaying all MountItems", e); + FLog.e(TAG, "dispatchMountItems: caught exception, displaying mount state", e); for (MountItem m : mountItemsToDispatch) { printMountItem(m, "dispatchMountItems: mountItem"); } + if (mountItem.getSurfaceId() != View.NO_ID) { + SurfaceMountingManager surfaceManager = + mMountingManager.getSurfaceManager(mountItem.getSurfaceId()); + if (surfaceManager != null) { + surfaceManager.printSurfaceState(); + } + } if (ReactIgnorableMountingException.isIgnorable(e)) { ReactSoftExceptionLogger.logSoftException(TAG, e); 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 1f05f824c8f..f93d1c20dca 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 @@ -963,6 +963,25 @@ public class SurfaceMountingManager { return (ViewGroupManager) viewState.mViewManager; } + public void printSurfaceState() { + FLog.e(TAG, "Views created for surface {%d}:", getSurfaceId()); + for (ViewState viewState : mTagToViewState.values()) { + String viewManagerName = + viewState.mViewManager != null ? viewState.mViewManager.getName() : null; + @Nullable View view = viewState.mView; + @Nullable View parent = view != null ? (View) view.getParent() : null; + @Nullable Integer parentTag = parent != null ? parent.getId() : null; + + FLog.e( + TAG, + "<%s id=%d parentTag=%s isRoot=%b />", + viewManagerName, + viewState.mReactTag, + parentTag, + viewState.mIsRoot); + } + } + /** * This class holds view state for react tags. Objects of this class are stored into the {@link * #mTagToViewState}, and they should be updated in the same thread.