Skip to content

Commit 5f45700

Browse files
javachefacebook-github-bot
authored andcommitted
Fix NullPointerException thrown on startup (#43293)
Summary: Pull Request resolved: #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
1 parent adc9e5b commit 5f45700

File tree

5 files changed

+1
-37
lines changed

5 files changed

+1
-37
lines changed

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/queue/MessageQueueThreadHandler.java

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
import android.os.Handler;
1111
import android.os.Looper;
1212
import android.os.Message;
13-
import com.facebook.common.logging.FLog;
14-
import com.facebook.react.common.ReactConstants;
1513

1614
/** Handler that can catch and dispatch Exceptions to an Exception handler. */
1715
public class MessageQueueThreadHandler extends Handler {
@@ -28,15 +26,6 @@ public void dispatchMessage(Message msg) {
2826
try {
2927
super.dispatchMessage(msg);
3028
} catch (Exception e) {
31-
if (e instanceof NullPointerException) {
32-
FLog.e(
33-
ReactConstants.TAG,
34-
"Caught NullPointerException when dispatching message in MessageQueueThreadHandler. This is likely caused by runnable"
35-
+ "(msg.callback) being nulled in Android Handler after dispatching and before handling (see T170239922 for more details)."
36-
+ "Currently we observe that it only happen once which is during initialisation. Due to fixing probably involve Android "
37-
+ "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.");
38-
return;
39-
}
4029
mExceptionHandler.handleException(e);
4130
}
4231
}

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/defaults/DefaultBindingsInstaller.kt

Lines changed: 0 additions & 20 deletions
This file was deleted.

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/defaults/DefaultReactHostDelegate.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public class DefaultReactHostDelegate(
4343
override val jsBundleLoader: JSBundleLoader,
4444
override val reactPackages: List<ReactPackage> = emptyList(),
4545
override val jsRuntimeFactory: JSRuntimeFactory = HermesInstance(),
46-
override val bindingsInstaller: BindingsInstaller = DefaultBindingsInstaller(),
46+
override val bindingsInstaller: BindingsInstaller? = null,
4747
private val reactNativeConfig: ReactNativeConfig = ReactNativeConfig.DEFAULT_CONFIG,
4848
private val exceptionHandler: (Exception) -> Unit = {},
4949
override val turboModuleManagerDelegateBuilder: ReactPackageTurboModuleManagerDelegate.Builder

packages/react-native/ReactAndroid/src/main/jni/react/jni/JMessageQueueThread.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
#include <condition_variable>
1111
#include <mutex>
1212

13-
#include <fb/log.h>
1413
#include <fbjni/NativeRunnable.h>
1514
#include <fbjni/fbjni.h>
1615
#include <jsi/jsi.h>

packages/react-native/ReactAndroid/src/main/jni/react/jni/JMessageQueueThread.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,6 @@ class JMessageQueueThread : public MessageQueueThread {
4242
*/
4343
void quitSynchronous() override;
4444

45-
JavaMessageQueueThread::javaobject jobj() {
46-
return m_jobj.get();
47-
}
48-
4945
private:
5046
jni::global_ref<JavaMessageQueueThread::javaobject> m_jobj;
5147
};

0 commit comments

Comments
 (0)