audioplayers
audioplayers copied to clipboard
Fatal Exception: java.util.ConcurrentModificationException
Firebase Crashlog:
Fatal Exception: java.util.ConcurrentModificationException
at java.util.LinkedHashMap$LinkedHashIterator.nextNode(LinkedHashMap.java:760)
at java.util.LinkedHashMap$LinkedValueIterator.next(LinkedHashMap.java:788)
at xyz.luan.audioplayers.AudioplayersPlugin$UpdateCallback.run(AudioplayersPlugin.java:57)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loopOnce(Looper.java:226)
at android.os.Looper.loop(Looper.java:313)
at android.app.ActivityThread.main(ActivityThread.java:8663)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:567)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1135)
Unfortunately, I only have this crash log from Firebase. I could not find out yet how the crash is caused. Shouldn't the error be prevented in the plugin?
Plz use issue template
I made some investigation, because this bug reproduces in my pet-project. It looks like Soundpool related bug. If you set PlayerMode.lowLatency
and keep ReleaseMode.release
then playing same audio simulateously could trigger a fatal error.
If you change to ReleaseMode.stop, the bug will disappear but you will be aple to play audio only 100 times.
The error fires from WrappedPlayer.actuallyPlay() if currentPlayer
already exists, at ref.handleIsPlaying()
call.
I guess, the reason is that extension tries to dispose played sound effect while you trying to play it again from async function call.
For my project I switched to https://pub.dev/packages/soundpool for Android... At least there are no crashes still. Maybe it could be useful to dig into this library's implementation to solve the problem or maybe even create simple wrapper to make API consistent.
I am also experiencing this, on Firebase this is reported as a crash, so it is an important issue.
We are happy to review any Merge-Requests regarding this issue.
I think this should be fixed via #1247 and #1272. Feel free to comment, if it still occurs.