Realm causing lots of ANRs
hoanganh-gu opened this issue · 2 comments
How frequently does the bug occur?
Always
Description
I encountered this error quite some time ago and have been consistently updating to the latest version in hopes of resolving it. But ARNs keep going, it makes my app not good at statistics. Any idea to reduce ARNs issue?
Stacktrace & log output
"main" tid=1 Native
#00 pc 0x000000000008921c /apex/com.android.runtime/lib64/bionic/libc.so (syscall+28)
#01 pc 0x00000000003a8b44 /apex/com.android.art/lib64/libart.so (art::ConditionVariable::WaitHoldingLocks(art::Thread*)+140)
#02 pc 0x00000000005f7eb8 /apex/com.android.art/lib64/libart.so (art::JNI<false>::NewString(_JNIEnv*, unsigned short const*, int)+3572)
#03 pc 0x0000000000534b70 /data/app/~~LZefJvJZOHIMGs2vAMwTPQ==/com.org.app--WrcDMUqKGG83em_2TFCGQ==/split_config.arm64_v8a.apk
#04 pc 0x000000000052035c /data/app/~~LZefJvJZOHIMGs2vAMwTPQ==/com.org.app--WrcDMUqKGG83em_2TFCGQ==/split_config.arm64_v8a.apk (Java_io_realm_internal_UncheckedRow_nativeGetString+76)
at io.realm.internal.UncheckedRow.nativeGetString (UncheckedRow.java)
at io.realm.internal.UncheckedRow.getString (UncheckedRow.java:161)
at io.realm.com_org_appandapp_realm_message_RealmMessageModelRealmProxy.realmGet$conversationId (com_org_appandapp_realm_message_RealmMessageModelRealmProxy.java:208)
at com.org.appandapp.module.home.label.FolderMessagePresenter.distinctConversation (FolderMessagePresenter.java:187)
at com.org.appandapp.module.home.label.FolderMessagePresenter.getFolderMessage (FolderMessagePresenter.java:360)
at com.org.appandapp.module.home.label.FolderMessagePresenter.handleData (FolderMessagePresenter.java:154)
at com.org.appandapp.module.home.label.FolderMessageFragment.initLayout (FolderMessageFragment.java:414)
at com.org.appandapp.mvp.BaseFragment.onViewCreated (BaseFragment.java:78)
at com.org.appandapp.module.home.label.FolderMessageFragment.onViewCreated (FolderMessageFragment.java:345)
at androidx.fragment.app.Fragment.performViewCreated (Fragment.java:2987)
at androidx.fragment.app.FragmentStateManager.createView (FragmentStateManager.java:546)
at androidx.fragment.app.FragmentStateManager.moveToExpectedState (FragmentStateManager.java:282)
at androidx.fragment.app.FragmentManager.executeOpsTogether (FragmentManager.java:2189)
at androidx.fragment.app.FragmentManager.removeRedundantOperationsAndExecute (FragmentManager.java:2100)
at androidx.fragment.app.FragmentManager.execPendingActions (FragmentManager.java:2002)
at androidx.fragment.app.FragmentManager.dispatchStateChange (FragmentManager.java:3138)
at androidx.fragment.app.FragmentManager.dispatchActivityCreated (FragmentManager.java:3072)
at androidx.fragment.app.FragmentController.dispatchActivityCreated (FragmentController.java:251)
at androidx.fragment.app.FragmentActivity.onStart (FragmentActivity.java:502)
at androidx.appcompat.app.AppCompatActivity.onStart (AppCompatActivity.java:246)
at android.app.Instrumentation.callActivityOnStart (Instrumentation.java:1563)
at android.app.Activity.performStart (Activity.java:8554)
at android.app.ActivityThread.handleStartActivity (ActivityThread.java:3839)
at android.app.servertransaction.TransactionExecutor.performLifecycleSequence (TransactionExecutor.java:221)
at android.app.servertransaction.TransactionExecutor.cycleToPath (TransactionExecutor.java:201)
at android.app.servertransaction.TransactionExecutor.executeLifecycleState (TransactionExecutor.java:173)
at android.app.servertransaction.TransactionExecutor.execute (TransactionExecutor.java:97)
at android.app.ActivityThread$H.handleMessage (ActivityThread.java:2410)
at android.os.Handler.dispatchMessage (Handler.java:106)
at android.os.Looper.loopOnce (Looper.java:211)
at android.os.Looper.loop (Looper.java:300)
at android.app.ActivityThread.main (ActivityThread.java:8167)
at java.lang.reflect.Method.invoke (Native method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:580)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1028)
"main" tid=1 Native
#00 pc 0x00000000006a5f94 /data/app/~~_2dzrFkunSmsJdwLWkC4jw==/com.org.app-TwqN9G7yDLXWRXT5uKvinQ==/split_config.arm64_v8a.apk
#01 pc 0x000000000068c504 /data/app/~~_2dzrFkunSmsJdwLWkC4jw==/com.org.app-TwqN9G7yDLXWRXT5uKvinQ==/split_config.arm64_v8a.apk
#02 pc 0x00000000007485a8 /data/app/~~_2dzrFkunSmsJdwLWkC4jw==/com.org.app-TwqN9G7yDLXWRXT5uKvinQ==/split_config.arm64_v8a.apk
#03 pc 0x000000000065ee8c /data/app/~~_2dzrFkunSmsJdwLWkC4jw==/com.org.app-TwqN9G7yDLXWRXT5uKvinQ==/split_config.arm64_v8a.apk
#04 pc 0x00000000006635c0 /data/app/~~_2dzrFkunSmsJdwLWkC4jw==/com.org.app-TwqN9G7yDLXWRXT5uKvinQ==/split_config.arm64_v8a.apk
#05 pc 0x00000000006bbc50 /data/app/~~_2dzrFkunSmsJdwLWkC4jw==/com.org.app-TwqN9G7yDLXWRXT5uKvinQ==/split_config.arm64_v8a.apk
#06 pc 0x0000000000660c44 /data/app/~~_2dzrFkunSmsJdwLWkC4jw==/com.org.app-TwqN9G7yDLXWRXT5uKvinQ==/split_config.arm64_v8a.apk
#07 pc 0x0000000000782d40 /data/app/~~_2dzrFkunSmsJdwLWkC4jw==/com.org.app-TwqN9G7yDLXWRXT5uKvinQ==/split_config.arm64_v8a.apk
#08 pc 0x0000000000660608 /data/app/~~_2dzrFkunSmsJdwLWkC4jw==/com.org.app-TwqN9G7yDLXWRXT5uKvinQ==/split_config.arm64_v8a.apk
#09 pc 0x00000000006618ec /data/app/~~_2dzrFkunSmsJdwLWkC4jw==/com.org.app-TwqN9G7yDLXWRXT5uKvinQ==/split_config.arm64_v8a.apk
#10 pc 0x000000000055c304 /data/app/~~_2dzrFkunSmsJdwLWkC4jw==/com.org.app-TwqN9G7yDLXWRXT5uKvinQ==/split_config.arm64_v8a.apk
#11 pc 0x00000000005611c0 /data/app/~~_2dzrFkunSmsJdwLWkC4jw==/com.org.app-TwqN9G7yDLXWRXT5uKvinQ==/split_config.arm64_v8a.apk
#12 pc 0x000000000050a3d4 /data/app/~~_2dzrFkunSmsJdwLWkC4jw==/com.org.app-TwqN9G7yDLXWRXT5uKvinQ==/split_config.arm64_v8a.apk (Java_io_realm_internal_OsResults_nativeEvaluateQueryIfNeeded+28)
at io.realm.internal.OsResults.nativeEvaluateQueryIfNeeded (OsResults.java)
at io.realm.internal.OsResults.load (OsResults.java:754)
at io.realm.RealmResults.load (RealmResults.java:152)
at io.realm.RealmQuery.createRealmResults (RealmQuery.java:2857)
at io.realm.RealmQuery.findAll (RealmQuery.java:2465)
at com.org.appandapp.module.home.HomePresenter.getAccountItemExtrasForSwipeList (HomePresenter.java:1224)
at com.org.appandapp.module.home.HomeActivity.setUpDataPopupListSwitchAccount (HomeActivity.java:1153)
at com.org.appandapp.module.home.HomeActivity.renderMailFolder (HomeActivity.java:1137)
at com.org.appandapp.module.home.HomePresenter.showItems (HomePresenter.java:164)
at com.org.appandapp.module.home.HomePresenter.getAccounts (HomePresenter.java:592)
at com.org.appandapp.module.home.HomeActivity.onCreate (HomeActivity.java:448)
at android.app.Activity.performCreate (Activity.java:8290)
at android.app.Activity.performCreate (Activity.java:8269)
at android.app.Instrumentation.callActivityOnCreate (Instrumentation.java:1385)
at android.app.ActivityThread.performLaunchActivity (ActivityThread.java:3658)
at android.app.ActivityThread.handleLaunchActivity (ActivityThread.java:3814)
at android.app.servertransaction.LaunchActivityItem.execute (LaunchActivityItem.java:101)
at android.app.servertransaction.TransactionExecutor.executeCallbacks (TransactionExecutor.java:135)
at android.app.servertransaction.TransactionExecutor.execute (TransactionExecutor.java:95)
at android.app.ActivityThread$H.handleMessage (ActivityThread.java:2309)
at android.os.Handler.dispatchMessage (Handler.java:106)
at android.os.Looper.loopOnce (Looper.java:346)
at android.os.Looper.loop (Looper.java:475)
at android.app.ActivityThread.main (ActivityThread.java:7950)
at java.lang.reflect.Method.invoke (Native method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:548)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:942)
Can you reproduce the bug?
Always
Reproduction Steps
No response
Version
10.16.1
What Atlas App Services are you using?
Local Database only
Are you using encryption?
Yes
Platform OS and version(s)
Android
Build environment
Android Studio version: 2022.2.1
Android Build Tools version: 7.4.2
Gradle version: 7.5
Hi @hoanganh-gu This is most likely caused because you are either writing to or querying on the UI thread. If the UI thread is blocked for more than 5 seconds it will cause an ANR. You can detect if you are doing this by enabling RealmConfiguration.allowQueriesOnUiThread(false)
and RealmConfiguration.allowWritesOnUiThread(false)
. Realm will then crash if you try this. Instead you should switch to our findAllAsync
or excuteTransactionAsync
methods.
Got that point, we are switching to async methods. Thanks @cmelchior