androidx / androidx/media

java.io.IOException: bt socket closed, read return

Open
#965 3 comments 0 reactions 1 assignee View on GitHub

@marcbaechinger is already working on this.

Since Jan 15, 2024.

bug needs triage
Dominant language
Java
Stars
3k
Forks
955
Avg merge
12d 14h
Merged PRs (30d)
2

Description

Version

Media3 1.1.1

More version details

We are using media3 library to send voice commands to the media outlet. We noticed that sending voice commands to exo player works great if there are not bluetooth devices connected to the phone. However, if the user is trying to use a bluetooth speaker (or headphones) while using our app, the bluetooth seems to crash occasionally, and pause the background music. For example, user is using Spotify to listen to the podcast. Every once in a while, they receive a spoken voice command from our app (via exoplayer). Each time they receive a command the system successfully ducks the podcast, and then gives it focus once our app is done. However, after 10-25 mins of back and forth, the bluetooth seems to crash, and the Spotify podcast fails to resume once our app gives away focus. I see the following error in the logs:

Error reading stream, exiting loop
                                                                                                    java.io.IOException: bt socket closed, read return: -1
                                                                                                    	at android.bluetooth.BluetoothSocket.read(BluetoothSocket.java:797)
                                                                                                    	at android.bluetooth.BluetoothInputStream.read(BluetoothInputStream.java:62)
                                                                                                    	at java.io.DataInputStream.readUnsignedByte(DataInputStream.java:296)
                                                                                                    	at csb.c(PG:2)
                                                                                                    	at bom.run(PG:7)
                                                                                                    	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
                                                                                                    	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644)
                                                                                                    	at java.lang.Thread.run(Thread.java:1012)

Is there a way to figure out why is this crashing only when user has bluetooth connected?

Devices that reproduce the issue
  • variety of Android devices
Devices that do not reproduce the issue

No response

Reproducible in the demo app?

Yes

Reproduction steps

Connect bluetooth speaker or headphones to the device. Start playing podcast in YouTube Music, or Spotify. Play and pause

Expected result

The background media resumes successfully.

Actual result

Every once in a while the background media fails to resume, and there is a bluetooth error in the logs.

Media

Follow up in email

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.