realm / realm-js

Realm is a mobile database: an alternative to SQLite & key-value stores
https://realm.io
Apache License 2.0
5.79k stars 577 forks source link

realm.create crashing the android app #4399

Closed myousufq closed 2 years ago

myousufq commented 2 years ago

How frequently does the bug occur?

All the time

Description

Hi everyone,

The example below is working fine while in debug is enabled using React Native Debugger but the app is crashing in normal mode for Android only. Can someone assist me resolve this issue, please?

  const Cat = {
    name: "Cat",
    properties: {
      _id: "string",
      name: "string",
      age: "int",
      type: "string",
    },
  };
const db = await Realm.open({
schema: [Cat],
schemaVersion: 1,
});
  const cats = db.objects("Cat");
  console.log(`There are ${cats.length} cats`);```

db.write(() => {

 db.create("Cat", {  // this step is causing the crash
  _id: '1',
  name: "Alice",
  age: 14,
  type: "Calico",
});

});


**Package.json**

"@codler/react-native-keyboard-aware-scroll-view": "^2.0.1",
    "@eva-design/eva": "^2.1.0",
    "@expo/react-native-action-sheet": "^3.9.0",
    "@fortawesome/fontawesome-pro": "^5.15.4",
    "@fortawesome/fontawesome-svg-core": "^1.2.35",
    "@fortawesome/free-brands-svg-icons": "^5.15.3",
    "@fortawesome/free-solid-svg-icons": "^5.15.3",
    "@fortawesome/pro-duotone-svg-icons": "^5.15.4",
    "@fortawesome/pro-light-svg-icons": "^5.15.3",
    "@fortawesome/pro-regular-svg-icons": "^5.15.3",
    "@fortawesome/pro-solid-svg-icons": "^5.15.4",
    "@fortawesome/react-native-fontawesome": "^0.2.6",
    "@freakycoder/react-native-progressive-fast-image": "^0.2.5",
    "@react-native-community/async-storage": "^1.12.1",
    "@react-native-community/geolocation": "^2.0.2",
    "@react-native-community/masked-view": "^0.1.11",
    "@react-native-community/netinfo": "^6.0.0",
    "@react-native-community/push-notification-ios": "^1.8.0",
    "@react-native-firebase/analytics": "^14.5.0",
    "@react-native-firebase/app": "^14.5.0",
    "@react-navigation/bottom-tabs": "^5.11.11",
    "@react-navigation/drawer": "^5.12.5",
    "@react-navigation/material-bottom-tabs": "^5.3.15",
    "@react-navigation/material-top-tabs": "^5.3.15",
    "@react-navigation/native": "^5.9.4",
    "@react-navigation/stack": "^5.14.5",
    "@redux-offline/redux-offline": "^2.6.0",
    "@ui-kitten/components": "^5.1.0",
    "@ui-kitten/eva-icons": "^5.1.0",
    "ajv": "7.1.0",
    "ajv-errors": "^3.0.0",
    "ajv-formats": "^2.1.1",
    "axios": "^0.21.1",
    "crypto-js": "^4.0.0",
    "d3-shape": "^2.1.0",
    "install": "^0.13.0",
    "jsc-android": "^250230.2.1",
    "lodash": "^4.17.21",
    "lpf": "^1.0.0",
    "moment": "^2.29.1",
    "moment-timezone": "^0.5.33",
    "npm": "^7.18.1",
    "prop-types": "^15.7.2",
    "ramda": "^0.27.1",
    "raygun4reactnative": "^1.1.5",
    "react": "17.0.2",
    "react-native": "0.66.4",
    "react-native-build-config": "^0.3.2",
    "react-native-bundle-splitter": "^2.1.0",
    "react-native-clean-project": "^3.6.4",
    "react-native-date-picker": "^3.3.1",
    "react-native-document-picker": "^5.0.4",
    "react-native-dropdownalert": "^4.3.0",
    "react-native-fast-image": "^8.5.11",
    "react-native-file-viewer": "^2.1.4",
    "react-native-fontawesome-pro": "^2.1.0",
    "react-native-fs": "^2.18.0",
    "react-native-gesture-handler": "^1.10.3",
    "react-native-google-places-autocomplete": "^2.2.0",
    "react-native-linear-gradient": "^2.5.6",
    "react-native-maps": "^0.28.0",
    "react-native-notifications": "^4.1.3",
    "react-native-pager-view": "^5.4.9",
    "react-native-paper": "^4.9.1",
    "react-native-permissions": "^3.1.0",
    "react-native-reanimated": "^2.2.0",
    "react-native-redash": "^16.0.11",
    "react-native-safe-area-context": "^3.3.2",
    "react-native-screens": "^3.3.0",
    "react-native-sensitive-info": "git+https://github.com/mCodex/react-native-sensitive-info.git#keystore",
    "react-native-splash-screen": "^3.2.0",
    "react-native-svg": "^12.1.1",
    "react-native-tab-view": "^3.0.1",
    "react-native-unimodules": "^0.13.3",
    "react-native-vector-icons": "^8.1.0",
    "react-native-webview": "^11.14.0",
    "react-redux": "^7.2.4",
    "realm": "^10.13.0",
    "redux": "^4.1.0",
    "redux-logger": "^3.0.6",
    "redux-persist": "^6.0.0",
    "redux-persist-sensitive-storage": "^1.0.0",
    "redux-saga": "^1.1.3",
    "reduxsauce": "^1.2.0",
    "reselect": "^4.0.0",
    "rn-fetch-blob": "^0.12.0",
    "rxjs": "^7.1.0",
    "underscore": "^1.13.1",
    "use-debounce": "^7.0.1"

### Stacktrace & log output
```shell
Type    Time    PID Tag Message
    11:08:52.623    32560   libc    Fatal signal 7 (SIGBUS), code 1 (BUS_ADRALN), fault addr 0xfffffffb in tid 1370 (mqt_js), pid 32560 (com.myfarmapp)

    11:08:52.872    1434    DEBUG   pid: 32560, tid: 1370, name: mqt_js  >>> com.myfarmapp <<<

    11:08:52.878    1434    DEBUG         #00 pc 002e3aa4  /data/app/com.myfarmapp-rtw-Mt49iUsbq8iCz8dIdw==/lib/arm/libjsc.so!libjsc.so (offset 0x75000) (BuildId: 184cbb2602409d8d87c82858f210bcb5255b9e8c)

    11:08:52.878    1434    DEBUG         #01 pc 002e118f  /data/app/com.myfarmapp-rtw-Mt49iUsbq8iCz8dIdw==/lib/arm/libjsc.so!libjsc.so (offset 0x75000) (BuildId: 184cbb2602409d8d87c82858f210bcb5255b9e8c)

    11:08:52.878    1434    DEBUG         #02 pc 002e0ec5  /data/app/com.myfarmapp-rtw-Mt49iUsbq8iCz8dIdw==/lib/arm/libjsc.so!libjsc.so (offset 0x75000) (BuildId: 184cbb2602409d8d87c82858f210bcb5255b9e8c)

    11:08:52.878    1434    DEBUG         #03 pc 000718bd  /data/app/com.myfarmapp-rtw-Mt49iUsbq8iCz8dIdw==/lib/arm/libjsc.so (BuildId: 184cbb2602409d8d87c82858f210bcb5255b9e8c)

    11:08:52.879    1434    DEBUG         #04 pc 000715e9  /data/app/com.myfarmapp-rtw-Mt49iUsbq8iCz8dIdw==/lib/arm/libjsc.so (BuildId: 184cbb2602409d8d87c82858f210bcb5255b9e8c)

    11:08:52.879    1434    DEBUG         #05 pc 002891bf  /data/app/com.myfarmapp-rtw-Mt49iUsbq8iCz8dIdw==/lib/arm/libjsc.so!libjsc.so (offset 0x75000) (BuildId: 184cbb2602409d8d87c82858f210bcb5255b9e8c)

    11:08:52.879    1434    DEBUG         #06 pc 00288d9d  /data/app/com.myfarmapp-rtw-Mt49iUsbq8iCz8dIdw==/lib/arm/libjsc.so!libjsc.so (offset 0x75000) (BuildId: 184cbb2602409d8d87c82858f210bcb5255b9e8c)

    11:08:52.879    1434    DEBUG         #07 pc 002892f1  /data/app/com.myfarmapp-rtw-Mt49iUsbq8iCz8dIdw==/lib/arm/libjsc.so!libjsc.so (offset 0x75000) (BuildId: 184cbb2602409d8d87c82858f210bcb5255b9e8c)

    11:08:52.879    1434    DEBUG         #08 pc 0027d381  /data/app/com.myfarmapp-rtw-Mt49iUsbq8iCz8dIdw==/lib/arm/libjsc.so!libjsc.so (offset 0x75000) (BuildId: 184cbb2602409d8d87c82858f210bcb5255b9e8c)

    11:08:52.879    1434    DEBUG         #09 pc 002b2955  /data/app/com.myfarmapp-rtw-Mt49iUsbq8iCz8dIdw==/lib/arm/libjsc.so!libjsc.so (offset 0x75000) (BuildId: 184cbb2602409d8d87c82858f210bcb5255b9e8c)

    11:08:52.879    1434    DEBUG         #10 pc 00169a39  /data/app/com.myfarmapp-rtw-Mt49iUsbq8iCz8dIdw==/lib/arm/libjsc.so!libjsc.so (offset 0x75000) (BuildId: 184cbb2602409d8d87c82858f210bcb5255b9e8c)

    11:08:54.151    4062    ActivityManager crash : com.myfarmapp,0
    11:08:54.158    4062    ActivityTaskManager   Force finishing activity com.myfarmapp/.MainActivity
    11:08:54.336    4062    InputDispatcher channel '3f863f2 com.myfarmapp/com.myfarmapp.MainActivity (server)' ~ Consumer closed input channel or an error occurred.  events=0x9, fd=520
    11:08:54.336    4062    InputDispatcher channel '3f863f2 com.myfarmapp/com.myfarmapp.MainActivity (server)' ~ Channel is unrecoverably broken and will be disposed!
    11:08:54.342    4062    WindowManager   WIN DEATH: Window{3f863f2 u0 com.myfarmapp/com.myfarmapp.MainActivity}

Can you reproduce the bug?

Yes, always

Reproduction Steps

No response

Version

10.13.0

What SDK flavour are you using?

Local Database only

Are you using encryption?

No, not using encryption

Platform OS and version(s)

Android 10

Build environment

Which debugger for React Native: .. React Native Debugger

Cocoapods version

No response

kneth commented 2 years ago

@myousufq I am not able to reproduce it in an Android emulator. Can you provide more context? If possible, please provide a small app which can reproduce the issue.

kneth commented 2 years ago

@myousufq It is your dependency on react-native-reanimated. We have solved it on v10.20.0-beta.2 so please try to upgrade.

myousufq commented 2 years ago

@myousufq It is your dependency on react-native-reanimated. We have solved it on v10.20.0-beta.2 so please try to upgrade.

Hi @kneth,
Upgrade to v10.20.0-beta.2 has resolved the issue. I am very thankful for your support.

Uzef1997 commented 2 years ago

Can you please help with installing i am getting below error with the command yarn add realm@10.20.0-beta.2 Error:- project\node_modules\realm: Command failed. Exit code: 1 Command: prebuild-install -r napi || cmake-js build Arguments: project\node_modules\realm Output: prebuild-install warn install self signed certificate in certificate chain 'cmake-js' is not recognized as an internal or external command, operable program or batch file.

