Realm-js: Support React Native 0.59

Created on 13 Mar 2019  Â·  28Comments  Â·  Source: realm/realm-js

React Native 0.59 is released: https://facebook.github.io/react-native/blog/2019/03/12/releasing-react-native-059

It, among other things, enables us to support 64 bit binaries on React Native Android, but it also seems there are more internal changes we need to handle.

Some headers appear to be gone or have changed: https://github.com/realm/realm-js/blob/master/react-native/ios/RealmReact/RealmReact.mm#L27. It is unclear exactly what is required to fix this.

64 bit support seems to require changes to https://github.com/realm/realm-js/blob/master/react-native/android/src/main/jni/Application.mk#L3 and https://github.com/realm/realm-js/blob/master/react-native/android/build.gradle#L230, but this does not need to be part of the same PR as 0.59 support

See also: https://github.com/realm/realm-js/issues/2281#issuecomment-472349008

T-Enhancement

Most helpful comment

I just tried updating to 0.59.8. Overall things seem OK with Realm on iOS. The only issue I've noticed is Object.assign({}, obj) on a Realm object always returns an empty object. The only way I've been able to create a copy of an object is JSON.parse(JSON.stringify(obj)).

All 28 comments

Arm64 support will require writing a new version of the hook function since that's inherently platform-specific.

On iOS we seem to build fine with 0.59 with no changes but it crashes on startup.

Is there a timeline on this? trying to upgrade our app to RN 0.59.
Thanks!

The issues is with Android 64 bits. If you try to install the 64 bits in your phone the app will crash with:

java.lang.UnsatisfiedLinkError: couldn't find DSO to load: librealmreact.so

Do you have updates on how hard would that be @kneth? I assume people are excited to finally have 64 bits on Android and Google will enforce this soon on the Play Store.

Realm doesn't support 64 binaries on React Native just yet. This is being tracked separately here https://github.com/realm/realm-js/issues/2221 but we plan to address this as soon as possible but I don't have an exact timeframe just yet.

@cmelchior I see, can you recommend a stable/latest RN version that realm fully supports? I see other issues related to compatibility as well e.g. RN 0.58

@cmelchior thanks! We should probably unified it in one issue.

@lodev09 the latest react-native 0.59.x works with the latest realm. The only thing is that you should build only 32 bits variants for Android as 64 bits one will crash.

@ferrannp I'm getting dependency issue during fresh install though e.g. https-proxy-agent. Do you recommend a workaround of adding those in my package.json instead?

They are filed in #2259 and #2281

I just tried updating to 0.59.8. Overall things seem OK with Realm on iOS. The only issue I've noticed is Object.assign({}, obj) on a Realm object always returns an empty object. The only way I've been able to create a copy of an object is JSON.parse(JSON.stringify(obj)).

I am still seeing App launch crash with SoLoader load error:

java.lang.UnsatisfiedLinkError: couldn't find DSO to load: librealmreact.so caused by: dlopen failed: "/data/data/.../lib-main/librealmreact.so" is 32-bit instead of 64-bit

react-native: 0.59.8
realm: 2.28.1
device: Samsung Galaxy S8
Android: 8.0.0

I analyzed the apk and see the librealmreact.so in 64 bit and 32 bit folders.

@testshallpasswork

I am not able to reproduce it using a simple app using Realm JS v2.28.1 and RN v0.59.8.

Are you upgrading an existing app? Not sure how that should cause the issue, just wondering :-)

@kneth It is existing app. I went from realm v2.0.12 to v2.28.1. It builds and runs on Android emulator fine. Also to note, I went from react-native 0.55.4 to 0.59.8. I was thinking on trying to isolate it by building only for 64-bit and seeing if reproduced it.

@kneth I was able to workaround it. I added to default config:

defaultConfig {
// ....
        packagingOptions {
            pickFirst 'lib/x86_64/librealmreact.so'
            pickFirst 'lib/arm64-v8a/librealmreact.so'
        }
// ...
}

and to proguard-rules.pro

-keep class io.realm.react.**

Now, I get a missing "index.android.bundle" issue and it crashes as a result.

I just tried updating to 0.59.8. Overall things seem OK with Realm on iOS. The only issue I've noticed is Object.assign({}, obj) on a Realm object always returns an empty object. The only way I've been able to create a copy of an object is JSON.parse(JSON.stringify(obj)).

I came across this specific issue, but for me doing let obj = { ...realmObj } works for some reason. This does not make sense to me as I was under the impression the spread syntax does Object.assign anyways... but somehow works for me...

Hi,

Please reply for the following :

Just wanted to clarify whether [email protected] supports react-native 0.59 version ?

If not, Any expected date for the release of supported realm version?

Is following error is due to realm version compatibility?
Error during npm install [email protected]

node-pre-gyp ERR! stack Error: Failed to execute 'C:\Program Files\node-v9.11.2-win-x64\node.exe C:\Program Files\node-v9.11.2-win-x64\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js configure --fallback-to-build --module=C:\Program Files\node-v9.11.2-win-x64\node_modules\realm\compiled\node-v59_win32_x64\realm.node --module_name=realm --module_path=C:\Program Files\node-v9.11.2-win-x64\node_modules\realm\compiled\node-v59_win32_x64 --napi_version=3 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v59' (1)
node-pre-gyp ERR! stack at ChildProcess. (C:\Program Files\node-v9.11.2-win-x64\node_modules\realm\node_modules\node-pre-gyp\lib\util\compile.js:83:29)
node-pre-gyp ERR! stack at ChildProcess.emit (events.js:180:13)
node-pre-gyp ERR! stack at maybeClose (internal/child_process.js:936:16)
node-pre-gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:220:5)
node-pre-gyp ERR! System Windows_NT 10.0.17134
node-pre-gyp ERR! command "C:\Program Files\node-v9.11.2-win-x64\node.exe" "C:\Program Files\node-v9.11.2-win-x64\node_modules\realm\node_modules\node-pre-gyp\bin\node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd C:\Program Files\node-v9.11.2-win-x64\node_modules\realm

