onnela-lab / beiwe-android

Beiwe is a smartphone-based digital phenotyping research platform. This is the Beiwe Android app code. The Beiwe2 app is also available on the Google Play store to use with open source builds of the Beiwe backend.
https://www.beiwe.org/
BSD 3-Clause "New" or "Revised" License
26 stars 16 forks source link

Index 0 requested, with a size of 0 #23

Closed zagorsky closed 6 years ago

zagorsky commented 6 years ago

There are two errors that are probably related:

Error 1: Index 0 requested, with a size of 0

Examples of this on Sentry: https://sentry.io/onnela-lab/production/issues/322580097/ https://sentry.io/onnela-lab/production/issues/421414640/ https://sentry.io/onnela-lab/production/issues/425524018/ https://sentry.io/onnela-lab/production/issues/296770548/ https://sentry.io/onnela-lab/production/issues/460110311/ https://sentry.io/onnela-lab/production/issues/460934654/ https://sentry.io/onnela-lab/production/issues/473191272/ https://sentry.io/onnela-lab/production/issues/535940221/ https://sentry.io/onnela-lab/production/issues/542668666/ https://sentry.io/onnela-lab/production/issues/537314236/ https://sentry.io/onnela-lab/production/issues/296770548/ https://sentry.io/onnela-lab/production/issues/460110311/ https://sentry.io/onnela-lab/production/issues/505395648/ https://sentry.io/onnela-lab/production/issues/460934654/

We actually got a bug report from a user with one phone that had this crash (https://sentry.io/onnela-lab/production/issues/542668666/):

Phone: Samsung Galaxy Avant; Model number: SM-G386T; Android version: 4.4.2 After downloading successfully, the first set of surveys popped up. The subject answered them, but after answering the four surveys, one of the surveys still appeared in the notifications bar (as though it were unanswered). After repeatedly answering the question, the notification would not go away. This is reflected in the data, and it keeps happening.

Error 2: Android Error: Index -1 requested, with a size of [X]

This seems like it could be a number of text messages, or a number of phone calls. We got two of these crashes from the same user; one said with a size of 1488, and a day later, we got the same error with a size of 1511.

In one case we got both an Index 0 requested, with a size of 0 error and an Index -1 requested, with a size of 1 error from the same user, within about an hour of each other.

Examples on Sentry: https://sentry.io/onnela-lab/production/issues/464623109/ https://sentry.io/onnela-lab/production/issues/440431291/ https://sentry.io/onnela-lab/production/issues/437974800/ https://sentry.io/onnela-lab/production/issues/353162686/ https://sentry.io/onnela-lab/production/issues/409644657/ https://sentry.io/onnela-lab/production/issues/406593270/ https://sentry.io/onnela-lab/production/issues/464623109/ https://sentry.io/onnela-lab/production/issues/541351386/ https://sentry.io/onnela-lab/production/issues/540535424/ https://sentry.io/onnela-lab/production/issues/529616738/ https://sentry.io/onnela-lab/production/issues/440431291/ https://sentry.io/onnela-lab/production/issues/525494832/ https://sentry.io/onnela-lab/production/issues/509341717/ https://sentry.io/onnela-lab/production/issues/502320313/ https://sentry.io/onnela-lab/production/issues/508557383/ https://sentry.io/onnela-lab/production/issues/501834235/ https://sentry.io/onnela-lab/production/issues/498933038/ https://sentry.io/onnela-lab/production/issues/492841459/ https://sentry.io/onnela-lab/production/issues/477067457/ https://sentry.io/onnela-lab/production/issues/475032950/ https://sentry.io/onnela-lab/production/issues/472549256/ https://sentry.io/onnela-lab/production/issues/437974800/

sesterki commented 6 years ago

This should be fixed in 336f51a019093708f94eece8f89f9700be17eee3 and so we should not see this error again on 2.3.2 +

zagorsky commented 6 years ago

A different error, but should be handled in the same fix: https://sentry.io/onnela-lab/production/issues/472846078/

Android Error: Attempt to invoke interface method 'boolean android.database.Cursor.moveToNext()' on a null object reference
Error message: Attempt to invoke interface method 'boolean android.database.Cursor.moveToNext()' on a null object reference
Error type: class java.lang.NullPointerException
Error-fill:
    org.beiwe.app.CrashHandler.writeCrashlog(CrashHandler.java:84)
    org.beiwe.app.listeners.SmsSentLogger.onChange(SmsSentLogger.java:79)
    android.database.ContentObserver.onChange(ContentObserver.java:130)
    android.database.ContentObserver.onChange(ContentObserver.java:145)
    android.database.ContentObserver$NotificationRunnable.run(ContentObserver.java:216)
    android.os.Handler.handleCallback(Handler.java:739)
    android.os.Handler.dispatchMessage(Handler.java:95)
    android.os.Looper.loop(Looper.java:145)
    android.app.ActivityThread.main(ActivityThread.java:5942)
    java.lang.reflect.Method.invoke(Native Method)
    java.lang.reflect.Method.invoke(Method.java:372)
    com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399)
    com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)
java threw an error with a null error cause or stack trace, this means we are manually creating a crash report.
sesterki commented 6 years ago

Added some logic to the call logger in 2bfad2709531784df274314fdea292706f5331fd to prevent it from generating this error, but I think all of the reported errors are from the sms logger.

zagorsky commented 6 years ago

This should be fixed in 336f51a (app version 2.3.2 and above) and 2bfad27 (app version 2.3.4 and above)