mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Make default classes load their own so's (#41467)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/41467 Make the DefaultTurboModuleManagerDelegate and the DefaultComponentRegistry load their own so's when they're created. **Motivation:** We are going to use these two classes in Meta apps. And Meta apps will not invoke DefaultNewArchitectureEntryPoint.load. Changelog: [Internal] Reviewed By: mdvacca Differential Revision: D51036133 fbshipit-source-id: 5ebd4d3b85f435229c9b5950493310aa7fa36ba0
This commit is contained in:
committed by
Facebook GitHub Bot
parent
66051047e0
commit
1394cf7da7
+4
@@ -27,6 +27,10 @@ private constructor(componentFactory: ComponentFactory) {
|
||||
|
||||
@DoNotStrip private external fun initHybrid(componentFactory: ComponentFactory): HybridData
|
||||
|
||||
init {
|
||||
DefaultSoLoader.maybeLoadSoLibrary()
|
||||
}
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
@DoNotStrip
|
||||
|
||||
+4
-8
@@ -8,7 +8,6 @@
|
||||
package com.facebook.react.defaults
|
||||
|
||||
import com.facebook.react.config.ReactFeatureFlags
|
||||
import com.facebook.soloader.SoLoader
|
||||
|
||||
/**
|
||||
* A utility class that serves as an entry point for users setup the New Architecture.
|
||||
@@ -27,8 +26,7 @@ object DefaultNewArchitectureEntryPoint {
|
||||
fun load(
|
||||
turboModulesEnabled: Boolean = true,
|
||||
fabricEnabled: Boolean = true,
|
||||
bridgelessEnabled: Boolean = false,
|
||||
dynamicLibraryName: String = "appmodules",
|
||||
bridgelessEnabled: Boolean = false
|
||||
) {
|
||||
ReactFeatureFlags.useTurboModules = turboModulesEnabled
|
||||
ReactFeatureFlags.enableFabricRenderer = fabricEnabled
|
||||
@@ -42,23 +40,21 @@ object DefaultNewArchitectureEntryPoint {
|
||||
this.privateConcurrentReactEnabled = fabricEnabled
|
||||
this.privateBridgelessEnabled = bridgelessEnabled
|
||||
|
||||
SoLoader.loadLibrary("react_newarchdefaults")
|
||||
SoLoader.loadLibrary(dynamicLibraryName)
|
||||
DefaultSoLoader.maybeLoadSoLibrary()
|
||||
}
|
||||
|
||||
@Deprecated(
|
||||
message =
|
||||
"Calling DefaultNewArchitectureEntryPoint.load() with different fabricEnabled and concurrentReactEnabled is deprecated. Please use a single flag for both Fabric and Concurrent React",
|
||||
replaceWith = ReplaceWith("load(turboModulesEnabled, fabricEnabled, dynamicLibraryName)"),
|
||||
replaceWith = ReplaceWith("load(turboModulesEnabled, fabricEnabled, bridgelessEnabled)"),
|
||||
level = DeprecationLevel.WARNING)
|
||||
fun load(
|
||||
turboModulesEnabled: Boolean = true,
|
||||
fabricEnabled: Boolean = true,
|
||||
bridgelessEnabled: Boolean = false,
|
||||
@Suppress("UNUSED_PARAMETER") concurrentReactEnabled: Boolean = true,
|
||||
dynamicLibraryName: String = "appmodules",
|
||||
) {
|
||||
load(turboModulesEnabled, fabricEnabled, bridgelessEnabled, dynamicLibraryName)
|
||||
load(turboModulesEnabled, fabricEnabled, bridgelessEnabled)
|
||||
}
|
||||
|
||||
private var privateFabricEnabled: Boolean = false
|
||||
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
package com.facebook.react.defaults
|
||||
|
||||
import com.facebook.soloader.SoLoader
|
||||
|
||||
internal class DefaultSoLoader {
|
||||
companion object {
|
||||
@Synchronized
|
||||
@JvmStatic
|
||||
fun maybeLoadSoLibrary() {
|
||||
SoLoader.loadLibrary("react_newarchdefaults")
|
||||
try {
|
||||
SoLoader.loadLibrary("appmodules")
|
||||
} catch (e: UnsatisfiedLinkError) {
|
||||
// ignore: DefaultTurboModuleManagerDelegate is still used in apps that don't have
|
||||
// appmodules.so
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+5
@@ -49,4 +49,9 @@ private constructor(
|
||||
override fun build(context: ReactApplicationContext, packages: List<ReactPackage>) =
|
||||
DefaultTurboModuleManagerDelegate(context, packages, eagerInitModuleNames)
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
override fun maybeLoadOtherSoLibraries() {
|
||||
DefaultSoLoader.maybeLoadSoLibrary()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user