MediaSessionCompat#setMetadata causing bluetooth disconnect on some devices
@tianyif is already working on this.
Since Aug 9, 2023.
- Dominant language
- Java
- Stars
- 3k
- Forks
- 955
- Avg merge
- 12d 14h
- Merged PRs (30d)
- 2
Description
Hi Android Media team,
Question:
Are there any further documentation or information you can share about the limitation of MediaSessionCompat#setMetadata(MediaMetadataCompat)? And in what situation it could break bluetooth connection?
Background:
Recently we got customer reports that when our app tries play audio via bluetooth, it will break the bluetooth connection on some {phone, bluetooth device} pair. The experience is like:
- User connect bluetooth headset to phone, or connect the phone to car bluetooth.
- User start to play audio from our app.
- The bluetooth connection on phone immediately disconnect and playback goes back to the phone.
- Some report even saying it is crashing the car's media system.
It is not happening to all phone/BT device pair, only some of them.
Example of pairs that would disconnect the bluetooth:
- Pixel 7 pro + Bose QC II earbuds
- Nokia 7 plus + Bose QC II earbuds
- Redmi K20 Pro + Bose QC II earbuds
- OnePlus 7 Pro + Bose QC II earbuds
- Samsung Galaxy s22 + Aftershockz Aeropex/ OpenRun
- Samsung S9+ + Ford Explorer and Escape 2017
Example of pairs that playback on BT will work normally:
- OnePlus 11 + Audi Q7 2017
- OnePlus 11 + Tesla Model Y 2022
- Moto Stylus 5g + Audi Q7 2017
- Samsung s21 FE 5g + Bose QC II earbuds
Narrowing down the root cause:
We eventually nail down the issue to that there is issue in one of the String data field we passed in MediaMetadataCompact for MediaSessionCompat#setMedadata(MediaMetadataCompat). We don't know if it is because the String is too long or is null or any other issue yet. Given we can't reproduce locally and only has report from customer. If we pass a nice short string for that field in MediaMetadataCompact, it fixes the issue for the customer.
We still would like to get more info from Android Media team to understand the root cause. And could you add more documentation on the API on the things need to be cautious?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.