mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Log created views with mounting errors
Summary: Displays views from the surface mounting manager after we hit a crash during mounting. This change should help with debugging mounting crashes (e.g. when view is added before removal) Changelog: [Internal] Reviewed By: cortinico Differential Revision: D30681339 fbshipit-source-id: f83cecaf8e418a2fa5aa0713513c51bb1be77013
This commit is contained in:
committed by
Facebook GitHub Bot
parent
963254e2ec
commit
8b4f5073a1
+9
-1
@@ -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);
|
||||
|
||||
+19
@@ -963,6 +963,25 @@ public class SurfaceMountingManager {
|
||||
return (ViewGroupManager<ViewGroup>) 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.
|
||||
|
||||
Reference in New Issue
Block a user