react-native/ReactCommon
Dratwas 2b0e11cc91 fix indexed RAM bundle (#24967)
Summary:
Co-Authored: zamotany
With React Native 0.59.8 the app keeps crashing with indexed RAM bundle on Android with the following error:

```
2019-05-09 11:58:06.684 2793-2856/? E/AndroidRuntime: FATAL EXCEPTION: mqt_js
    Process: com.ramtestapp, PID: 2793
    com.facebook.jni.CppException: getPropertyAsObject: property '__fbRequireBatchedBridge' is not an Object

    no stack
        at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method)
        at android.os.Handler.handleCallback(Handler.java:873)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:29)
        at android.os.Looper.loop(Looper.java:193)
        at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run(MessageQueueThreadImpl.java:232)
        at java.lang.Thread.run(Thread.java:764)
```

After investigation we found that when using any bundle, let it be non-ram, FIle RAM bundle or Index RAM bundle, the `CatalystInstanceImpl.java` is always using `loadScriptsFromAsset`, which is calling `CatalystInstanceImpl::jniLoadScriptFromAssets` in C++. This method when checking if bundle is a RAM bundle, uses `JniJSModulesUnbundle::isUnbundle` which only check for js-modules/UNBUNDLE - file generated when building File RAM bundle. There is no other logic to handle Indexed RAM bundle, so it figures that the bundle is not RAM, cause there is no js-modules/UNBUNDLE file and tries to load as regular bundle and fails.

In this PR we added check if it is indexed RAM bundle in `jniLoadScriptFromAssets` and handle it if it is.
## Changelog
[Android] [Fixed] fix indexed RAM bundle

Solves https://github.com/facebook/react-native/issues/21282
Pull Request resolved: https://github.com/facebook/react-native/pull/24967

Differential Revision: D15575924

Pulled By: cpojer

fbshipit-source-id: 5ea428e0b793edd8242243f39f933d1092b35260

# Conflicts:
#	ReactCommon/cxxreact/JSIndexedRAMBundle.cpp
2019-06-05 13:53:58 +01:00
..
better Fabric: Introducing Better: For faster, clear and ideomatic codebase 2019-02-08 13:57:33 -08:00
config Reformat xplat build files according to new formatting rules. 2019-01-10 20:00:42 -08:00
cxxreact fix indexed RAM bundle (#24967) 2019-06-05 13:53:58 +01:00
fabric Fabric: Systraces are temporary disabled in Fabric C++ code 2019-02-11 16:01:05 -08:00
jsi Fix crash when calling substring() on a string containing emoji. (#23609) 2019-03-11 21:16:21 +01:00
jsiexecutor Fix portability issues to Linux, FreeBSD, and older libc++ 2019-01-31 17:45:20 -08:00
jsinspector RN: Missing Copyright Headers 2018-10-31 01:37:26 -07:00
microprofiler Fix portability issues to Linux, FreeBSD, and older libc++ 2019-01-31 17:45:20 -08:00
turbomodule/core TM iOS: avoid bad memory access when passing prop name to a lambda 2019-02-11 17:29:14 -08:00
utils Fabric: Use LRU to cache results of ParagraphShadowNode::measure 2019-01-25 17:00:51 -08:00
yoga Make `==` operator for `YGStyle` free function 2019-02-04 10:24:50 -08:00