Skip to content

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

@jesses2025smith

Description

@jesses2025smith

Describe the bug

  • On Android, the app crashes when audio_waveforms extracts waveforms / decodes certain MP3 files. The crash happens consistently with MP3 files that have ID3 version 2.4.0 tags. MP3 files with ID3 version 2.3.0 tags (same audio encoding parameters) work fine. The fatal exception is java.lang.IllegalStateException: codec is released already, and the stack trace points to com.simform.audio_waveforms.WaveformExtractor.stop(...).
  • Normal on iOS

To Reproduce
Steps to reproduce the behavior:

  1. Run an Android app that uses audio_waveforms v2.0.2 (e.g., using PlayerController.preparePlayer(..., shouldExtractWaveform: true) / AudioFileWaveforms).
  2. Use an MP3 file with ID3 version 2.4.0 tags (example: video_parse_1769586510156.mp3). File info: MPEG ADTS, layer III, v1, 128 kbps, 44.1 kHz, JointStereo.
  3. Start waveform extraction / playback.
  4. Observe the crash. Logcat shows messages like:
oplayer2/audio/AudioTrackPositionTracker; (domain=app) using reflection: allowed
D/AudioSystem(28749): onNewServiceWithAdapter: media.audio_flinger service obtained 0xb400006f48b51d30
D/AudioSystem(28749): getService: checking for service media.audio_flinger: 0xb400006f28b5a240
I/ExoPlayerImpl(28749): Init 989c917 [ExoPlayerLib/2.17.1] [ASUS_AI2401, ASUS_AI2401_H, asus, 36]
W/AudioCapabilities(28749): Unsupported mediaType audio/alac
W/AudioCapabilities(28749): Unsupported mediaType audio/x-ape
W/AudioCapabilities(28749): Unsupported mediaType audio/dsd
W/AudioCapabilities(28749): Unsupported mediaType audio/amr-wb-plus
W/AudioCapabilities(28749): Unsupported mediaType audio/amr-wb+
W/AudioCapabilities(28749): Unsupported mediaType audio/x-ms-wma
W/AudioCapabilities(28749): Unsupported mediaType audio/alac
W/AudioCapabilities(28749): Unsupported mediaType audio/x-ape
W/AudioCapabilities(28749): Unsupported mediaType audio/iamf
W/VideoCapabilities(28749): Unrecognized profile 8 for video/hevc
W/VideoCapabilities(28749): Unrecognized profile 8 for video/hevc
W/VideoCapabilities(28749): Unrecognized profile 8 for video/hevc
W/VideoCapabilities(28749): Unrecognized profile 8 for video/hevc
W/VideoCapabilities(28749): Unrecognized profile 8 for video/hevc
W/VideoCapabilities(28749): Unrecognized profile 8 for video/hevc
W/VideoCapabilities(28749): Unsupported mime image/vnd.android.heic
W/AudioCapabilities(28749): Unsupported mime audio/alac
W/AudioCapabilities(28749): Unsupported mime audio/x-ape
W/AudioCapabilities(28749): Unsupported mime audio/dsd
W/AudioCapabilities(28749): Unsupported mime audio/amr-wb-plus
W/AudioCapabilities(28749): Unsupported mime audio/amr-wb+
W/AudioCapabilities(28749): Unsupported mime audio/x-ms-wma
W/AudioCapabilities(28749): Unsupported mime audio/alac
W/AudioCapabilities(28749): Unsupported mime audio/x-ape
W/AudioCapabilities(28749): Unsupported mime audio/iamf
W/VideoCapabilities(28749): Unrecognized profile 8 for video/hevc
W/VideoCapabilities(28749): Unrecognized profile 8 for video/hevc
W/VideoCapabilities(28749): Unrecognized profile 8 for video/hevc
W/VideoCapabilities(28749): Unrecognized profile 8 for video/hevc
W/VideoCapabilities(28749): Unrecognized profile 8 for video/hevc
W/VideoCapabilities(28749): Unrecognized profile 8 for video/hevc
W/VideoCapabilities(28749): Unrecognized profile 8 for video/hevc
W/VideoCapabilities(28749): Unrecognized profile 8 for video/hevc
W/VideoCapabilities(28749): Unrecognized profile 8 for video/hevc
W/VideoCapabilities(28749): Unrecognized profile 8 for video/hevc
W/VideoCapabilities(28749): Unrecognized profile 8 for video/hevc
W/VideoCapabilities(28749): Unsupported mime image/vnd.android.heic
W/VideoCapabilities(28749): Unsupported mime image/vnd.android.heic
I/DMCodecAdapterFactory(28749): Creating an asynchronous MediaCodec adapter for track type audio
D/CCodec  (28749): allocate(c2.android.mp3.decoder)
I/ApexCodecsLazy(28749): Failed to load libcom.android.media.swcodec.apexcodecs.so: dlopen failed: library "libcom.android.media.swcodec.apexcodecs.so" not found
I/Codec2Client(28749): Available Codec2 services: "default" "default2" "software"
I/CCodec  (28749): setting up 'default' as default (vendor) store
I/CCodec  (28749): Created component [c2.android.mp3.decoder] for [c2.android.mp3.decoder]
D/CCodecConfig(28749): read media type: audio/mpeg
D/ReflectedParamUpdater(28749): extent() != 1 for single value type: algo.buffers.max-count.values
D/ReflectedParamUpdater(28749): extent() != 1 for single value type: output.subscribed-indices.values
D/ReflectedParamUpdater(28749): extent() != 1 for single value type: input.buffers.allocator-ids.values
D/ReflectedParamUpdater(28749): extent() != 1 for single value type: output.buffers.allocator-ids.values
D/ReflectedParamUpdater(28749): extent() != 1 for single value type: algo.buffers.allocator-ids.values
D/ReflectedParamUpdater(28749): extent() != 1 for single value type: output.buffers.pool-ids.values
D/ReflectedParamUpdater(28749): extent() != 1 for single value type: algo.buffers.pool-ids.values
I/CCodecConfig(28749): query failed after returning 8 values (BAD_INDEX)
D/CCodecConfig(28749): c2 config diff is Dict {
D/CCodecConfig(28749):   c2::u32 coded.bitrate.value = 64000
D/CCodecConfig(28749):   c2::u32 input.buffers.max-size.value = 8192
D/CCodecConfig(28749):   c2::u32 input.delay.value = 0
D/CCodecConfig(28749):   string input.media-type.value = "audio/mpeg"
D/CCodecConfig(28749):   c2::u32 output.large-frame.max-size = 0
D/CCodecConfig(28749):   c2::u32 output.large-frame.threshold-size = 0
D/CCodecConfig(28749):   string output.media-type.value = "audio/raw"
D/CCodecConfig(28749):   c2::u32 raw.channel-count.value = 2
D/CCodecConfig(28749):   c2::u32 raw.sample-rate.value = 44100
D/CCodecConfig(28749): }
I/MediaCodec(28749): MediaCodec will operate in async mode
E/MediaCodec(28749): Media Quality Service not found.
D/CCodec  (28749): [c2.android.mp3.decoder] buffers are bound to CCodec for this session
D/CCodecConfig(28749): no c2 equivalents for flags
D/CCodecConfig(28749): config failed => CORRUPTED
W/Codec2Client(28749): query -- param skipped: index = 1107298332.
D/CCodec  (28749): client requested max input size 4096, which is smaller than what component recommended (8192); overriding with component recommendation.
W/CCodec  (28749): This behavior is subject to change. It is recommended that app developers double check whether the requested max input size is in reasonable range.
D/CCodec  (28749): encoding statistics level = 0
D/CCodec  (28749): setup formats input: AMessage(what = 0x00000000) = {
D/CCodec  (28749):   int32_t bitrate = 64000
D/CCodec  (28749):   int32_t channel-count = 2
D/CCodec  (28749):   int32_t max-input-size = 8192
D/CCodec  (28749):   string mime = "audio/mpeg"
D/CCodec  (28749):   int32_t sample-rate = 44100
D/CCodec  (28749): }
D/CCodec  (28749): setup formats output: AMessage(what = 0x00000000) = {
D/CCodec  (28749):   int32_t buffer-batch-max-output-size = 0
D/CCodec  (28749):   int32_t buffer-batch-threshold-output-size = 0
D/CCodec  (28749):   int32_t channel-count = 2
D/CCodec  (28749):   string mime = "audio/raw"
D/CCodec  (28749):   int32_t sample-rate = 44100
D/CCodec  (28749):   int32_t android._config-pcm-encoding = 2
D/CCodec  (28749): }
I/CCodecConfig(28749): query failed after returning 8 values (BAD_INDEX)
E/om.dianyaai.app(28749): Failed to query component interface for required system resources: 6
D/MediaCodec(28749): keep callback message for reclaim
W/Codec2Client(28749): query -- param skipped: index = 1342179345.
W/Codec2Client(28749): query -- param skipped: index = 2415921170.
D/C2Store (28749): debug.c2.use_dmabufheaps set, forcing DMABUF Heaps
D/C2Store (28749): Using DMABUF Heaps
D/CCodecBufferChannel(28749): [c2.android.mp3.decoder#96] Created input block pool with allocatorID 16 => poolID 17 - OK (0)
I/CCodecBufferChannel(28749): [c2.android.mp3.decoder#96] Created output block pool with allocatorID 16 => poolID 1772 - OK
D/CCodecBufferChannel(28749): [c2.android.mp3.decoder#96] Configured output block pool ids 1772 => OK
D/CCodecBufferChannel(28749): [c2.android.mp3.decoder#96] start: updating output delay 0
I/DMABUFHEAPS(28749): Using DMA-BUF heap named: system
D/MediaCodecList(28749): codecHandlesFormat: no format, so no extra checks
D/CCodec  (28749): allocate(c2.android.mp3.decoder)
I/CCodec  (28749): setting up 'default' as default (vendor) store
I/CCodec  (28749): Created component [c2.android.mp3.decoder] for [c2.android.mp3.decoder]
D/CCodecConfig(28749): read media type: audio/mpeg
D/ReflectedParamUpdater(28749): extent() != 1 for single value type: algo.buffers.max-count.values
D/ReflectedParamUpdater(28749): extent() != 1 for single value type: output.subscribed-indices.values
D/ReflectedParamUpdater(28749): extent() != 1 for single value type: input.buffers.allocator-ids.values
D/ReflectedParamUpdater(28749): extent() != 1 for single value type: output.buffers.allocator-ids.values
D/ReflectedParamUpdater(28749): extent() != 1 for single value type: algo.buffers.allocator-ids.values
D/ReflectedParamUpdater(28749): extent() != 1 for single value type: output.buffers.pool-ids.values
D/ReflectedParamUpdater(28749): extent() != 1 for single value type: algo.buffers.pool-ids.values
I/CCodecConfig(28749): query failed after returning 8 values (BAD_INDEX)
D/CCodecConfig(28749): c2 config diff is Dict {
D/CCodecConfig(28749):   c2::u32 coded.bitrate.value = 64000
D/CCodecConfig(28749):   c2::u32 input.buffers.max-size.value = 8192
D/CCodecConfig(28749):   c2::u32 input.delay.value = 0
D/CCodecConfig(28749):   string input.media-type.value = "audio/mpeg"
D/CCodecConfig(28749):   c2::u32 output.large-frame.max-size = 0
D/CCodecConfig(28749):   c2::u32 output.large-frame.threshold-size = 0
D/CCodecConfig(28749):   string output.media-type.value = "audio/raw"
D/CCodecConfig(28749):   c2::u32 raw.channel-count.value = 2
D/CCodecConfig(28749):   c2::u32 raw.sample-rate.value = 44100
D/CCodecConfig(28749): }
E/MediaCodec(28749): Media Quality Service not found.
D/CCodec  (28749): [c2.android.mp3.decoder] buffers are bound to CCodec for this session
D/CCodecConfig(28749): no c2 equivalents for track-id
D/CCodecConfig(28749): no c2 equivalents for durationUs
D/CCodecConfig(28749): no c2 equivalents for flags
D/CCodecConfig(28749): c2 config diff is   c2::u32 coded.bitrate.value = 128000
W/Codec2Client(28749): query -- param skipped: index = 1107298332.
D/CCodec  (28749): encoding statistics level = 0
D/CCodec  (28749): setup formats input: AMessage(what = 0x00000000) = {
D/CCodec  (28749):   int32_t bitrate = 128000
D/CCodec  (28749):   int32_t channel-count = 2
D/CCodec  (28749):   int32_t max-input-size = 8192
D/CCodec  (28749):   string mime = "audio/mpeg"
D/CCodec  (28749):   int32_t sample-rate = 44100
D/CCodec  (28749): }
D/CCodec  (28749): setup formats output: AMessage(what = 0x00000000) = {
D/CCodec  (28749):   int32_t buffer-batch-max-output-size = 0
D/CCodec  (28749):   int32_t buffer-batch-threshold-output-size = 0
D/CCodec  (28749):   int32_t channel-count = 2
D/CCodec  (28749):   string mime = "audio/raw"
D/CCodec  (28749):   int32_t sample-rate = 44100
D/CCodec  (28749):   int32_t android._config-pcm-encoding = 2
D/CCodec  (28749): }
I/CCodecConfig(28749): query failed after returning 8 values (BAD_INDEX)
E/om.dianyaai.app(28749): Failed to query component interface for required system resources: 6
I/MediaCodec(28749): MediaCodec will operate in async mode
D/MediaCodec(28749): keep callback message for reclaim
W/Codec2Client(28749): query -- param skipped: index = 1342179345.
W/Codec2Client(28749): query -- param skipped: index = 2415921170.
D/CCodecBufferChannel(28749): [c2.android.mp3.decoder#611] Created input block pool with allocatorID 16 => poolID 18 - OK (0)
I/CCodecBufferChannel(28749): [c2.android.mp3.decoder#611] Created output block pool with allocatorID 16 => poolID 1774 - OK
D/CCodecBufferChannel(28749): [c2.android.mp3.decoder#611] Configured output block pool ids 1774 => OK
D/CCodecBufferChannel(28749): [c2.android.mp3.decoder#611] start: updating output delay 0
W/AudioSystem-JNI(28749): Unknown native audio format for JAVA API: 452984832
W/AudioSystem-JNI(28749): Unknown native audio format for JAVA API: 469762048
W/AudioSystem-JNI(28749): Unknown native audio format for JAVA API: 486539264
W/AudioSystem-JNI(28749): Unknown native audio format for JAVA API: 352321536
W/AudioSystem-JNI(28749): Unknown native audio format for JAVA API: 369098752
W/AudioSystem-JNI(28749): Unknown native audio format for JAVA API: 117440512
W/AudioSystem-JNI(28749): Unknown native audio format for JAVA API: 452984832
W/AudioSystem-JNI(28749): Unknown native audio format for JAVA API: 469762048
W/AudioSystem-JNI(28749): Unknown native audio format for JAVA API: 486539264
W/AudioSystem-JNI(28749): Unknown native audio format for JAVA API: 352321536
W/AudioSystem-JNI(28749): Unknown native audio format for JAVA API: 369098752
W/AudioSystem-JNI(28749): Unknown native audio format for JAVA API: 117440512
D/AudioTrack(28749): getTimestamp_l(9217): device stall time corrected using current time 690267591639443
W/AudioTrack(28749): getTimestamp_l(9217): retrograde timestamp time corrected, 690267586418974 < 690267591639443
D/CCodecBufferChannel(28749): [c2.android.mp3.decoder#611] MediaCodec discarded an unknown buffer
D/CCodecBufferChannel(28749): [c2.android.mp3.decoder#611] MediaCodec discarded an unknown buffer
D/CCodecBufferChannel(28749): [c2.android.mp3.decoder#611] MediaCodec discarded an unknown buffer
D/CCodecBufferChannel(28749): [c2.android.mp3.decoder#611] MediaCodec discarded an unknown buffer
E/AudioWaveforms(28749): Error processing output buffer: buffer is inaccessible
E/AudioWaveforms(28749): Error releasing output buffer: codec is released already
I/hw-BpHwBinder(28749): onLastStrongRef automatically unlinking death recipients
D/AndroidRuntime(28749): Shutting down VM
E/AndroidRuntime(28749): FATAL EXCEPTION: main
E/AndroidRuntime(28749): Process: com.dianyaai.app, PID: 28749
E/AndroidRuntime(28749): java.lang.IllegalStateException: codec is released already
E/AndroidRuntime(28749):        at android.media.MediaCodec.native_stop(Native Method)
E/AndroidRuntime(28749):        at android.media.MediaCodec.stop(MediaCodec.java:2838)
E/AndroidRuntime(28749):        at com.simform.audio_waveforms.WaveformExtractor.stop(WaveformExtractor.kt:405)
E/AndroidRuntime(28749):        at com.simform.audio_waveforms.WaveformExtractor$startDecode$1$1.onOutputBufferAvailable(WaveformExtractor.kt:235)
E/AndroidRuntime(28749):        at android.media.MediaCodec$EventHandler.handleCallback(MediaCodec.java:1982)
E/AndroidRuntime(28749):        at android.media.MediaCodec$EventHandler.handleMessage(MediaCodec.java:1880)
E/AndroidRuntime(28749):        at android.os.Handler.dispatchMessage(Handler.java:110)
E/AndroidRuntime(28749):        at android.os.Looper.loopOnce(Looper.java:288)
E/AndroidRuntime(28749):        at android.os.Looper.loop(Looper.java:408)
E/AndroidRuntime(28749):        at android.app.ActivityThread.main(ActivityThread.java:9331)
E/AndroidRuntime(28749):        at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(28749):        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:593)
E/AndroidRuntime(28749):        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:940)
I/Process (28749): Sending signal. PID: 28749 SIG: 9
Lost connection to device.

Expected behavior
MP3 files with ID3v2.4 tags should not crash the app. If decoding / waveform extraction fails, the plugin should handle the error gracefully and avoid calling MediaCodec.stop() after the codec has already been released.

Smartphone (please complete the following information):

  • Device: Asus Zenphone 12 Pro
  • OS: Android 16
  • Version: 2.0.2

Screenshots
None

Additional context
video_parse_1769586510156.mp3

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions