fix: make sure native libs are loaded for RN >= 0.80#315
Conversation
cause: loadNativeLibs() in ReactNativeBrownfield.kt is a no-op for RN >= 0.80. All ReactNativeHostManager templates call loadReactNative(application) BEFORE ReactNativeBrownfield.initialize(), so when done through the recommended path the libs load. But loadNativeLibs() — called inside every initialize() overload — silently skips for RN >= 0.80. Any consumer using ReactNativeBrownfield.initialize() directly — with a custom ReactHost, custom packages list, or custom options — skipped native lib loading entirely. Without JNI_OnLoad firing, registerComponentDescriptorsFromEntryPoint and the DefaultTurboModuleManagerDelegate module providers were never assigned, leading to the SIGSEGV during Fabric initialization. ddc011c — moved SoLoader.init() from preloadReactNative() into initialize(application, rnHost, ...). Before this, SoLoader.init() was called inside preloadReactNative after creating the React context. It was consolidated into the initialize entry point. 9908b68 — added the RN_THRESHOLD_VERSION = "0.80.0" gate and removed SoLoader.init() + load() for RN ≥ 0.80, leaving those calls only for < 0.80. ReactNativeBrownfield.initialize() itself had no fallback for the RN ≥ 0.80 case. If anything bypasses ReactNativeHostManager — a custom ReactHost, a consumer calling initialize() directly, or the generated ReactNativeApplicationEntryPoint being unavailable — native libs are never loaded. That's the bug this fix addresses.
hurali97
reviewed
May 8, 2026
Member
hurali97
left a comment
There was a problem hiding this comment.
If I understand correctly, the crash happens because the user does not call the loadReactNative in some integrations, so we are saying that we will do it for them if they do not follow the docs?
Since we are now using Reflection, we will need to ask the User to add this ReactNativeApplicationEntryPoint to their consumer-rules - so this is one extra step for them and we need to document it, see here
Also, let's get rid of RN <=80 support, only keep 80+ changes.
artus9033
requested changes
May 8, 2026
Collaborator
artus9033
left a comment
There was a problem hiding this comment.
LGTM after 1 comment, great job!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
loadNativeLibs()inReactNativeBrownfield.ktis a no-op forRN >= 0.80. AllReactNativeHostManagertemplates callloadReactNative(application)BEFOREReactNativeBrownfield.initialize(), so when done through the recommended path the libs load. ButloadNativeLibs()— called inside everyinitialize()overload — silently skips forRN >= 0.80. Any consumer usingReactNativeBrownfield.initialize()directly — with a customReactHost, custom packages list, or custom options — skipped native lib loading entirely. WithoutJNI_OnLoadfiring,registerComponentDescriptorsFromEntryPointand theDefaultTurboModuleManagerDelegatemodule providers were never assigned, leading to theSIGSEGVduring Fabric initialization.ddc011c— movedSoLoader.init()frompreloadReactNative()intoinitialize(application, rnHost, ...). Before this,SoLoader.init()was called insidepreloadReactNativeafter creating the React context. It was consolidated into the initialize entry point.9908b68— added theRN_THRESHOLD_VERSION = "0.80.0"gate and removedSoLoader.init()+load()forRN ≥ 0.80, leaving those calls only for< 0.80.ReactNativeBrownfield.initialize()itself had no fallback for theRN ≥ 0.80case. If anything bypassesReactNativeHostManager— a customReactHost, a consumer callinginitialize()directly, or the generatedReactNativeApplicationEntryPointbeing unavailable — native libs are never loaded. That's the bug this fix addresses.Test plan
To genuinely reproduce the original crash we'd need one of:
59f472bconsumed by the reporter's enterprise applibreact_codegen_rnscreens.soNeither is practical to set up cleanly. The
SoLoader.init()not yet called crash the GH issue reporter produced is sufficient proof that the same class of bug exists — the fix prevents both the Java exception AND the conditions that led to the original native crash.Closes #283