Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix WMDatabaseBridge compatibility with Bridgeless architecture #1875

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

limbo56
Copy link

@limbo56 limbo56 commented Jan 13, 2025

This pull request addresses the following NullPointerException that occurs on app reload in the new architecture:

Caused by: java.lang.NullPointerException
    at com.facebook.react.runtime.BridgelessCatalystInstance.getReactQueueConfiguration(BridgelessCatalystInstance.kt:116)
    at com.nozbe.watermelondb.WMDatabaseBridge.invalidate(WMDatabaseBridge.java:251)
    at com.facebook.react.internal.turbomodule.core.TurboModuleManager.invalidate(TurboModuleManager.java:417)
    at com.facebook.react.runtime.ReactInstance.destroy(ReactInstance.java:462)
    at com.facebook.react.runtime.ReactHostImpl.lambda$getOrCreateDestroyTask$41(ReactHostImpl.java:1701)
    at com.facebook.react.runtime.ReactHostImpl.$r8$lambda$JjSvGyrjIWnRG8yxfoNdD4824hc(Unknown Source:0)
    at com.facebook.react.runtime.ReactHostImpl$$ExternalSyntheticLambda32.then(D8$$SyntheticClass:0)
    at com.facebook.react.runtime.internal.bolts.Task$8.run(Task.java:460)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644at java.lang.Thread.run(Thread.java:1012

This issue arises because the new Bridgeless architecture does not support CatalystInstance, as described in the React Native source code.

This change updates WMDatabaseBridge to use runOnJSQueueThread() instead of getCatalystInstance().getReactQueueConfiguration().getJSQueueThread().runOnQueue(), ensuring compatibility with the Bridgeless architecture.

This commit updates WMDatabaseBridge to use getJSMessageQueueThread()
instead of getCatalystInstance().getReactQueueConfiguration().getJSQueueThread().
The change addresses a NullPointerException when running on the Bridgeless architecture,
which no longer supports CatalystInstance.
This change replaces getJSMessageQueueThread().runOnQueue() with runOnJSQueueThread() to improve readability and consistency with updated APIs.

Co-authored-by: @dppo <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant