BasicAirData / GPSLogger

A GPS logger for Android mobile devices
http://www.basicairdata.eu/projects/android/android-gps-logger/
GNU General Public License v3.0
403 stars 126 forks source link

Bug Report - ANR - Input dispatching timed out at DatabaseHandler.java:943 #214

Open GrazianoCapelli opened 10 months ago

GrazianoCapelli commented 10 months ago

Input dispatching timed out at sun.misc.Unsafe.park (Native method) at java.util.concurrent.locks.LockSupport.parkNanos (LockSupport.java:230) at android.database.sqlite.SQLiteConnectionPool.waitForConnection (SQLiteConnectionPool.java:756) at android.database.sqlite.SQLiteConnectionPool.acquireConnection (SQLiteConnectionPool.java:380)

This function call is performing I/O operations, which have unpredictable timing

at android.database.sqlite.SQLiteSession.acquireConnection (SQLiteSession.java:896) at android.database.sqlite.SQLiteSession.prepare (SQLiteSession.java:588) at android.database.sqlite.SQLiteProgram. (SQLiteProgram.java:61) at android.database.sqlite.SQLiteQuery. (SQLiteQuery.java:37) at android.database.sqlite.SQLiteDirectCursorDriver.query (SQLiteDirectCursorDriver.java:46) at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory (SQLiteDatabase.java:1545) at android.database.sqlite.SQLiteDatabase.rawQuery (SQLiteDatabase.java:1484) at eu.basicairdata.graziano.gpslogger.DatabaseHandler.getTrack (DatabaseHandler.java:943)

Your app code here involves the I/O call shown above. The code that triggers I/O operations must be moved off the main thread.

at eu.basicairdata.graziano.gpslogger.Exporter. (Exporter.java:172) at eu.basicairdata.graziano.gpslogger.GPSApplication.executeExportingTask (GPSApplication.java:1641) at eu.basicairdata.graziano.gpslogger.GPSApplication$5.run (GPSApplication.java:364) at eu.basicairdata.graziano.gpslogger.GPSApplication.startExportingStatusChecker (GPSApplication.java:1621) at eu.basicairdata.graziano.gpslogger.GPSApplication.executeJob (GPSApplication.java:1711) at eu.basicairdata.graziano.gpslogger.FragmentTracklist.onEvent (FragmentTracklist.java:221) at java.lang.reflect.Method.invoke (Native method) at org.greenrobot.eventbus.EventBus.invokeSubscriber (EventBus.java:510) at org.greenrobot.eventbus.EventBus.postToSubscription (EventBus.java:433) at org.greenrobot.eventbus.EventBus.postSingleEventForEventType (EventBus.java:414) at org.greenrobot.eventbus.EventBus.postSingleEvent (EventBus.java:387) at org.greenrobot.eventbus.EventBus.post (EventBus.java:268) at eu.basicairdata.graziano.gpslogger.ToolbarActionMode.onActionItemClicked (ToolbarActionMode.java:102) at androidx.appcompat.app.AppCompatDelegateImpl$ActionModeCallbackWrapperV9.onActionItemClicked (AppCompatDelegateImpl.java:2718) at androidx.appcompat.view.StandaloneActionMode.onMenuItemSelected (StandaloneActionMode.java:140) at androidx.appcompat.view.menu.MenuBuilder.dispatchMenuItemSelected (MenuBuilder.java:836) at androidx.appcompat.view.menu.MenuItemImpl.invoke (MenuItemImpl.java:159) at androidx.appcompat.view.menu.MenuBuilder.performItemAction (MenuBuilder.java:987) at androidx.appcompat.view.menu.MenuBuilder.performItemAction (MenuBuilder.java:977) at androidx.appcompat.widget.ActionMenuView.invokeItem (ActionMenuView.java:625) at androidx.appcompat.view.menu.ActionMenuItemView.onClick (ActionMenuItemView.java:156) at android.view.View.performClick (View.java:7503) at android.view.View.performClickInternal (View.java:7480) at android.view.View.access$3600 (View.java:813) at android.view.View$PerformClick.run (View.java:28445) at android.os.Handler.handleCallback (Handler.java:938) at android.os.Handler.dispatchMessage (Handler.java:99) at android.os.Looper.loop (Looper.java:223) at android.app.ActivityThread.main (ActivityThread.java:7986) at java.lang.reflect.Method.invoke (Native method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:603) at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:947)

Problem:

The main thread was busy with an I/O operation. The problem may be due to network or file access (particularly compressed files), but also operations such as ClassLoader.loadClass.

Advise:

I/O operations are very unpredictable and can block a thread for a long time. Avoid I/O in the main thread and refactor your code so that I/O operations are performed in a separate thread from the main thread