Skip to content

fix #478 by GPT5.2#479

Open
jesses2025smith wants to merge 1 commit intoSimformSolutionsPvtLtd:mainfrom
jesses2025smith:main
Open

fix #478 by GPT5.2#479
jesses2025smith wants to merge 1 commit intoSimformSolutionsPvtLtd:mainfrom
jesses2025smith:main

Conversation

@jesses2025smith
Copy link

Description

This PR fixes an Android crash during waveform extraction for some MP3 files (notably MP3s with ID3v2.4 tags).
Previously, when MediaCodec decoding failed, WaveformExtractor.stop() could be triggered multiple times (from async codec callbacks / error paths). This led to java.lang.IllegalStateException: codec is released already and a fatal crash on the main thread.

Changes in this PR:

  • Make WaveformExtractor.stop() idempotent (execute stop/release only once) using an atomic guard.
  • Wrap MediaCodec.stop(), MediaCodec.release(), and related cleanup with defensive try/catch to avoid crashing if the codec is already released.
  • Ensure error/exception paths properly stop and clean up resources.
  • Add guards to prevent invalid/zero perSamplePoints from causing premature stop and subsequent callback races.

Motivation:

  • Waveform extraction should never crash the host app; decode failures should be handled gracefully.
  • Verified that disabling waveform extraction avoids the crash (playback remains fine), so the issue is isolated to the extraction pipeline.

Checklist

  • The title of my PR starts with a Conventional Commit prefix (fix:, feat:, docs: etc).
  • 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.
  • No, this PR is not a breaking change.

Related Issues

Close #478

@jesses2025smith jesses2025smith changed the title fix: fix #478 by GPT5.2 fix #478 by GPT5.2 Jan 28, 2026
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.

Crash when extracting waveform for MP3 files with ID3v2.4 tags (MediaCodec "codec is released already")

1 participant