@myousufq It is your dependency on react-native-reanimated. We have solved it on v10.20.0-beta.2 so please try to upgrade.

Hi @kneth, Upgrade to v10.20.0-beta.2 has resolved the issue. I am very thankful for your support.

hispeedimagins commented 2 years ago

I am getting this error after installing v10.20.0-beta.2 or 5.

` error: Error: Unable to resolve module fs from E:\pp\ShoppingCart\frontend\nx\rs\node_modules\bindings\bindings.js: fs could not be found within the project or in these directories: node_modules

If you are sure the module exists, try these steps:

  1. Clear watchman watches: watchman watch-del-all
  2. Delete node_modules and run yarn install
  3. Reset Metro's cache: yarn start --reset-cache
  4. Remove the cache: rm -rf /tmp/metro- 3 | / 4 |

    5 | var fs = require('fs'), | ^ 6 | path = require('path'), 7 | fileURLToPath = require('file-uri-to-path'), 8 | join = path.join, at ModuleResolver.resolveDependency (E:\pp\ShoppingCart\frontend\nx\rs\node_modules\react-native\node_modules\metro\src\node-haste\DependencyGraph\ModuleResolution.js:129:15) at DependencyGraph.resolveDependency (E:\pp\ShoppingCart\frontend\nx\rs\node_modules\react-native\node_modules\metro\src\node-haste\DependencyGraph.js:288:43) at Object.resolve (E:\pp\ShoppingCart\frontend\nx\rs\node_modules\react-native\node_modules\metro\src\lib\transformHelpers.js:129:24) at resolve (E:\pp\ShoppingCart\frontend\nx\rs\node_modules\react-native\node_modules\metro\src\DeltaBundler\traverseDependencies.js:396:33) at E:\pp\ShoppingCart\frontend\nx\rs\node_modules\react-native\node_modules\metro\src\DeltaBundler\traverseDependencies.js:412:26 at Array.reduce () at resolveDependencies (E:\pp\ShoppingCart\frontend\nx\rs\node_modules\react-native\node_modules\metro\src\DeltaBundler\traverseDependencies.js:411:33) at processModule (E:\pp\ShoppingCart\frontend\nx\rs\node_modules\react-native\node_modules\metro\src\DeltaBundler\traverseDependencies.js:140:31) at async addDependency (E:\pp\ShoppingCart\frontend\nx\rs\node_modules\react-native\node_modules\metro\src\DeltaBundler\traverseDependencies.js:230:18) at async Promise.all (index 1)

`

Please help

Uzef1997 commented 2 years ago

I am getting this error after installing v10.20.0-beta.2 or 5.

` error: Error: Unable to resolve module fs from E:\pp\ShoppingCart\frontend\nx\rs\node_modules\bindings\bindings.js: fs could not be found within the project or in these directories: node_modules

If you are sure the module exists, try these steps:

  1. Clear watchman watches: watchman watch-del-all
  2. Delete node_modules and run yarn install
  3. Reset Metro's cache: yarn start --reset-cache
  4. Remove the cache: rm -rf /tmp/metro- 3 | / 4 |

5 | var fs = require('fs'), | ^ 6 | path = require('path'), 7 | fileURLToPath = require('file-uri-to-path'), 8 | join = path.join, at ModuleResolver.resolveDependency (E:\pp\ShoppingCart\frontend\nx\rs\node_modules\react-native\node_modules\metro\src\node-haste\DependencyGraph\ModuleResolution.js:129:15) at DependencyGraph.resolveDependency (E:\pp\ShoppingCart\frontend\nx\rs\node_modules\react-native\node_modules\metro\src\node-haste\DependencyGraph.js:288:43) at Object.resolve (E:\pp\ShoppingCart\frontend\nx\rs\node_modules\react-native\node_modules\metro\src\lib\transformHelpers.js:129:24) at resolve (E:\pp\ShoppingCart\frontend\nx\rs\node_modules\react-native\node_modules\metro\src\DeltaBundler\traverseDependencies.js:396:33) at E:\pp\ShoppingCart\frontend\nx\rs\node_modules\react-native\node_modules\metro\src\DeltaBundler\traverseDependencies.js:412:26 at Array.reduce () at resolveDependencies (E:\pp\ShoppingCart\frontend\nx\rs\node_modules\react-native\node_modules\metro\src\DeltaBundler\traverseDependencies.js:411:33) at processModule (E:\pp\ShoppingCart\frontend\nx\rs\node_modules\react-native\node_modules\metro\src\DeltaBundler\traverseDependencies.js:140:31) at async addDependency (E:\pp\ShoppingCart\frontend\nx\rs\node_modules\react-native\node_modules\metro\src\DeltaBundler\traverseDependencies.js:230:18) at async Promise.all (index 1)

`

Please help

@hispeedimagins can you please let me know how you install the beta version because I am not able to install it

hispeedimagins commented 2 years ago

I am getting this error after installing v10.20.0-beta.2 or 5. ` error: Error: Unable to resolve module fs from E:\pp\ShoppingCart\frontend\nx\rs\node_modules\bindings\bindings.js: fs could not be found within the project or in these directories: node_modules If you are sure the module exists, try these steps:

  1. Clear watchman watches: watchman watch-del-all
  2. Delete node_modules and run yarn install
  3. Reset Metro's cache: yarn start --reset-cache
  4. Remove the cache: rm -rf /tmp/metro- 3 | / 4 |

5 | var fs = require('fs'), | ^ 6 | path = require('path'), 7 | fileURLToPath = require('file-uri-to-path'), 8 | join = path.join, at ModuleResolver.resolveDependency (E:\pp\ShoppingCart\frontend\nx\rs\node_modules\react-native\node_modules\metro\src\node-haste\DependencyGraph\ModuleResolution.js:129:15) at DependencyGraph.resolveDependency (E:\pp\ShoppingCart\frontend\nx\rs\node_modules\react-native\node_modules\metro\src\node-haste\DependencyGraph.js:288:43) at Object.resolve (E:\pp\ShoppingCart\frontend\nx\rs\node_modules\react-native\node_modules\metro\src\lib\transformHelpers.js:129:24) at resolve (E:\pp\ShoppingCart\frontend\nx\rs\node_modules\react-native\node_modules\metro\src\DeltaBundler\traverseDependencies.js:396:33) at E:\pp\ShoppingCart\frontend\nx\rs\node_modules\react-native\node_modules\metro\src\DeltaBundler\traverseDependencies.js:412:26 at Array.reduce () at resolveDependencies (E:\pp\ShoppingCart\frontend\nx\rs\node_modules\react-native\node_modules\metro\src\DeltaBundler\traverseDependencies.js:411:33) at processModule (E:\pp\ShoppingCart\frontend\nx\rs\node_modules\react-native\node_modules\metro\src\DeltaBundler\traverseDependencies.js:140:31) at async addDependency (E:\pp\ShoppingCart\frontend\nx\rs\node_modules\react-native\node_modules\metro\src\DeltaBundler\traverseDependencies.js:230:18) at async Promise.all (index 1)

` Please help

@hispeedimagins can you please let me know how you install the beta version because I am not able to install it

You can simply do npm install realm@10.20.0-beta.5

Uzef1997 commented 2 years ago

npm install realm@10.20.0-beta.5

Tried same several times with yarn as well as npm but getting below error

npm ERR! code 1
npm ERR! path D:\UzefShaikh\project\realm
npm ERR! command failed
npm ERR! command C:\WINDOWS\system32\cmd.exe /d /s /c prebuild-install -r napi || cmake-js build
npm ERR! prebuild-install warn install self signed certificate in certificate chain
npm ERR! 'cmake-js' is not recognized as an internal or external command,
npm ERR! operable program or batch file.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\UzefShaikh\AppData\Local\npm-cache\_logs\2022-08-24T05_50_36_523Z-debug.log

Please help me to solve this

HuuNguyen312 commented 2 years ago

Same issue with Realm JavaScript v10.21.0

kneth commented 2 years ago

@Uzef1997 @HuuNguyen312

If you experience a crash on Android with calling realm.create() please let us know. If you have other issues, please create a new issue.

HuuNguyen312 commented 2 years ago

@kneth Yes. I am facing a crash with calling realm.create()

      realm.write(() => {
        const task = Task.generate(description);
        realm.create('Task', task);
      });

Dependencies version

"react-native-reanimated": "^2.9.1",
"realm": "^10.21.0",
"@realm/react": "^0.3.2",
"react": "17.0.2",
"react-native": "0.68.2",
pedrotrogo-fump commented 2 years ago

+1

vitorleonel commented 2 years ago

@kneth Yes. I am facing a crash with calling realm.create()

      realm.write(() => {
        const task = Task.generate(description);
        realm.create('Task', task);
      });

Dependencies version

"react-native-reanimated": "^2.9.1",
"realm": "^10.21.0",
"@realm/react": "^0.3.2",
"react": "17.0.2",
"react-native": "0.68.2",

I'm using these same versions. Did you find something?

Uzef1997 commented 2 years ago

@kneth Yes. I am facing a crash with calling realm.create()

      realm.write(() => {
        const task = Task.generate(description);
        realm.create('Task', task);
      });

Dependencies version

"react-native-reanimated": "^2.9.1",
"realm": "^10.21.0",
"@realm/react": "^0.3.2",
"react": "17.0.2",
"react-native": "0.68.2",

I'm using these same versions. Did you find something?

@kneth Yes I am facing an issue with the same dependencies as @vitorleonel has described

kneth commented 2 years ago

We had a build issue with v10.21.0 leading to random crashes on Android. Please upgrade to v10.21.1.

HuuNguyen312 commented 2 years ago

I upgraded Dependencies

"realm": "^v11.0.0-rc.2",
"@realm/react": "^0.3.2",
"react": "18.1.0",
"react-native": "0.70.1",

It is resolved Thanks

anshif10 commented 2 years ago

I am facing a crash with calling realm.create() only in android. Working fine in ios "realm": "^10.21.1", "react": "^18.0.0", "react-native": "^0.69.1", "react-native-reanimated": "^2.10.0",

anshif10 commented 2 years ago

@myousufq It is your dependency on react-native-reanimated. We have solved it on v10.20.0-beta.2 so please try to upgrade. i upgrade "realm": "^10.21.1" still facing same issue "react-native": "^0.69.1", "react": "18.0.0", "react-native-reanimated": "^2.10.0",

kneth commented 2 years ago

@anshif10 @myousufq Please see https://github.com/realm/realm-js/issues/4399#issuecomment-1254591108

ArtKullashi commented 2 years ago

Unfortunately #4399 was the only solution to this. Upgrading react native to 0.70.1 and realm to v11.0.0-rc.2 fixed it. I might have a long couple of days ahead of me now, upgrading rn isn't exactly straightforward a lot of the times.