audio_waveforms icon indicating copy to clipboard operation
audio_waveforms copied to clipboard

fix: 🐛 Prevent crashes and ANR on network loss during playback

Open lavigarg-simform opened this issue 5 months ago • 0 comments

Description

Fixes three Android crash/freeze problems in playback and waveform extraction.

1. Crash when the extractor is stopped twice. Stop ran once at end-of-file and again on dispose, hitting an already-released codec (IllegalStateException: codec is released already). Teardown and decode callbacks now share a lock and a released flag, and codec references are cleared on stop. (#477, crash part of #478)

2. Crash on network drop. A lost connection during playback was reported as a hard error. Transient errors on a prepared player now auto-retry from the same position (5 attempts, 3s apart); unrecoverable loss shuts down cleanly and notifies Flutter instead of crashing. A single-reply guard ensures the prepare call responds once.

3. ANR on slow/dead network. Extraction setup ran on the main thread. It now runs on a background thread, and a failed extraction is caught and logged on the Dart side.

Checklist

  • [x] The title of my PR starts with a Conventional Commit prefix (fix:, feat:, docs: etc).
  • [x] I have followed the Contributor Guide when preparing my PR.
  • [ ] I have updated/added tests for ALL new/updated/fixed functionality.
  • [ ] I have updated/added relevant documentation in docs and added dartdoc comments with ///.
  • [ ] I have updated/added relevant examples in examples or docs.

Breaking Change?

  • [ ] Yes, this PR is a breaking change.
  • [x] No, this PR is not a breaking change.

Related Issues

Closes #488 Closes #477

Partially addresses #478 — this PR fixes the crash on ID3v2.4 files.

lavigarg-simform avatar Jun 19 '26 13:06 lavigarg-simform