Skip to content

Commit

Permalink
CxxReactPackage: Load So's during class loads (#41674)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #41674

The problem: The Java runtime couldn't find CatalystCxxReactPackage.initHybrid.

Why: I think is because CxxReactPackage loads CatalystCxxReactPackage's so in its constructor. This might be too late to load the derived class's so.

So, I just switched derived delegates to load the so in the static initializer (i.e: the recomended approch for so loading):

https://www.internalfb.com/code/fbsource/[91c4e41c49ed191ac864250ccaec52c01ddaeccc]/fbandroid/libraries/soloader/java/com/facebook/soloader/SoLoader.java?lines=52-54%2C60-61%2C63-67

This way:
1. The So's are loaded plenty early (the method not found error went away).
2. We don't create our own so loading infra, which complicates this abstraction, and makes it harder to work with, even more.

Changelog: [Internal]

Reviewed By: javache

Differential Revision: D51550622

fbshipit-source-id: f4782d6fa9387f21fbf611191e9483e2a58b3a34
  • Loading branch information
RSNara authored and facebook-github-bot committed Nov 28, 2023
1 parent 00e7035 commit 4c1bdea
Showing 1 changed file with 0 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,9 @@ abstract class CxxReactPackage {
protected abstract fun initHybrid(): HybridData

protected constructor() {
maybeLoadOtherSoLibraries()
mHybridData = initHybrid()
}

@Synchronized protected open fun maybeLoadOtherSoLibraries(): Unit {}

companion object {
init {
SoLoader.loadLibrary("react_cxxreactpackage")
Expand Down

0 comments on commit 4c1bdea

Please sign in to comment.