realm-js
realm-js copied to clipboard
Test on Android using "release" configuration
What, How & Why?
As part of #6737 I've experienced the Android test app crashing with out of memory exceptions (most likely caused by https://github.com/microsoft/react-native-test-app/issues/2109). As per conversations with the other members of our SDK team, it seems valuable for use to bundle and run our Android app using a "release" configuration, which I suspect will also serve as a workaround for the out-of-memory issue.
This is currently crashing:
Sync Errors 06-28 10:19:24.844 3482 3513 E libc++abi: terminating due to uncaught exception of type facebook::jsi::JSError: expected 'Person' to equal 't' 06-28 10:19:24.844 3482 3513 E libc++abi: 06-28 10:19:24.844 3482 3513 E libc++abi: AssertionError: expected 'Person' to equal 't' 06-28 10:19:24.844 3482 3513 E libc++abi: at proxy trap (native) 06-28 10:19:24.844 3482 3513 E libc++abi: at onError (main.android.jsbundle:1345:9930) 06-28 10:19:24.844 3482 3513 E libc++abi: at anonymous (main.android.jsbundle:635:800)
I believe we've seen this in the past when the C++ stdlib ABI mismatch :thinking_face: Basically the block of native code that catch the JSError and "translates" in into an Error object for the JS runtime is unable to catch the exception. I suspect this has to do with the arguments provide to cmake when we build the prebuild or the binding itself:
https://github.com/realm/realm-js/blob/f8aefa20ebd03a9178b79ea8fa0ed72bf206696e/packages/realm/src/scripts/build/android.ts#L94-L130
https://github.com/realm/realm-js/blob/f8aefa20ebd03a9178b79ea8fa0ed72bf206696e/packages/realm/binding/android/build.gradle#L58-L60
We might need to pass -frtti or -fexceptions as it's done here.
I ran it with -frtti and -fexpections but got the same crash.
Another theory of mine:
- We're failing an expect that normally passes, possibly because this PR produce a minified bundle that might change names (in this case the "Person" class might now be called "t").
- The assertion is written in a callback that we're not wrapping like we do it for the object listeners: https://github.com/realm/realm-js/blob/f8aefa20ebd03a9178b79ea8fa0ed72bf206696e/packages/realm/src/ObjectListeners.ts#L60-L71 ☝️ this explicitly mentions the app aborting if we don't wrap the callback in a try catch and rethrow the error on the event-loop. It's most likely related to the callback passed through
sync.onErrorhere: https://github.com/realm/realm-js/blob/main/integration-tests/tests/src/tests/sync/flexible.ts#L488