Add logging in ReactInstanceManager.onHostPause when activity is incorrectly null (#48226)

Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48226

Adding logging to onHostPause to help diagnose cases when the activity is incorrectly null.

Reviewed By: fkgozali

Differential Revision: D67123351

fbshipit-source-id: f694a3a89e4584776050f6bca2f33f2805528d4b
This commit is contained in:
Maddie Lord
2024-12-13 13:35:08 -08:00
committed by Facebook GitHub Bot
parent 81c74cd35f
commit c2fd35a442
@@ -651,6 +651,16 @@ public class ReactInstanceManager {
@ThreadConfined(UI)
public void onHostPause(@Nullable Activity activity) {
if (mRequireActivity) {
if (mCurrentActivity == null) {
String message =
"ReactInstanceManager.onHostPause called with null activity, expected:"
+ mCurrentActivity.getClass().getSimpleName();
FLog.e(TAG, message);
StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace();
for (StackTraceElement element : stackTrace) {
FLog.e(TAG, element.toString());
}
}
Assertions.assertCondition(mCurrentActivity != null);
}
if (mCurrentActivity != null) {