Skip to content

Conversation

@hsangtini
Copy link
Contributor

  • FIX 1: Iterate over a copy of the list to avoid ConcurrentModificationException.
  • FIX 2: Only reply once per request to avoid "Reply already submitted" crash.

Exception java.util.ConcurrentModificationException:
at java.util.ArrayList$Itr.checkForComodification (ArrayList.java:1111)
at java.util.ArrayList$Itr.next (ArrayList.java:1064)
at com.tundralabs.fluttertts.FlutterTtsPlugin.onInitListener$lambda$3 (FlutterTtsPlugin.java:221)
at android.speech.tts.TextToSpeech.lambda$dispatchOnInit$0 (TextToSpeech.java:934)
at android.speech.tts.TextToSpeech.$r8$lambda$goj8UKjdOAM21kdYLRXRNDpSxxI (Unknown Source)
at android.speech.tts.TextToSpeech$$ExternalSyntheticLambda1.run (Unknown Source:4)
at android.speech.tts.TextToSpeech.dispatchOnInit (TextToSpeech.java:943)
at android.speech.tts.TextToSpeech.-$$Nest$mdispatchOnInit (Unknown Source)
at android.speech.tts.TextToSpeech$Connection$SetupConnectionAsyncTask.onPostExecute (TextToSpeech.java:2324)
at android.speech.tts.TextToSpeech$Connection$SetupConnectionAsyncTask.onPostExecute (TextToSpeech.java:2284)
at android.os.AsyncTask.finish (AsyncTask.java:771)
at android.os.AsyncTask.-$$Nest$mfinish (Unknown Source)
at android.os.AsyncTask$InternalHandler.handleMessage (AsyncTask.java:788)
at android.os.Handler.dispatchMessage (Handler.java:106)
at android.os.Looper.loopOnce (Looper.java:230)
at android.os.Looper.loop (Looper.java:319)
at android.app.ActivityThread.main (ActivityThread.java:8919)
at java.lang.reflect.Method.invoke
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:578)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1103)

Exception java.lang.IllegalStateException: Reply already submitted
at io.flutter.embedding.engine.dart.DartMessenger$Reply.reply (DartMessenger.java:431)
at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler$1.success (MethodChannel.java:272)
at com.tundralabs.fluttertts.FlutterTtsPlugin.onInitListener$lambda$3 (FlutterTtsPlugin.java:240)
at android.speech.tts.TextToSpeech.lambda$dispatchOnInit$0 (TextToSpeech.java:934)
at android.speech.tts.TextToSpeech.$r8$lambda$goj8UKjdOAM21kdYLRXRNDpSxxI (Unknown Source)
at android.speech.tts.TextToSpeech$$ExternalSyntheticLambda1.run (Unknown Source:4)
at android.speech.tts.TextToSpeech.dispatchOnInit (TextToSpeech.java:943)
at android.speech.tts.TextToSpeech.-$$Nest$mdispatchOnInit (Unknown Source)
at android.speech.tts.TextToSpeech$Connection$SetupConnectionAsyncTask.onPostExecute (TextToSpeech.java:2324)
at android.speech.tts.TextToSpeech$Connection$SetupConnectionAsyncTask.onPostExecute (TextToSpeech.java:2284)
at android.os.AsyncTask.finish (AsyncTask.java:771)
at android.os.AsyncTask.-$$Nest$mfinish (Unknown Source)
at android.os.AsyncTask$InternalHandler.handleMessage (AsyncTask.java:788)
at android.os.Handler.dispatchMessage (Handler.java:106)
at android.os.Looper.loopOnce (Looper.java:230)
at android.os.Looper.loop (Looper.java:319)
at android.app.ActivityThread.main (ActivityThread.java:8919)
at java.lang.reflect.Method.invoke
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:578)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1103)

- FIX 1: Iterate over a copy of the list to avoid ConcurrentModificationException.
- FIX 2: Only reply once per request to avoid "Reply already submitted" crash.
- FIX 1: Iterate over a copy of the list to avoid ConcurrentModificationException.
- FIX 2: Only reply once per request to avoid "Reply already submitted" crash.
ymkil added a commit to ymkil/flutter_tts that referenced this pull request Aug 6, 2025
@hsangtini
Copy link
Contributor Author

hsangtini commented Aug 10, 2025

@dlutton please review, i tested in production and it's working great

@dlutton dlutton self-assigned this Aug 30, 2025
Copy link
Owner

@dlutton dlutton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@dlutton
Copy link
Owner

dlutton commented Sep 1, 2025

@hsangtini , does the PR in #594 also solve your issue? I need to determine which solution fits best here.

@hsangtini
Copy link
Contributor Author

I don’t know about that PR, but with my PR it’s working well in production. All crashes are gone.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants