inaturalist / iNaturalistAndroid

Android app for iNaturalist.org
https://market.android.com/details?id=org.inaturalist.android
MIT License
168 stars 57 forks source link

CursorWindowAllocationException in INaturalistServiceImplementation.getUserObservations #1306

Open kueda opened 1 year ago

kueda commented 1 year ago

https://console.firebase.google.com/u/0/project/inaturalist-ios/crashlytics/app/android:org.inaturalist.android/issues/07d00c2c69c6483731932add1916e547

Fatal Exception: android.database.CursorWindowAllocationException: Could not allocate CursorWindow '/data/user/0/org.inaturalist.android/databases/inaturalist.db' of size 4194304 due to error -12.
       at android.database.CursorWindow.nativeCreate(CursorWindow.java)
       at android.database.CursorWindow.<init>(CursorWindow.java:145)
       at android.database.sqlite.SQLiteCursor.clearOrCreateWindow(SQLiteCursor.java:319)
       at android.database.sqlite.SQLiteCursor.fillWindow(SQLiteCursor.java:159)
       at android.database.sqlite.SQLiteCursor.getCount(SQLiteCursor.java:152)
       at android.content.ContentResolver.query(ContentResolver.java:970)
       at android.content.ContentResolver.query(ContentResolver.java:887)
       at android.content.ContentResolver.query(ContentResolver.java:843)
       at org.inaturalist.android.INaturalistServiceImplementation.syncJson(INaturalistServiceImplementation.java:6386)
       at org.inaturalist.android.INaturalistServiceImplementation.getUserObservations(INaturalistServiceImplementation.java:5309)
       at org.inaturalist.android.INaturalistServiceImplementation.syncObservations(INaturalistServiceImplementation.java:1817)
       at org.inaturalist.android.INaturalistServiceImplementation.onHandleIntentWorker(INaturalistServiceImplementation.java:1529)
       at org.inaturalist.android.INaturalistService$1.run(INaturalistService.java:659)
       at java.lang.Thread.run(Thread.java:919)
budowski commented 1 year ago

This is a cursor leak related crash (see here for example: https://stackoverflow.com/questions/21219039/android-database-cursorwindowallocationexception-when-moving-a-cursor)

The problem is that it's hard to investigate this just from a stack trace (need the full logs that came before it). I did go over all the relevant code related to syncing, to see if there might be issues of forgotten cursors (that were not closed properly, thus causing a cursor leak) -> but couldn't find any such cases.