领域:在 android 内创建导致崩溃(react-native)

Realm: create causing a crash within android (react-native)

下面的示例在使用 React Native Debugger 启用调试时工作正常,但应用程序仅在正常模式下崩溃 Android。有人可以帮我解决这个问题吗?

  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",
        });
      });

"react": "17.0.2", "react-native": "0.66.4", "realm": "^10.13.0","react-native-reanimated": "^2.2.0",

堆栈跟踪

键入时间 PID 标记消息 11:08:52.623 32560 libc 致命信号 7 (SIGBUS),代码 1 (BUS_ADRALN),故障地址 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}

将领域升级到 v10.20.0-beta.2 后问题已解决

https://github.com/realm/realm-js/issues/4399#issuecomment-1061722341