media: Crash on playback in onAudioCapabilitiesChanged

Version

Media3 1.3.0

More version details

No response

Devices that reproduce the issue

  • Fire TV Stick 4K

Devices that do not reproduce the issue

  • Nvidia Shield
  • Android emulator (API 33)

Reproducible in the demo app?

Not tested

Reproduction steps

Steps To Reproduce:

  1. Install and launch the app
  2. Go through the app content and use the functionality as outlined in description
  3. Select Music Category
  4. Click on play button Actual Result: Observe app force closes to launch page Expected Result: App must not experience force close, crash, or soft/hard lock while in use, even when dealing with conflicting inputs.

(Via Amazon tester)

Expected result

The androidx.media3 library should not cause a crash due to invalid state.

Actual result

The check in onAudioCapabilitiesChanged() fails because it is not called from the main thread. This appears to be a regression introduced in 432cde60511db47a739973cff7c2da287380fa15, to be specific the newly introduced “OnRoutingChangedListenerApi24”.

03-17 02:58:54.887: E/ACRA(10455): ACRA caught a IllegalStateException for org.jellyfin.androidtv
03-17 02:58:54.887: E/ACRA(10455): java.lang.IllegalStateException
03-17 02:58:54.887: E/ACRA(10455): 	at androidx.media3.common.util.Assertions.checkState(Assertions.java:85)
03-17 02:58:54.887: E/ACRA(10455): 	at androidx.media3.exoplayer.audio.DefaultAudioSink.onAudioCapabilitiesChanged(DefaultAudioSink.java:1527)
03-17 02:58:54.887: E/ACRA(10455): 	at androidx.media3.exoplayer.audio.DefaultAudioSink$$ExternalSyntheticLambda16.onAudioCapabilitiesChanged(D8$$SyntheticClass)
03-17 02:58:54.887: E/ACRA(10455): 	at androidx.media3.exoplayer.audio.AudioCapabilitiesReceiver.onNewAudioCapabilities(AudioCapabilitiesReceiver.java:205)
03-17 02:58:54.887: E/ACRA(10455): 	at androidx.media3.exoplayer.audio.AudioCapabilitiesReceiver.setRoutedDevice(AudioCapabilitiesReceiver.java:142)
03-17 02:58:54.887: E/ACRA(10455): 	at androidx.media3.exoplayer.audio.DefaultAudioSink$OnRoutingChangedListenerApi24.onRoutingChanged(DefaultAudioSink.java:1939)
03-17 02:58:54.887: E/ACRA(10455): 	at androidx.media3.exoplayer.audio.DefaultAudioSink$OnRoutingChangedListenerApi24.$r8$lambda$HRb3r58UkCrShJGoyBtN21Qgd6c(DefaultAudioSink.java)
03-17 02:58:54.887: E/ACRA(10455): 	at androidx.media3.exoplayer.audio.DefaultAudioSink$OnRoutingChangedListenerApi24$$ExternalSyntheticLambda4.onRoutingChanged(D8$$SyntheticClass)
03-17 02:58:54.887: E/ACRA(10455): 	at android.media.AudioTrack$NativeRoutingEventHandlerDelegate$1.handleMessage(AudioTrack.java:2764)
03-17 02:58:54.887: E/ACRA(10455): 	at android.os.Handler.dispatchMessage(Handler.java:102)
03-17 02:58:54.887: E/ACRA(10455): 	at android.os.Looper.loop(Looper.java:154)
03-17 02:58:54.887: E/ACRA(10455): 	at android.os.HandlerThread.run(HandlerThread.java:61)

Media

The Amazon tester used an MP3 file.

Bug Report

  • You will email the zip file produced by adb bugreport to android-media-github@google.com after filing this issue.

About this issue

Commits related to this issue

Most upvoted comments

I resubmitted the exact same app release to Amazon and this time they approved it

If this is not reproducible, I’m inclined to leave it for now until we know more. I’ll leave the issue open and if you or anyone else sees something like that again we can look into submitting a workaround.