Skip to content

Commit

Permalink
Fix NullPointerException thrown on startup (#43293)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
javache authored and facebook-github-bot committed Mar 4, 2024
1 parent adc9e5b commit 5f45700
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
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 {
Expand All @@ -28,15 +26,6 @@ public void dispatchMessage(Message msg) {
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);
}
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
Expand Down

0 comments on commit 5f45700

Please sign in to comment.