Unified media pipeline audio latency
Reported by
yas...@gmail.com,
Mar 18 2016
|
||||||||||
Issue descriptionExample URL: http://buildoneforme.com/metronome-glitch/ Steps to reproduce the problem: 1. Open console window in developer tools 2. Click start 3. Listen to the clicks 4. Notice the "drift" value in the console window What is the expected behavior? Clicks sound regular, e.g. like you'd hear in a metronome. What went wrong? When "Unified media pipeline" is enabled in chrome://flags, clicks don't sound regular at all (gap in time between each click varies noticeably). I don't think the problem is with setTimeout(). I detect the drift in time, and it's usually less than 5 milliseconds. Did this work before? N/A Is it a problem with Flash or HTML5? HTML5 Does this work in other browsers? Yes Chrome version: 49.0.2623.92 Channel: stable OS Version: 5.1.1 Flash Version: It sounds fine on the desktop version of Chrome.
,
Mar 18 2016
Not sure what the issue is here, will need some investigation. I wouldn't count on this to work well generally though. If you need this kind of repetition WebAudio is much better choice. I'd guess something is causing audio callbacks to be irregular (possible OpenSLES with a simple buffer queue isn't great at this).
,
Mar 18 2016
yassam: could you compare with other devices as well? And as is mentioned above, I would assume that WebAudio is a better choice for what you want to accomplish.
,
Mar 18 2016
,
Mar 19 2016
I only have a Samsung Galaxy S3 and it's stuck on Chrome 47 because I don't have enough space to update it. It sounds even worse on this phone, for what it's worth.
,
Mar 19 2016
Thank you for providing more feedback. Assigning to requester "rsgavara@chromium.org" for another review. For more details visit https://sites.google.com/a/chromium.org/dev/issue-tracking/autotriage - Your friendly Sheriffbot
,
Mar 22 2016
I have an alternative to this code now that uses the Web Audio API. There's still a timing glitch: http://buildoneforme.com/metronome-webaudio/ Each "click" is still triggered via setTimeout(). It uses uses an AudioBufferSourceNode, instead of an audio element, to play the click. I realise this isn't the only way of using WebAudio, that there are alternative ways of doing the same thing and avoid the timing glitch. But I'd have thought what I'm doing in this code should sound ok, and it doesn't.
,
Mar 22 2016
,
Mar 22 2016
If you want precise scheduling of your clicks, using setTimeout to trigger the clicks with WebAudio is not the right way. cwilso@ has a great article on precise scheduling: http://www.html5rocks.com/en/tutorials/audio/scheduling/
,
Mar 22 2016
Thank you, yes I realise using WebAudio to do scheduling is the ideal solution, but just wanted to point out how significant the timing problems are on Android. Just to be clear, the problem is not latency with setTimeout: I log the discrepancy between the actual time of the setTimeout callback and the desired time, and it's of the order of 0-2 milliseconds, which is well within the error margin I need. The problem is that even when I play audio at the right time (in response to setTimeout), the actual time the sound is emitted is way off. It sounds fine on the desktop.
,
Mar 22 2016
I'd guess this happens when the audio device on android has a minimum buffer size longer than the period of your metronome click. We will play then try to play and write min_buffer_size frames and then immediately pause. If the next play() comes before min_buffer_size elapses, the play will be delayed. I don't think there's any way we can guarantee this can work short of always creating an OS level stream for each play() attempt -- which is generally not desirable due to resource load. I think this is WontFix with the expectation that short repeated sounds will need to go through WebAudio to work on a regular basis.
,
Mar 22 2016
Note that WebAudio on Android has a fairly large latency mostly because no tuning was done. This is in addition to the fact that some Android devices don't support a low-latency API so it's even larger.
,
Mar 23 2016
,
Mar 24 2016
,
Apr 28 2016
,
Jul 22 2016
This is WAI given the large buffer size required for certain Android devices. |
||||||||||
►
Sign in to add a comment |
||||||||||
Comment 1 by yas...@gmail.com
, Mar 18 2016