Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Occasional crash in form with many audio questions that autoplay #6085

Open
lognaturel opened this issue Apr 11, 2024 · 0 comments
Open

Occasional crash in form with many audio questions that autoplay #6085

lognaturel opened this issue Apr 11, 2024 · 0 comments
Milestone

Comments

@lognaturel
Copy link
Member

lognaturel commented Apr 11, 2024

ODK Collect version

v2024.1.0 - v2024.1.3 (Crashlytics)

Android version

87% Android 13 since start (but also some 9, 12, 14 so maybe it's just the devices that happen to have forms that trigger this)

Device used

91% Samsung since start, reported by a user with a fleet of Galaxy Tab S7 5G, 82% of occurrences are with Galaxy Tab Active3 (probably just happens to be those devices that have forms that trigger this)

Problem description

A user reports seemingly-random crashes while navigating through the section of a form that is many select questions with autoplay audio media. Users don't see any crash message when Collect restarts.

Crashlytics shows two stacktraces from crashes from `mediaplayer.prepare` and `mediaplayer.setDataSource` ```javarosa Fatal Exception: java.lang.IllegalStateException: at android.media.MediaPlayer._prepare(MediaPlayer.java) at android.media.MediaPlayer.prepare(MediaPlayer.java:1435) at org.odk.collect.audioclips.AudioClipViewModel.loadNewClip$lambda$3(AudioClipViewModel.kt:26) at org.odk.collect.async.CoroutineScheduler$immediate$1$result$1.invokeSuspend(CoroutineScheduler.kt:12) at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:11) at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:98) at kotlinx.coroutines.internal.LimitedDispatcher$Worker.run(LimitedDispatcher.kt:3) at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:2) at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:14) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:28) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt) ```
Fatal Exception: java.lang.IllegalStateException:
       at android.media.MediaPlayer._setDataSource(MediaPlayer.java)
       at android.media.MediaPlayer.setDataSource(MediaPlayer.java:1251)
       at android.media.MediaPlayer.setDataSource(MediaPlayer.java:1234)
       at android.media.MediaPlayer.setDataSource(MediaPlayer.java:1188)
       at android.media.MediaPlayer.setDataSource(MediaPlayer.java:1164)
       at android.media.MediaPlayer.setDataSource(MediaPlayer.java:1131)
       at org.odk.collect.audioclips.AudioClipViewModel.loadNewClip$lambda$3(AudioClipViewModel.kt:23)
       at org.odk.collect.async.CoroutineScheduler$immediate$1$result$1.invokeSuspend(CoroutineScheduler.kt:12)
       at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:11)
       at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:98)
       at kotlinx.coroutines.internal.LimitedDispatcher$Worker.run(LimitedDispatcher.kt:3)
       at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:2)
       at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt)
       at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:14)
       at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:28)
       at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt)

We always call

mediaPlayer.reset()
mediaPlayer.setDataSource(uri)
mediaPlayer.prepare()

which should put the player in the correct states according to the state diagram.

Steps to reproduce the problem

It can't be reproduced systematically.

I've used audio crash.zip to try to reproduce but can't.

Expected behavior

No crash.

Other information

Presumably introduced by https://github.com/getodk/collect/pull/5836/files#diff-dd7070cc2905fbf7e644eac39e7590ff53ccf92fc0dfb39512a55315099e9619

I'm opening this issue to have a record of what we've considered/discovered here. I think it's likely there's some weird Samsung-Android 13 platform bug that we're hitting so I don't think we need to take immediate action.

Another idea is that mediaplayer is not threadsafe. Is there a way we could somehow be calling mediaplayer methods from different threads under some conditions?

@seadowg seadowg added this to the v2024.3 milestone Apr 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: not ready
Development

No branches or pull requests

2 participants