mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
88e18b6c8d
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