audioplayers icon indicating copy to clipboard operation
audioplayers copied to clipboard

Fatal Exception: java.util.ConcurrentModificationException

Open offline-first opened this issue 2 years ago • 4 comments

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?

offline-first avatar Jul 29 '22 06:07 offline-first

Plz use issue template

Gustl22 avatar Aug 05 '22 11:08 Gustl22

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.

ASGAlex avatar Aug 22 '22 16:08 ASGAlex

I am also experiencing this, on Firebase this is reported as a crash, so it is an important issue.

JankoLancer avatar Aug 24 '22 07:08 JankoLancer

We are happy to review any Merge-Requests regarding this issue.

Gustl22 avatar Aug 30 '22 12:08 Gustl22

I think this should be fixed via #1247 and #1272. Feel free to comment, if it still occurs.

Gustl22 avatar Sep 27 '22 19:09 Gustl22