Description
Version
Media3 1.3.1
More version details
This is still in 1.3.1. I believe it was either a new issue in 1.3 or it became much worse after 1.3
Devices that reproduce the issue
Android 14, several manufacturers
Devices that do not reproduce the issue
I attached firebase screenshot.
Reproducible in the demo app?
Not tested
Reproduction steps
This happens during playlist transitions. I see it in production data and reports from users. I've definitely had it happen but can't reproduce easily or 100%
Caused by java.lang.IllegalArgumentException: sizeToOutput is not aligned to frame size: 8466
at androidx.media3.common.util.Assertions.checkArgument(Assertions.java:55)
at androidx.media3.exoplayer.audio.SilenceSkippingAudioProcessor.outputSilence(SilenceSkippingAudioProcessor.java:632)
at androidx.media3.exoplayer.audio.SilenceSkippingAudioProcessor.outputShortenedSilenceBuffer(SilenceSkippingAudioProcessor.java:471)
at androidx.media3.exoplayer.audio.SilenceSkippingAudioProcessor.onQueueEndOfStream(SilenceSkippingAudioProcessor.java:302)
at androidx.media3.common.audio.BaseAudioProcessor.queueEndOfStream(BaseAudioProcessor.java:68)
at androidx.media3.common.audio.AudioProcessingPipeline.processData(AudioProcessingPipeline.java:327)
at androidx.media3.common.audio.AudioProcessingPipeline.getOutput(AudioProcessingPipeline.java:229)
at androidx.media3.exoplayer.audio.DefaultAudioSink.processBuffers(DefaultAudioSink.java:1110)
at androidx.media3.exoplayer.audio.DefaultAudioSink.drainToEndOfStream(DefaultAudioSink.java:1139)
at androidx.media3.exoplayer.audio.DefaultAudioSink.handleBuffer(DefaultAudioSink.java:890)
at androidx.media3.exoplayer.audio.MediaCodecAudioRenderer.processOutputBuffer(MediaCodecAudioRenderer.java:743)
at androidx.media3.exoplayer.mediacodec.MediaCodecRenderer.drainOutputBuffer(MediaCodecRenderer.java:2010)
at androidx.media3.exoplayer.mediacodec.MediaCodecRenderer.render(MediaCodecRenderer.java:827)
at androidx.media3.exoplayer.ExoPlayerImplInternal.doSomeWork(ExoPlayerImplInternal.java:1102)
at androidx.media3.exoplayer.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:541)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loopOnce(Looper.java:224)
at android.os.Looper.loop(Looper.java:318)
at android.os.HandlerThread.run(HandlerThread.java:67)
I get this exception in production sporadically, and it causes audio to stop playback. It only happens when transitioningg from
playlist item to another. Disabling the silence skipper resolves it, so I'm fairly positive that is the cause. Here is my RendererFactory
override fun buildAudioSink(
context: Context,
enableFloatOutput: Boolean,
enableAudioTrackPlaybackParams: Boolean,
): AudioSink? {
val mySilenceSkippingProcessor = SilenceSkippingAudioProcessor(
DEFAULT_MINIMUM_SILENCE_DURATION_US * 2,
DEFAULT_PADDING_SILENCE_US * 5,
(DEFAULT_SILENCE_THRESHOLD_LEVEL / 2).toShort()
)
val chain = DefaultAudioSink.DefaultAudioProcessorChain(
emptyArray(),
mySilenceSkippingProcessor,
SonicAudioProcessor()
)
val sink = DefaultAudioSink.Builder(context)
.setEnableFloatOutput(enableFloatOutput)
.setAudioOffloadSupportProvider(DefaultAudioOffloadSupportProvider(context))
.setEnableAudioTrackPlaybackParams(enableAudioTrackPlaybackParams)
.setAudioProcessorChain(chain)
.build()
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
sink.setOffloadMode(OFFLOAD_MODE_ENABLED_GAPLESS_NOT_REQUIRED)
}
return sink
}
Expected result
Exception should not be thrown, and playlist transition should occur
Actual result
Exception is thrown and playback stops
Media
My app is a podcast app. I don't have a particular audio file
Bug Report
- You will email the zip file produced by
adb bugreport
to android-media-github@google.com after filing this issue.
Activity
icbaker commentedon May 8, 2024
Assigning to @tonihei as the author of dfe4721
tonihei commentedon May 10, 2024
Thanks for reporting. I can reproduce a very similar issue, but not exactly the same one. I believe they both have the same root cause though and the exact manifestation depends on the media files and their silences.
The problem is that
SilenceSkippingAudioProcessor
updates its internal value for the current format too early (where it should have relied on the existing handling in the base class). This causes issues where the audio format changes, e.g. from stereo to mono. Not sure how well you can see or check the properties of the media items you transition between in the error cases, but I guess these issues happen in cases where the channel count of the media is different.dabluck commentedon May 10, 2024
Thanks for getting back to me @tonihei I could check the media formats if necessary, but basically any media file could show up in an RSS feed.
Is there a workaround you suggest?
tonihei commentedon May 10, 2024
I'm about to submit a fix, but don't know a good workaround for the existing code (except to disable silence skipping shortly before the transition)
dabluck commentedon May 10, 2024
Thanks for getting to it so quickly.
Use BaseAudioProcessor format tracking in SilenceSkippingAudioProcessor
aljohnston112 commentedon May 22, 2024
What release will the fix be in?
tonihei commentedon May 23, 2024
The upcoming 1.4.0 releases (starting with
1.4.0-alpha02
later this week or next week)