mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Fix NullPointerException thrown on startup (#43293)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/43293 Was debugging this, and found that this exception was being thrown due to `DefaultBindingsInstaller`, which was an invalid hybrid object. The ReactInstance initializer fully supports this being null, so let's use that as default. Changelog: [Android][Fixed] NullPointerException is no longer ignored in MessageQueueThreadHandler Reviewed By: sammy-SC Differential Revision: D54434417 fbshipit-source-id: 52417b390061eface0f0578e32796d3a85303e03
This commit is contained in:
committed by
Facebook GitHub Bot
parent
adc9e5b0fa
commit
5f45700bd0
-11
@@ -10,8 +10,6 @@ package com.facebook.react.bridge.queue;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.os.Message;
|
||||
import com.facebook.common.logging.FLog;
|
||||
import com.facebook.react.common.ReactConstants;
|
||||
|
||||
/** Handler that can catch and dispatch Exceptions to an Exception handler. */
|
||||
public class MessageQueueThreadHandler extends Handler {
|
||||
@@ -28,15 +26,6 @@ public class MessageQueueThreadHandler extends Handler {
|
||||
try {
|
||||
super.dispatchMessage(msg);
|
||||
} catch (Exception e) {
|
||||
if (e instanceof NullPointerException) {
|
||||
FLog.e(
|
||||
ReactConstants.TAG,
|
||||
"Caught NullPointerException when dispatching message in MessageQueueThreadHandler. This is likely caused by runnable"
|
||||
+ "(msg.callback) being nulled in Android Handler after dispatching and before handling (see T170239922 for more details)."
|
||||
+ "Currently we observe that it only happen once which is during initialisation. Due to fixing probably involve Android "
|
||||
+ "System code, we decide to ignore here for now and print an error message for debugging purpose in case this cause more serious issues in future.");
|
||||
return;
|
||||
}
|
||||
mExceptionHandler.handleException(e);
|
||||
}
|
||||
}
|
||||
|
||||
-20
@@ -1,20 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
package com.facebook.react.defaults
|
||||
|
||||
import com.facebook.jni.annotations.DoNotStrip
|
||||
import com.facebook.react.common.annotations.UnstableReactNativeAPI
|
||||
import com.facebook.react.runtime.BindingsInstaller
|
||||
|
||||
/**
|
||||
* A utility class that provides users a default [BindingsInstaller] class that's used to initialize
|
||||
* [ReactHostDelegate]
|
||||
*/
|
||||
@DoNotStrip
|
||||
@UnstableReactNativeAPI
|
||||
public class DefaultBindingsInstaller : BindingsInstaller(null) {}
|
||||
+1
-1
@@ -43,7 +43,7 @@ public class DefaultReactHostDelegate(
|
||||
override val jsBundleLoader: JSBundleLoader,
|
||||
override val reactPackages: List<ReactPackage> = emptyList(),
|
||||
override val jsRuntimeFactory: JSRuntimeFactory = HermesInstance(),
|
||||
override val bindingsInstaller: BindingsInstaller = DefaultBindingsInstaller(),
|
||||
override val bindingsInstaller: BindingsInstaller? = null,
|
||||
private val reactNativeConfig: ReactNativeConfig = ReactNativeConfig.DEFAULT_CONFIG,
|
||||
private val exceptionHandler: (Exception) -> Unit = {},
|
||||
override val turboModuleManagerDelegateBuilder: ReactPackageTurboModuleManagerDelegate.Builder
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
#include <condition_variable>
|
||||
#include <mutex>
|
||||
|
||||
#include <fb/log.h>
|
||||
#include <fbjni/NativeRunnable.h>
|
||||
#include <fbjni/fbjni.h>
|
||||
#include <jsi/jsi.h>
|
||||
|
||||
@@ -42,10 +42,6 @@ class JMessageQueueThread : public MessageQueueThread {
|
||||
*/
|
||||
void quitSynchronous() override;
|
||||
|
||||
JavaMessageQueueThread::javaobject jobj() {
|
||||
return m_jobj.get();
|
||||
}
|
||||
|
||||
private:
|
||||
jni::global_ref<JavaMessageQueueThread::javaobject> m_jobj;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user