|
25 | 25 | import android.view.ViewParent; |
26 | 26 | import android.view.ViewStructure; |
27 | 27 | import android.view.animation.Animation; |
| 28 | +import android.util.Log; |
28 | 29 | import androidx.annotation.Nullable; |
29 | 30 | import com.facebook.common.logging.FLog; |
30 | 31 | import com.facebook.infer.annotation.Assertions; |
@@ -655,11 +656,7 @@ public void onViewRemoved(View child) { |
655 | 656 | boolean matches = java.util.Arrays.stream(removalTrackedChildrenIDs) |
656 | 657 | .anyMatch(nativeID::equals); |
657 | 658 | if (matches) { |
658 | | - StringBuilder stackTraceBuilder = new StringBuilder(); |
659 | | - for (StackTraceElement element : new Exception().getStackTrace()) { |
660 | | - stackTraceBuilder.append("\n at ").append(element.toString()); |
661 | | - } |
662 | | - String stackTrace = stackTraceBuilder.toString(); |
| 659 | + String stackTrace = android.util.Log.getStackTraceString(new Throwable()); |
663 | 660 | FLog.e(ReactConstants.TAG, "onViewRemoved of one of the tracked children: " + nativeID + " with stack trace: " + "\n" + stackTrace); |
664 | 661 | } |
665 | 662 | } |
@@ -1035,11 +1032,12 @@ protected void dispatchDraw(Canvas canvas) { |
1035 | 1032 | try { |
1036 | 1033 | ancestry = describeViewAncestry(this); |
1037 | 1034 | } catch (Throwable ignore) {} |
1038 | | - FLog.e(TAG, "NullPointerException in dispatchDraw of " + e.getStackTrace() + getClass().getName() + ": " + e.getMessage() + "\n Failing view ancestry: " + ancestry); |
| 1035 | + FLog.e(TAG, "NullPointerException in dispatchDraw of " + getClass().getName() + ": " + e.getMessage() + "\n Failing view ancestry: " + ancestry); |
1039 | 1036 | FLog.e(TAG, "Child info: \n" + childrenCountInfo + "\n" + childrenViewInfo); |
| 1037 | + String caughtErrorStackTrace = android.util.Log.getStackTraceString(e); |
1040 | 1038 | throw new NullPointerException( |
1041 | | - "NullPointerException in dispatchDraw of " + getClass().getName() + ": " + e.getMessage() + "\n" + e.getStackTrace()); |
1042 | | - } |
| 1039 | + "NullPointerException in dispatchDraw of " + getClass().getName() + ": " + e.getMessage() + "\n" + caughtErrorStackTrace); |
| 1040 | +§ } |
1043 | 1041 | } |
1044 | 1042 |
|
1045 | 1043 | // Helper function to debug NPEs in dispatchDraw |
|
0 commit comments