mirror of
https://github.com/facebook/react-native.git
synced 2026-11-18 20:19:07 +00:00
Summary: [Android] [Added] - Release underlying resources when JS instance is GC'ed on Android D15826082 was reverted because it introduced a crash in Ads Manager for Android (see P67222724). This diff fixes the crash and re-applies D15826082. The problem was that `jni::findClassStatic` in the destructor of BlobCollector.cpp couldn't find the Java class `com/facebook/react/modules/blob/BlobModule` and crashed the app. JNI didn't seem to have access to the Java class loader probably because the destructor was called from a non-Java thread (https://our.intern.facebook.com/intern/wiki/Fbjni/environment-and-thread-management/?vitals_event=wiki_click_navigation_link#threads). The fix is to wrap the code in the destructor inside `ThreadScope::WithClassLoader `, which will allow to run code that has full access to Java as though you were running in a Java thread. Reviewed By: shergin Differential Revision: D16122059 fbshipit-source-id: 12f14fa4a58218242a482c2c3e2149bb6770e8ec
41 lines
1.6 KiB
Python
41 lines
1.6 KiB
Python
load("//tools/build_defs/oss:rn_defs.bzl", "KEYSTORE_TARGET", "react_native_dep", "react_native_target", "rn_android_binary", "rn_android_library", "rn_android_resource")
|
|
|
|
rn_android_binary(
|
|
name = "app",
|
|
keystore = KEYSTORE_TARGET,
|
|
manifest = "src/main/AndroidManifest.xml",
|
|
deps = [
|
|
":rntester-lib",
|
|
],
|
|
)
|
|
|
|
rn_android_library(
|
|
name = "rntester-lib",
|
|
srcs = glob(["src/main/java/**/*.java"]),
|
|
is_androidx = True,
|
|
deps = [
|
|
":res",
|
|
react_native_dep("third-party/android/androidx:annotation"),
|
|
react_native_dep("third-party/android/androidx:appcompat"),
|
|
react_native_dep("third-party/android/androidx:core"),
|
|
react_native_dep("third-party/android/androidx:fragment"),
|
|
react_native_dep("third-party/android/androidx:legacy-support-core-ui"),
|
|
react_native_dep("third-party/android/androidx:legacy-support-core-utils"),
|
|
react_native_dep("third-party/java/jsr-305:jsr-305"),
|
|
react_native_target("java/com/facebook/react:react"),
|
|
react_native_target("java/com/facebook/react/common:build_config"),
|
|
react_native_target("java/com/facebook/react/modules/core:core"),
|
|
react_native_target("java/com/facebook/react/views/text:text"),
|
|
react_native_target("java/com/facebook/react/shell:shell"),
|
|
react_native_target("jni/prebuilt:android-jsc"),
|
|
# .so files are prebuilt by Gradle with `./gradlew :ReactAndroid:packageReactNdkLibsForBuck`
|
|
react_native_target("jni/prebuilt:reactnative-libs"),
|
|
],
|
|
)
|
|
|
|
rn_android_resource(
|
|
name = "res",
|
|
package = "com.facebook.react.uiapp",
|
|
res = "src/main/res",
|
|
)
|