Web Audio API is silent when connected to bluetooth
Reported by
l...@lukeblaney.co.uk,
Aug 9 2016
|
|||||||||||||
Issue descriptionExample URL: https://webaudiodemos.appspot.com/midi-synth/index.html Steps to reproduce the problem: 1. Pair Android phone with Bluetooth speaker 2. Navigate to any site using sounds based on Web Audio API (for example: https://webaudiodemos.appspot.com/midi-synth/index.html ) 3. Listen for sound What is the expected behavior? Sound to be played through the bluetooth speaker. What went wrong? No sound was played. (Pressing the volume shows the bell icon, which normally only shows when audio is *not* playing) Did this work before? N/A Is it a problem with Flash or HTML5? HTML5 Does this work in other browsers? N/A Chrome version: 53.0.2785.49 Channel: beta OS Version: 6.0.1 Flash Version: Pairing to the bluetooth speaker after the page has loaded works correctly. The symptoms seem similar to https://bugs.chromium.org/p/chromium/issues/detail?id=355813 which was fixed 2 years ago. I can also reproduce this in stable version 51.0.2704.81, both inside the browser and as a standalone web app added to the homepage.
,
Dec 9 2016
,
Dec 16 2016
Finally remembered to try this with my bluetooth speakers at home. I loaded up the page and started playing audio on my phone, then connected to the bluetooth speaker. Audio came out of the speaker instead of the phone as expected. Chrome 55.0.2883.91, Nexus 5X, Android 7.1.1 Can you try with a Chrome 55?
,
Dec 17 2016
Still happening for me on Chrome 55.0.2883.91 (Sony Xperia Z3, Android 6.0.1) Note that the order you follow the steps in is very important. There's only a problem if you're connected to the bluetooth device *before* the page loads. Your comment suggests you tried this in the reverse order, which does works as expected (as mentioned in the original bug report)
,
Dec 22 2016
Interesting. I tried again just now. I connected to my bluetooth speakers. Then started chrome and loaded up the shiny drum machine demo. I hear it playing out the speakers. (It's really terrible sounding, but that's a different issue. When I switch back to the phones' speakers, it sounds fine.) Chrome 55.0.2883.91, Android 7.1.1. I'll try it again with a different phone running an older version of Android.
,
Dec 29 2016
Thank you for providing more feedback. Adding requester "rtoy@chromium.org" for another review and adding "Needs-Review" label for tracking. For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot
,
Jan 21 2017
Can confirm this issue exists. It's an issue with initiating the AudioContext while the Bluetooth is connected only on android chromium. The problem exists on the Chrome browser and the same issue happens with my app that uses the chromium webview. The issue is reported by many many users of my app all with different devices and all caused by using Bluetooth headsets.
,
Feb 6 2017
,
Feb 23 2017
Is there any progress on this issue or anything I can do to help assist with giving more info on the problem? Would really like to see this bug fixed soon.
,
Mar 13 2017
Cleaning up sheriffbot label "Needs-Review" label as a part of modified "Needs-Feedback" sheriffbot rule. [ref bug for cleanup 684919]
,
Jul 11 2017
Still waiting on an update or response on this issue.
,
Jul 18 2017
Sorry for the delay. I tried again, using my Nexus 5X running 7.1.2 with Chrome 59. Here's what I did. Connect to my bluetooth speakers (Chrome not running any WebAudio page). Use Google Play Music to play some songs through the speakers. Works fine. Start chrome and load the shiny drum machine demo. Press play on the demo. I hear the demo being played through the speakers. As before, the audio is pretty bad. I am guessing this is a buffer size mismatch between what the bluetooth audio buffer size should be and what WebAudio has selected. While playing to the speakers, I use Android Setting and disconnect from the speakers so that phone's internal speaker is used. The shiny drum machine sounds fine. For people who are having troubles, can you provide the model for the Android device you are using?
,
Jul 18 2017
Blu R1 HD Android 6.0 If the audiocontext is already set before connecting to Bluetooth then the Bluetooth will stutter/crackle. If the audiocontext is loaded after the Bluetooth then it is silent. Apps like YouTube have no Bluetooth issues with the device.
,
Jul 18 2017
Thanks. I will try again tonight, being sure to have not audiocontext running when first connecting to the speaker. I'm pretty sure my last experiment didn't have that.
,
Jul 18 2017
http://webaudiodemos.appspot.com/MIDIDrums/index.html Load the page then enable bluetooth and connect = stuttered audio Refresh the page when bluetooth is already connected = can't hear anything at all
,
Jul 18 2017
For the case when the page is loaded and I connect to bluetooth, I can speculate on what is happening. The default phone output has a certain audio buffer size. WebAudio sets its internal stuff with this value. When you connect the bluetooth speaker, the required buffer size probably changes to something larger. WebAudio doesn't notice this and uses the original size. This probably causes the stuttering. I will follow your instructions tonight and see what happens.
,
Jul 20 2017
Ok, I followed the instructions in c#15, after stopping chrome. I get stuttering audio and when I reload the page, I still get stuttering audio. Nexus 5X, Android 7.1.2, Chrome 59 (stable). http://rtoy.github.io/webaudio-hacks/tests/osc.html says the base latency is 4096 frames. That's way larger than I expected for a 5X. I'll have to look into that. And since I can't seem to reproduce this issue, I'm going to have to find a Blu R1 HD or some other phone that exhibits this problem.
,
Jul 23 2017
Are you able to come up with a fix for the audio low quality/stutter at least?
,
Jul 24 2017
That seems to be a different issue from this one. I'll file a new bug report for this.
,
Jul 24 2017
See issue 748157 for the stuttering problem.
,
Jul 29 2017
I just got a new Alcatel A30 Plus with Android 7.0 and it had the issue the same as you. So the silent audio may be happening on Android 6 and below and skipping on 7+.
,
Sep 1 2017
Anything yet?
,
Sep 5 2017
Tried again (using different Bluetooth speakers) using the midi-synth demo. Audio plays as expected. Also tried with a Nexus 9 tablet running Android 6.0 and chrome 60. The midi-synth demo works and I can hear audio. (Sounds funny though, but that's probably issue 748157.) What do you mean that you have the same issue as I do with your new Alcatel A30 Plus? You don't get silence connecting when connecting the the bluetooth speaker, but you get glitchy audio as mentioned in c#15? If yes, please follow up on issue 748157, which was created for the glitchy audio. This issue is about silent audio with bluetooth speakers. I still can't reproduce that.
,
Oct 13 2017
I encountered this bug today. Device Samsung Galaxy A3 2016 (SM-A310F), Android 6.0.1 (SM-A310F Build/MMB29) Chrome 61.0.3163.98 BT devices: JBL GO speaker and Hypons Model #JC229 headphones. The sound of the web-audio example is not directed to any bluetooth device. Not to speakers nor headphones. This problem seems to affect WebRTC audio also and other sounds generated by Chrome.
,
Nov 14 2017
Based on c#24, adding webrtc and internals>media
,
Nov 18 2017
My phone received an update to both Android and Chrome. Current Chrome is 62.0.3202.84, Android 7.0; SM-A310F Build/NDR90M. The problem persists, but there are some changes to the situation. - When I try to direct media audio to the Bluetooth device (by turning media audio on from the settings of the Bluetooth device, this being done from the phone), audio is muted for several seconds (no sound from the phone or the Bluetooth device). It seems like Chrome is trying to send audio to the Bluetooth device. - After a few seconds the sound restarts playing on the phone, not on the Bluetooth device. Looks like after failing to send the sound, Chrome falls back to playing on the phones speakers. - I have tried this with several Bluetooth devices with the same result. The phone is Samsung Galaxy A3 2016 (SM-A310F). Directing the sound to a Bluetooth device works fine with Spotify and any other program but Chrome. Concerns both Web Audio Api and WebRTC.
,
Jan 19 2018
device: Medion X10301, Android 6.0 (X1030X_20161010_v1.8) Android System WebView: 62.0.3202.84 We encountered the same bug in our music application, which is based on the Web Audio Api. If we start our application with an active Bluetooth connection, there will be no music playing. The currentTime of the AudioContext is always 0. If we instead connect the Bluetooth device if the application is already running there is no problem. If we start our application with an active Bluetooth connection, then disconnect the Bluetooth connection, create the AudioContext and connect to a Bluetooth device again, there is also no problem. Also tested with an Samsung Galaxy Note 8 (SM-N950F), Chrome 63.0.3239.111 Tested with several Bluetooth devices.
,
Mar 14 2018
Moto G5S+ (7.1.1) and Chrome 65.0.3325.109 Just ran into this too with a PWA. If Bluetooth headphones are paired while the app is in the foreground everything works fine (easiest way to do this is to turn Bluetooth off/on from the quickbar - don't switch to the settings app). If the app is sent to the background then sound will be muted when you bring it back and you'll have to repair your headphones. When sound isn't working the headphones still turn on and start hissing as if they are about to play something but no sound is ever played. If you plug in wired headphones after disconnecting Bluetooth headphones then you may still need to refresh the page to make audio work over the wired headphones. Playing regular videos etc seems fine - it's just AudioContext that has problems.
,
Mar 14 2018
I can confirm this post about baseLatency is true: https://stackoverflow.com/a/47328748 When you connect Bluetooth headphones while the app is running then the baseLatency stays the same as the phone speakers but if you send Chrome to the background and bring it back then baseLatency will now be 0.2+.
,
Mar 14 2018
When Bluetooth headphones are connected, providing any value for latencyHint to AudioContext crashes Chrome.
,
Mar 14 2018
@rtoy Are your speakers just speakers or also speakerphones? It seems like everyone else is using headphones (which 99% of the time are also headsets) or speakerphones (JBL GO). Unfortunately it seems like every device I can find has a mic so I can't test.
,
Mar 14 2018
Sorry to keep spamming. Confirmed the bug doesn't exist on Nexus 7 / Chrome 65.0.3325.109 / Android 6.0.1. So it's definitely down to the phone/tablet and not the headphones/speakers.
,
Apr 26 2018
This is a very strange and annoying issue. I have been able to reproduce the problem with every headphone/phone combination I have access to. In some rare cases the sound works for a while, but the connection is very unstable. I have tested this mainly with WebRTC, however. It seems to be the case that the problem is present with audio only WebRTC connections. With video included things seems to work more like expected.
,
Jul 27
Looking in the syslog I'm seeing the following: 07-26 23:33:02.229 30380 30439 W AudioTrack: AUDIO_OUTPUT_FLAG_FAST denied by client; transfer 1, track 48000 Hz, output 44100 Hz 07-26 23:33:02.229 2981 2981 W AudioFlinger: createTrack_l(): mismatch between requested flags (00000100) and output flags (00000000) So Chrome is probably failing to set MODE_IN_COMMUNICATION because of the wrong sample rate. There is a sampleRate option to AudioContext but Chrome doesn't seem to support it on any platforms. The latencyHint option no longer crashes Chrome for me and while setting it to "playback" does remove the sample rate error there's still no sound but maybe that's due to the high latency. #748157 seems to be a similar Bluetooth + 44khz vs 48khz issue.
,
Jul 27
,
Jul 27
I found a workaround but I wouldn't use it publicly unless you already have a better reason to request microphone access. It seems like it's possible to kick it into communication mode by opening the microphone stream. https://gist.github.com/kylemacfarlane/290208f70ff4b67599289e9ab101d23c 1) Request microphone access. What happens next will depend on your Bluetooth settings. 2a) If your headphones have "phone audio" enabled in Bluetooth settings then they will drop in quality for a few seconds. Most likely they are switching from the "headphone/media" profile to "headset/phone" profile. 2b) If you don't have "phone audio" enabled then audio will be played out of the phone speaker for a few seconds. 3) Keep creating new AudioContext instances. After 1-10s you'll get an instance with low latency. 4) Close the microphone stream to return the headphones to normal. 5) Volume might be louder or quieter than normal which needs to be fixed by changing the volume from the phone as using the remote on the headphones doesn't fix it. Volume is also messed up when disconnecting Bluetooth and going back to the phone speaker but adjusting the volume doesn't fix it and you have to wait for it to fix itself. Notes: - I don't trust the baseLatency attribute. I always get the same 80ms or 285ms values but I would guess it's really always closer to 500ms. Perhaps this is due to the 44khz vs 48khz issue and Android having to resample or reroute the audio. - If you don't close unused audio contexts then WebAudio will eventually stop working for a few minutes but not display any errors. This is even true across Chrome sessions so there's probably an OS level limit. - If you leave the microphone stream open and too many unused audio contexts open then all kind of weird things can happen like randomly switching between headphones and speaker, quality going up and down, etc. This could be related to the WebRTC issues others have mentioned. - I noticed every time the workaround creates a new audio context this is logged 12 times: 07-27 19:47:24.645 16825 16839 W chromium: [WARNING:push_pull_fifo.cc(97)] PushPullFIFO: overflow while pushing (overflowCount=1, availableFrames=12288, inputFrames=128, fifoLength=12288)
,
Aug 14
jjahifi: When you use WebRTC and get this problem, is WebAudio used at all?
,
Aug 17
grunell: We get the problem with WebRTC even when not using WebAudio. Audio will be routed to bluetooth sometimes, but mostly not. I have not been able find any pattern in this. The problem is very frustrating. Android Chrome works fine with WebRTC on any other aspect but routing audio to and from bluetooth devices. The only solution we have found is to create an app. That is, however, a workaround, not a fix. We would be very happy to have this working.
,
Aug 21
OK, thanks for the information.
,
Oct 14
,
Oct 25
The 8.1 update for the Moto G5S+ seems to have fixed the no sound problem but the latency is very high and you still need to use the hack in comment #36 to get a low latency audio context.
,
Jan 11
Setting defect without priority to Pri-2. |
|||||||||||||
►
Sign in to add a comment |
|||||||||||||
Comment 1 by ssamanoori@chromium.org
, Aug 9 2016