Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support React Native 0.59 #2282

Closed
cmelchior opened this issue Mar 13, 2019 · 28 comments
Closed

Support React Native 0.59 #2282

cmelchior opened this issue Mar 13, 2019 · 28 comments
Assignees
Milestone

Comments

@cmelchior
Copy link
Contributor

cmelchior commented Mar 13, 2019

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: #2281 (comment)

@tgoyne
Copy link
Member

tgoyne commented Mar 13, 2019

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

@tgoyne
Copy link
Member

tgoyne commented Mar 13, 2019

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

@lodev09
Copy link

lodev09 commented Mar 14, 2019

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

@ferrannp
Copy link

ferrannp commented Mar 14, 2019

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.

@cmelchior
Copy link
Contributor Author

Realm doesn't support 64 binaries on React Native just yet. This is being tracked separately here #2221 but we plan to address this as soon as possible but I don't have an exact timeframe just yet.

@lodev09
Copy link

lodev09 commented Mar 14, 2019

@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

@ferrannp
Copy link

@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.

@lodev09
Copy link

lodev09 commented Mar 14, 2019

@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

@dkpalmer
Copy link

dkpalmer commented May 24, 2019

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)).

@brianinator
Copy link

brianinator commented Jun 3, 2019

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.

@kneth
Copy link
Contributor

kneth commented Jun 4, 2019

@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 :-)

@brianinator
Copy link

@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.

@brianinator
Copy link

@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.

@tomsjansons
Copy link

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...

@sreeragk1
Copy link

Hi,

Please reply for the following :

Just wanted to clarify whether realm@2.27.0 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 realm@2.27.0

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

@ferrannp
Copy link

@cmelchior I think this issue can be closed.

@kneth
Copy link
Contributor

kneth commented Jun 25, 2019

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

@kneth kneth closed this as completed Jun 25, 2019
@sinhpn92
Copy link

sinhpn92 commented Jul 2, 2019

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?

@tomsjansons
Copy link

tomsjansons commented Jul 2, 2019

@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" }])

@cyphire
Copy link

cyphire commented Jul 9, 2019

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.?

@MrScorp
Copy link

MrScorp commented Jul 12, 2019

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

@sumyfly
Copy link

sumyfly commented Jul 29, 2019

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?

@cyphire
Copy link

cyphire commented Jul 29, 2019 via email

@cyphire
Copy link

cyphire commented Jul 29, 2019 via email

@sumyfly
Copy link

sumyfly commented Jul 30, 2019

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.

@YaoHuiJi
Copy link

YaoHuiJi commented Aug 30, 2019

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?

@bachphuc
Copy link

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.

@bmunkholm
Copy link
Contributor

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

@realm realm locked as off-topic and limited conversation to collaborators Mar 20, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests