objectbox-java: Native Crash when querying first - Only showing at PlayStore
Issue Basics
- ObjectBox version: 2.3.4 and 2.5.1 - Upgraded version to see if still happens
- Reproducibility: Always on following devices (caught on playstore): Samsung Galaxy S9+ (star2qltechn), 5632MB RAM, Android 10 Motorola moto g(7) (river), 3584MB RAM, Android 9 Motorola motorola one vision (kane_sprout), 3840MB RAM, Android 10 Motorola Moto X (4) (payton), 2816MB RAM, Android 9 Redmi Redmi Note 8 (ginkgo), 3840MB RAM, Android 9 Samsung Galaxy A30s (a30s), 3840MB RAM, Android 10
-Never on debug builds or release builds that I generated for my team to test it, and never happened, even on same devices like Samgung Galaxy S9 and a Motorola Moto G7 which some member also have.
It seems that it’s only happening on Android 9 and 10 (which I also tested here and wasn’t able to reproduce)
Reproducing the bug
Description
I’m getting the following native crash log (that I can only get by PlayStore, not Crashlytics) as soon as my app starts, since I request data from local database: The only line that showed me some info was:
#06 pc 0000000000043688 /data/app/br.com.ampli-A-oKgSqV0pfD7IL5xQWvwQ==/base.apk!libobjectbox-jni.so (offset 0x37e000) (Java_io_objectbox_query_Query_nativeFindFirst+68)
It started out of nowhere, I was working just fine on my app version “1.0.2” when I upgraded to “1.1.0” it stopped working. I didn’t change any property on any Entity. First I thought was an extension function queryFirst that I use:
inline fun <reified T : Any> BoxStore.queryFirst(model: T): T? {
return this.boxFor(model::class.java).query().build().findFirst()
}
So I’ve change all call on it to the default :
BoxStore.getDefault().boxFor(Course::class.java).query().build().findFirst()
Maybe related to (https://github.com/objectbox/objectbox-java/issues/494) or (https://github.com/objectbox/objectbox-java/issues/490)
Code
I’m not entirely sure what code exactly is causing this, but I think is when I get the first Course object:
override suspend fun fetchCourse(): Course? {
return withContext(Dispatchers.IO) {
BoxStore.getDefault().boxFor(Course::class.java).query().build().findFirst()
}
}
Logs & stackstraces
pid: 0, tid: 0 >>> br.com.ampli <<<
backtrace:
#00 pc 0000000000083134 /apex/com.android.runtime/lib64/bionic/libc.so (abort+160)
#01 pc 00000000004b3c08 /apex/com.android.runtime/lib64/libart.so (art::Runtime::Abort(char const*)+2376)
#02 pc 000000000000c5b4 /system/lib64/libbase.so (android::base::LogMessage::~LogMessage()+608)
#03 pc 0000000000374a94 /apex/com.android.runtime/lib64/libart.so (art::JavaVMExt::JniAbort(char const*, char const*)+1592)
#04 pc 00000000003a74c8 /apex/com.android.runtime/lib64/libart.so (art::JNI::SetObjectField(_JNIEnv*, _jobject*, _jfieldID*, _jobject*)+924)
#05 pc 00000000000262a4 /data/app/br.com.ampli-A-oKgSqV0pfD7IL5xQWvwQ==/base.apk!libobjectbox-jni.so (offset 0x37e000)
#06 pc 0000000000043688 /data/app/br.com.ampli-A-oKgSqV0pfD7IL5xQWvwQ==/base.apk!libobjectbox-jni.so (offset 0x37e000) (Java_io_objectbox_query_Query_nativeFindFirst+68)
#07 pc 000000000003fb7c /data/app/br.com.ampli-A-oKgSqV0pfD7IL5xQWvwQ==/oat/arm64/base.odex (art_jni_trampoline+140)
#08 pc 0000000000137334 /apex/com.android.runtime/lib64/libart.so (art_quick_invoke_stub+548)
#09 pc 000000000014606c /apex/com.android.runtime/lib64/libart.so (art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*)+244)
#10 pc 00000000002e0cd0 /apex/com.android.runtime/lib64/libart.so (art::interpreter::ArtInterpreterToCompiledCodeBridge(art::Thread*, art::ArtMethod*, art::ShadowFrame*, unsigned short, art::JValue*)+384)
#11 pc 00000000002dbfb0 /apex/com.android.runtime/lib64/libart.so (bool art::interpreter::DoCall<false, false>(art::ArtMethod*, art::Thread*, art::ShadowFrame&, art::Instruction const*, unsigned short, art::JValue*)+912)
#12 pc 00000000005a030c /apex/com.android.runtime/lib64/libart.so (MterpInvokeVirtualQuick+596)
#13 pc 0000000000135594 /apex/com.android.runtime/lib64/libart.so (mterp_op_invoke_virtual_quick+20)
#14 pc 000000000047941c /data/app/br.com.ampli-A-oKgSqV0pfD7IL5xQWvwQ==/oat/arm64/base.vdex (io.objectbox.query.Query$a.call+28)
#15 pc 000000000059bbe4 /apex/com.android.runtime/lib64/libart.so (MterpInvokeInterface+1740)
#16 pc 0000000000131a14 /apex/com.android.runtime/lib64/libart.so (mterp_op_invoke_interface+20)
#17 pc 0000000000476786 /data/app/br.com.ampli-A-oKgSqV0pfD7IL5xQWvwQ==/oat/arm64/base.vdex (io.objectbox.BoxStore.a+42)
#18 pc 00000000005a0610 /apex/com.android.runtime/lib64/libart.so (MterpInvokeVirtualQuick+1368)
#19 pc 0000000000135594 /apex/com.android.runtime/lib64/libart.so (mterp_op_invoke_virtual_quick+20)
#20 pc 0000000000476886 /data/app/br.com.ampli-A-oKgSqV0pfD7IL5xQWvwQ==/oat/arm64/base.vdex (io.objectbox.BoxStore.a+6)
#21 pc 00000000005a0610 /apex/com.android.runtime/lib64/libart.so (MterpInvokeVirtualQuick+1368)
#22 pc 0000000000135594 /apex/com.android.runtime/lib64/libart.so (mterp_op_invoke_virtual_quick+20)
#23 pc 0000000000479a40 /data/app/br.com.ampli-A-oKgSqV0pfD7IL5xQWvwQ==/oat/arm64/base.vdex (io.objectbox.query.Query.d+40)
#24 pc 00000000005a0610 /apex/com.android.runtime/lib64/libart.so (MterpInvokeVirtualQuick+1368)
#25 pc 0000000000135594 /apex/com.android.runtime/lib64/libart.so (mterp_op_invoke_virtual_quick+20)
#26 pc 00000000002442c6 /data/app/br.com.ampli-A-oKgSqV0pfD7IL5xQWvwQ==/oat/arm64/base.vdex (e.a.a.j1.d.a$a.d+54)
#27 pc 00000000005a0610 /apex/com.android.runtime/lib64/libart.so (MterpInvokeVirtualQuick+1368)
#28 pc 0000000000135594 /apex/com.android.runtime/lib64/libart.so (mterp_op_invoke_virtual_quick+20)
#29 pc 000000000047fe9a /data/app/br.com.ampli-A-oKgSqV0pfD7IL5xQWvwQ==/oat/arm64/base.vdex (b1.p.i.a.a.c+18)
#30 pc 000000000059bbe4 /apex/com.android.runtime/lib64/libart.so (MterpInvokeInterface+1740)
#31 pc 0000000000131a14 /apex/com.android.runtime/lib64/libart.so (mterp_op_invoke_interface+20)
#32 pc 000000000048797e /data/app/br.com.ampli-A-oKgSqV0pfD7IL5xQWvwQ==/oat/arm64/base.vdex (a0.a.p0.run+214)
#33 pc 000000000059bbe4 /apex/com.android.runtime/lib64/libart.so (MterpInvokeInterface+1740)
#34 pc 0000000000131a14 /apex/com.android.runtime/lib64/libart.so (mterp_op_invoke_interface+20)
#35 pc 000000000048fcd4 /data/app/br.com.ampli-A-oKgSqV0pfD7IL5xQWvwQ==/oat/arm64/base.vdex (a0.a.c2.b.a)
#36 pc 00000000005a0610 /apex/com.android.runtime/lib64/libart.so (MterpInvokeVirtualQuick+1368)
#37 pc 0000000000135594 /apex/com.android.runtime/lib64/libart.so (mterp_op_invoke_virtual_quick+20)
#38 pc 000000000048ee5e /data/app/br.com.ampli-A-oKgSqV0pfD7IL5xQWvwQ==/oat/arm64/base.vdex (a0.a.c2.b$a.run+534)
#39 pc 00000000002b191c /apex/com.android.runtime/lib64/libart.so (art::interpreter::Execute(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame&, art::JValue, bool, bool) (.llvm.18252570399552585066)+240)
#40 pc 000000000058b6e8 /apex/com.android.runtime/lib64/libart.so (artQuickToInterpreterBridge+1012)
#41 pc 0000000000140468 /apex/com.android.runtime/lib64/libart.so (art_quick_to_interpreter_bridge+88)
#42 pc 0000000000137334 /apex/com.android.runtime/lib64/libart.so (art_quick_invoke_stub+548)
#43 pc 000000000014606c /apex/com.android.runtime/lib64/libart.so (art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*)+244)
#44 pc 00000000004ab72c /apex/com.android.runtime/lib64/libart.so (art::(anonymous namespace)::InvokeWithArgArray(art::ScopedObjectAccessAlreadyRunnable const&, art::ArtMethod*, art::(anonymous namespace)::ArgArray*, art::JValue*, char const*)+104)
#45 pc 00000000004ac7c0 /apex/com.android.runtime/lib64/libart.so (art::InvokeVirtualOrInterfaceWithJValues(art::ScopedObjectAccessAlreadyRunnable const&, _jobject*, _jmethodID*, jvalue const*)+416)
#46 pc 00000000004ecb00 /apex/com.android.runtime/lib64/libart.so (art::Thread::CreateCallback(void*)+1176)
#47 pc 00000000000e28c0 /apex/com.android.runtime/lib64/bionic/libc.so (__pthread_start(void*)+36)
#48 pc 000000000008503c /apex/com.android.runtime/lib64/bionic/libc.so (__start_thread+64)
Entities
But I can’t be sure what entity is causing the issue. But I think is my following Course entity:
@Entity
data class Course(
@Id var boxId: Long = 0L,
@Index var id: String = UUID.randomUUID().toString(),
var version: Int = 0,
var name: String = "",
var studentId: String = "",
var percentageCompletion: Int = 0,
var startDateInEpochDay: Long = 0L,
var endDateInEpochDay: Long = 0L
) {
var disciplines: ToMany<Discipline> = ToMany(this, Course_.disciplines)
}
Btw in case someone’s wondering why disciplines is not a lateinit var, is because couldn’t unit test it if it was, so I changed and initialized here, for more info: ToOneObjectIsNull
Misc
*Is there anything special about your app? The only “big” change that I’ve made from working version to not working version was adding and upgrading another lib, specifically Zendesk’s I went from
3.0.1 to 4.0.0
And also added 2 more libs:
com.zendesk:chat:2.0.0 com.zendesk:messaging:4.2.1
May transactions or multi-threading play a role? I’m using coroutines with Dispatchers.IO as a context whenever I call the database
Did you find any workarounds to prevent the issue?* I’ll try to change every findFirst() call to find and get the first position to see if I’m able to make it work., but I’m running out of ideas.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 16 (7 by maintainers)
@greenrobot-team and @greenrobot Thank you guys so much, the solution worked like a charm, no more crashes shown since I released.
@greenrobot-team I see, so I probably messed up something when I was running the migration test but when I did change one only one of those things, I kept getting DbException
Can’t thank you guys enough. I’ve been in love with objectbox for a while, since I’ve try it last year, and your consideration helping me out of this, made me love it even more. Hope to test 3.0 soon !!
I’m gonna close it for now then, thanks guys!