Collect: Out of bounds exception when FormEntryActivity paused

Created on 24 Oct 2019  路  3Comments  路  Source: getodk/collect

From Crashlytics here (requires auth).

Fatal Exception: java.lang.RuntimeException: Unable to pause activity {org.odk.collect.android/org.odk.collect.android.activities.FormEntryActivity}: java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
       at android.app.ActivityThread.performPauseActivityIfNeeded(ActivityThread.java:4126)
       at android.app.ActivityThread.performPauseActivity(ActivityThread.java:4092)
       at android.app.ActivityThread.performPauseActivity(ActivityThread.java:4066)
       at android.app.ActivityThread.handlePauseActivity(ActivityThread.java:4040)
       at android.app.ActivityThread.-wrap16(ActivityThread.java)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1717)
       at android.os.Handler.dispatchMessage(Handler.java:105)
       at android.os.Looper.loop(Looper.java:164)
       at android.app.ActivityThread.main(ActivityThread.java:6944)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)
Caused by java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
       at java.util.ArrayList.get(ArrayList.java:437)
       at org.odk.collect.android.views.ODKView.stopAudio(ODKView.java:621)
       at org.odk.collect.android.activities.FormEntryActivity.onPause(FormEntryActivity.java:2143)
       at android.app.Activity.performPause(Activity.java:7408)
       at android.app.Instrumentation.callActivityOnPause(Instrumentation.java:1414)
       at android.app.ActivityThread.performPauseActivityIfNeeded(ActivityThread.java:4115)
       at android.app.ActivityThread.performPauseActivity(ActivityThread.java:4092)
       at android.app.ActivityThread.performPauseActivity(ActivityThread.java:4066)
       at android.app.ActivityThread.handlePauseActivity(ActivityThread.java:4040)
       at android.app.ActivityThread.-wrap16(ActivityThread.java)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1717)
       at android.os.Handler.dispatchMessage(Handler.java:105)
       at android.os.Looper.loop(Looper.java:164)
       at android.app.ActivityThread.main(ActivityThread.java:6944)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)
bug in progress

Most helpful comment

@lognaturel this is definitelly not a regression in v1.24 I have seen the same stacktraces since I remember but it has not been common so I didnt work on it. Just wanted to clarify in case you ar臋 anxious.

All 3 comments

It initially looks related to the audio changes but after a little look it seems to me this is code from some old MediaPlayer stuff hanging around in the ODKView and the QuestionWidget - we should look at cleaning this all out. The interesting part is that the OutOfBoundsException actually had nothing to do with audio as far as I can see: the stopAudio method assumes that there is always at least one element in the ODKView's widget field and tries to access first element. This method is called when the Activity itself is paused.

I think the fix is just to pull this line out as it's just theoretically dead code.

@lognaturel this is definitelly not a regression in v1.24 I have seen the same stacktraces since I remember but it has not been common so I didnt work on it. Just wanted to clarify in case you ar臋 anxious.

Thanks, @grzesiek2010, @seadowg! I filed it because it looked related to the new audio code but given what you've said, it doesn't look like a candidate for a point release and we can just get the fix in to v1.25.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

nap2000 picture nap2000  路  6Comments

yanokwa picture yanokwa  路  4Comments

mateusmedeiros picture mateusmedeiros  路  4Comments

grzesiek2010 picture grzesiek2010  路  5Comments

mmarciniak90 picture mmarciniak90  路  5Comments