@cmelchior I think this issue can be closed.

@sreeragk1 You are using node 9 which is the root of your problems. Please use either 8 or 10.

I just tried updating to 0.59.8. Overall things seem OK with Realm on iOS. The only issue I've noticed is Object.assign({}, obj) on a Realm object always returns an empty object. The only way I've been able to create a copy of an object is JSON.parse(JSON.stringify(obj)).

🤣 Lol. It's really fun. We need two process to copy 1 object :( Have any solution to do it?

@sinhpn92 I ended up using

let obj = { ...realmObj }

on my ReactNative project that works for some mysterious reason and writing a shallow copy for my Node project where Babel transpiled the spread operator to Object.assign

function CopyObjShallow(copyFromArray) {
    const objTo = {}
    for (const arrayIndex in copyFromArray) {
        for (const objKey in copyFromArray[arrayIndex]) {
            objTo[objKey] = copyFromArray[arrayIndex][objKey]
        }
    }
    return objTo
}

newObj = CopyObjShallow([realmObj, { key: 123, FieldOne:"value one" }])

Just saw this as all of a sudden my code of

// tmpInfo is a single realm object
tmpBins.push({...tmpInfo})

No longer works.

I had to use:

tmpBins.push({id: tmpInfo.id, key: tmpKey.key})

Does anyone know if it is an issue with Babble or is it a change in realm behavior? I thought that by using the spread operator it would make this an array of anonomous objects, not realm objects but I guess i do need to use a shallow copy or stringify/parse.?

RN 0.59.9, Node 10.16.0, realm 2.28.1

// myObj is an object retrieved from realm, something like {a:"aa", b:"bb"}

const tmp = {...myObj}; //returns {}

const d2 = {e: "EE", f:"FF"};
const tmp2 = {...myObj, ...d2}; //returns {e: "EE", f:"FF"}, so RN object spread still works

I use react-native 0.59.10, and when I call Object.values(RealmResults), it returns an empty array. But it works previously with 0.57.5. Does anyone have an idea?

Yes. You can't do that anymore. I just JSON.stringify(JSON.parse(realm
array)) to get my array out of realm.

On Mon, Jul 29, 2019, 4:27 AM Edward Qian notifications@github.com wrote:

I use react-native 0.59.10, and when I call Object.values(RealmResults),
it returns an empty array. But it works previously with 0.57.5. Does anyone
have an idea?

—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/realm/realm-js/issues/2282?email_source=notifications&email_token=AACSPBWGY7PLH6RZ5MFCO6DQB2SXTA5CNFSM4G5TGML2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD277L3Q#issuecomment-515896814,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AACSPBTBPHMAOQKO5JGOB6TQB2SXTANCNFSM4G5TGMLQ
.

Sorry that's backwards

On Mon, Jul 29, 2019, 8:44 AM Brian Canin brian.canin@gmail.com wrote:

Yes. You can't do that anymore. I just JSON.stringify(JSON.parse(realm
array)) to get my array out of realm.

On Mon, Jul 29, 2019, 4:27 AM Edward Qian notifications@github.com
wrote:

I use react-native 0.59.10, and when I call Object.values(RealmResults),
it returns an empty array. But it works previously with 0.57.5. Does anyone
have an idea?

—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/realm/realm-js/issues/2282?email_source=notifications&email_token=AACSPBWGY7PLH6RZ5MFCO6DQB2SXTA5CNFSM4G5TGML2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD277L3Q#issuecomment-515896814,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AACSPBTBPHMAOQKO5JGOB6TQB2SXTANCNFSM4G5TGMLQ
.

Thanks, but I used Realm Relationships, it will take a long time to parse it to a string. I downgraded the RN to the old version for now, hope there's a better solution.

I just tried updating to 0.59.8. Overall things seem OK with Realm on iOS. The only issue I've noticed is Object.assign({}, obj) on a Realm object always returns an empty object. The only way I've been able to create a copy of an object is JSON.parse(JSON.stringify(obj)).

🤣💔😢😭It is much more weird in my project(2500),when react native "Debug JS Remotely" is turned on , Object.assign will copy data from realm object as expect, but if you turn debugger off, Object.assign will copy nothing, return an empty object {}. Is it probably about javascript runtime?

I'm facing with this issue. Any progress?
I updated current my app to react-native version 0.61 and now it's not working because this issue 🤣💔🤣💔. I'm thinking about other solution like using alternative local database library. Downgrade react-native version is not solution, react-native has a lot of changes and we have to go ahead.

@bachphuc and all: We don't really pay attention to closed issues. So please create a new issue with a repro case. Thanks!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

MihaelIsaev picture MihaelIsaev  Â·  3Comments

timanglade picture timanglade  Â·  3Comments

fever324 picture fever324  Â·  4Comments

max-zu picture max-zu  Â·  3Comments

ashah888 picture ashah888  Â·  3Comments