Leanplum/Leanplum-Android-SDK

ANR due to SQLite operations from the main thread

dmitry-novikov opened this issue · 2 comments

Expected Behavior

All operations with filesystem should be done from a dedicated thread to not block main thread.

Actual Behavior

We see some ANRs in production caused by main thread blocking:

"main" tid=1 Native Performing SQLite (disk) I/O
"main" prio=5 tid=1 Native
  | group="main" sCount=1 dsCount=0 obj=0x74c0c430 self=0xedf84400
  | sysTid=8390 nice=-10 cgrp=default sched=0/0 handle=0xf0ce2534
  | state=S schedstat=( 0 0 0 ) utm=1742 stm=340 core=1 HZ=100
  | stack=0xfd469000-0xfd46b000 stackSize=8MB
  | held mutexes=
  #00  pc 00000000000177d8  /system/lib/libc.so (syscall+28)
  #01  pc 00000000000b6dc9  /system/lib/libart.so (_ZN3art17ConditionVariable16WaitHoldingLocksEPNS_6ThreadE+92)
  #02  pc 00000000003f2c2b  /system/lib/libart.so (_ZN3artL12GoToRunnableEPNS_6ThreadE+230)
  #03  pc 00000000003f2b1d  /system/lib/libart.so (_ZN3art12JniMethodEndEjPNS_6ThreadE+8)
  #04  pc 00000000002b9de5  /system/framework/arm/boot-framework.oat (Java_android_database_sqlite_SQLiteConnection_nativeExecuteForLastInsertedRowId__JJ+120)
  at android.database.sqlite.SQLiteConnection.nativeExecuteForLastInsertedRowId (Native method)
  at android.database.sqlite.SQLiteConnection.executeForLastInsertedRowId (SQLiteConnection.java:782)
  at android.database.sqlite.SQLiteSession.executeForLastInsertedRowId (SQLiteSession.java:788)
  at android.database.sqlite.SQLiteStatement.executeInsert (SQLiteStatement.java:86)
  at android.database.sqlite.SQLiteDatabase.insertWithOnConflict (SQLiteDatabase.java:1474)
  at android.database.sqlite.SQLiteDatabase.insert (SQLiteDatabase.java:1343)
  at com.leanplum.a.ae.a (SourceFile:96)
  at com.leanplum.a.aw.k (SourceFile:3247)
  at com.leanplum.a.aw.i (SourceFile:287)
  at com.leanplum.Leanplum.o (SourceFile:1013)
  at com.leanplum.Leanplum.b (SourceFile:992)
  at com.leanplum.LeanplumActivityHelper.d (SourceFile:216)
  at com.leanplum.LeanplumActivityHelper.b (SourceFile:51)
  at com.leanplum.LeanplumActivityHelper$2.onActivityResumed (SourceFile:128)
  at android.app.Application.dispatchActivityResumed (Application.java:216)
  at android.app.Activity.onResume (Activity.java:1276)
  at android.support.v4.app.i.onResume (FragmentActivity.java:458)
  at com.project.MainActivity.onResume (MainActivity.kt:42)
  at android.app.Instrumentation.callActivityOnResume (Instrumentation.java:1270)
  at android.app.Activity.performResume (Activity.java:6959)
  at android.app.ActivityThread.performResumeActivity (ActivityThread.java:3444)
  at android.app.ActivityThread.handleResumeActivity (ActivityThread.java:3507)
  at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1560)
  at android.os.Handler.dispatchMessage (Handler.java:102)
  at android.os.Looper.loop (Looper.java:154)
  at android.app.ActivityThread.main (ActivityThread.java:6157)
  at java.lang.reflect.Method.invoke! (Native method)
  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:926)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:788)

Steps to Reproduce the Problem

Specifications

  • Version: Leanplum-Android-SDK 3.0.2
  • Platform: Android 7.1
  • Subsystem:

Hi @dmitry-novikov , thanks for reporting this.

fixed at #162