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

Suspected race conditon exception with Encrypted Realm database #30

Closed
kelvinharron opened this issue Dec 13, 2021 · 3 comments
Closed

Comments

@kelvinharron
Copy link

Hey,

We're seeing a crash in our debug and release builds with the below stacktrace. The behaviour is strange because the app technically crashes but because the service is going into a fatal state, we just get a dialog to state that this app keeps stopping etc.

I believe it's a race condition issue because when I attach a debugger to sanity check the pid, I can't reproduce the issue. Removing WhatTheStack also resolves it but I'd like to see what I can do to work around this.

When our app starts, our Application will create our Dagger AppModule which includes getting our encrypted realm instance. From your experience with Jetpack Startup, do you believe it would be better for us to adapt it to hopefully prevent this issue?

stacktrace

2021-12-13 13:50:36.546 19590-19590/com.my.app.dev E/REALM_JNI: jni: ThrowingException 7, /data/user/0/com.my.app.dev/files/encrypted-register.realm: Encrypted interprocess sharing is currently unsupported.DB has been opened by pid: 19556. Current pid is 19590. in /tmp/realm-java/realm/realm-library/src/main/cpp/io_realm_internal_OsSharedRealm.cpp line 106, .
2021-12-13 13:50:36.546 19590-19590/com.my.app.dev E/REALM_JNI: Exception has been thrown: /data/user/0/com.my.app.dev/files/encrypted-register.realm: Encrypted interprocess sharing is currently unsupported.DB has been opened by pid: 19556. Current pid is 19590. in /tmp/realm-java/realm/realm-library/src/main/cpp/io_realm_internal_OsSharedRealm.cpp line 106
2021-12-13 13:50:36.546 19590-19590/com.my.app.dev D/AndroidRuntime: Shutting down VM
2021-12-13 13:50:36.547 19590-19590/com.my.app.dev E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.my.app.dev:what_the_stack_process, PID: 19590
java.lang.RuntimeException: Unable to create application com.my.app.DebugApplication: java.lang.RuntimeException: /data/user/0/com.my.app.dev/files/encrypted-register.realm: Encrypted interprocess sharing is currently unsupported.DB has been opened by pid: 19556. Current pid is 19590. in /tmp/realm-java/realm/realm-library/src/main/cpp/io_realm_internal_OsSharedRealm.cpp line 106
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6465)
at android.app.ActivityThread.access$1300(ActivityThread.java:219)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1859)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7356)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
Caused by: java.lang.RuntimeException: /data/user/0/com.my.app.dev/files/encrypted-register.realm: Encrypted interprocess sharing is currently unsupported.DB has been opened by pid: 19556. Current pid is 19590. in /tmp/realm-java/realm/realm-library/src/main/cpp/io_realm_internal_OsSharedRealm.cpp line 106
at io.realm.internal.OsSharedRealm.nativeGetSharedRealm(Native Method)
at io.realm.internal.OsSharedRealm.(OsSharedRealm.java:175)
at io.realm.internal.OsSharedRealm.getInstance(OsSharedRealm.java:251)
at io.realm.BaseRealm.(BaseRealm.java:141)
at io.realm.BaseRealm.(BaseRealm.java:108)
at io.realm.Realm.(Realm.java:159)
at io.realm.Realm.createInstance(Realm.java:495)
at io.realm.RealmCache.createInstance(RealmCache.java:494)
at io.realm.RealmCache.doCreateRealmOrGetFromCache(RealmCache.java:461)
at io.realm.RealmCache.createRealmOrGetFromCache(RealmCache.java:422)
at io.realm.Realm.getInstance(Realm.java:424)
at com.my.app.persistence.RealmDao.getRealmInstance(RealmDao.kt:144)
at com.my.app.persistence.RealmDao.executeQuery(RealmDao.kt:137)
at com.my.app.users.persistence.UsersDao.findUserById(UsersDao.kt:47)
at com.my.app.users.service.UsersService.fetchUserById(UsersService.kt:97)
at com.my.app.users.service.UsersService.restorePersistedActiveUser(UsersService.kt:63)
at com.my.app.users.service.UsersService.restoreLastLoggedInUser(UsersService.kt:58)
at com.my.app.users.service.UsersService.(UsersService.kt:46)
at com.my.app.users.service.UsersService_Factory.newInstance(UsersService_Factory.java:65)
at com.my.app.users.service.UsersService_Factory.get(UsersService_Factory.java:51)
at com.my.app.users.service.UsersService_Factory.get(UsersService_Factory.java:15)
at dagger.internal.DoubleCheck.get(DoubleCheck.java:47)
at com.my.app.updates.service.UpdateService_Factory.get(UpdateService_Factory.java:90)
at com.my.app.updates.service.UpdateService_Factory.get(UpdateService_Factory.java:22)
at dagger.internal.DoubleCheck.get(DoubleCheck.java:47)
at com.my.app.updates.service.UpdateService_Factory.get(UpdateService_Factory.java:105)
at com.my.app.updates.service.UpdateService_Factory.get(UpdateService_Factory.java:26)
at dagger.internal.DoubleCheck.get(DoubleCheck.java:47)
at dagger.internal.DelegateFactory.get(DelegateFactory.java:36)
at com.my.app.scheduler.service.UpdateTimerTask_Factory.get(UpdateTimerTask_Factory.java:33)
at com.my.app.scheduler.service.UpdateTimerTask_Factory.get(UpdateTimerTask_Factory.java:11)
at com.my.app.scheduler.service.UpdateScheduler_Factory.get(UpdateScheduler_Factory.java:27)
2021-12-13 13:50:36.548 19590-19590/com.my.app.dev E/AndroidRuntime: at com.my.app.scheduler.service.UpdateScheduler_Factory.get(UpdateScheduler_Factory.java:9)
at dagger.internal.DoubleCheck.get(DoubleCheck.java:47)
at com.my.app.modules.DaggerApplicationComponent.injectApplication(DaggerApplicationComponent.java:3989)
at com.my.app.modules.DaggerApplicationComponent.inject(DaggerApplicationComponent.java:3312)
at com.my.app.Application.initializeDagger(Application.kt:87)
at com.my.app.Application.onCreate(Application.kt:63)
at com.my.app.DebugApplication.onCreate(DebugApplication.kt:13)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1182)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6460)

Thanks!

@haroldadmin
Copy link
Owner

Thanks for reporting the issue in detail.

I'm not sure if this is a bug in WhatTheStack. It seems to be Realm specific. A bit of googling tells me that this problem has been around for a while, I found issues as old as 2016.

I don't know if Jetpack App Startup library will help, as it's just a wrapper around the ContentProvider API. Maybe I could be of more help if you could share a sample app to reproduce the bug?

@kelvinharron
Copy link
Author

Thanks for reporting the issue in detail.

I'm not sure if this is a bug in WhatTheStack. It seems to be Realm specific. A bit of googling tells me that this problem has been around for a while, I found issues as old as 2016.

I don't know if Jetpack App Startup library will help, as it's just a wrapper around the ContentProvider API. Maybe I could be of more help if you could share a sample app to reproduce the bug?

The nature of it is bizarre that I think its likely to be a limitation with Realm encryption. I'll see about getting a sample project together this week with realm encryption and report back. Thanks!

@kelvinharron
Copy link
Author

Closing this one out. I've replicated a similar structure in a local app and cannot reproduce the issue, so I figure it's a race condition in realm starting up too quickly, with a side effect of blaming WhatTheStack!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants