When they showed Angry Birds on HTML5 at the Google I / O conference, few people noticed in the stream of joy that the game actually requires Flash. The question is why? After all, the game is written on the Google Web Toolkit (GWT) and uses the GWT-voices library for sound processing.
There were thoughts that in this way the developer tried to block the game for iOS users (they buy it for money in the App Store). From the camp, Microsoft expressed in the sense that Google deliberately optimized the game for its “buggy” and “non-standard” Chrome, while IE supports <Audio> much better and does not experiment with functions that have not yet been approved.
In fact, the reasons are slightly different, and the main one is that HTML5 <Audio> is not yet suitable for use in games or professional audio applications. Developer Ray Cromwell, who ported Quake2 to HTML5 a year ago (GwtQuake), identifies two major flaws in HTML5 <Audio> ')
First, in its current form, HTML5 functionality does not allow the browser to directly access audio data, so it is impossible to synthesize sound on the fly, receive and process samples, impose additional effects, or even work normally with stereo.
Secondly, HTML5 does not provide the necessary control over timing, and in fact it is very important for perception - the human ear reacts to the sound delay even in a few milliseconds. Here it is almost impossible to start audio in the millisecond when it is required. In practice, the development of games is considered a normal delay of no more than 7 ms. However, in HTML5 you can assign sounds only with the setInterval or setTimeout commands, and this is too unreliable: accurate timing is not guaranteed, there can be delays of up to 16 ms, and with intensive use of these commands, the browser starts to slow down. If you switch to another tab, the browser can slow down the script to reduce the load on the CPU, because there is no “requestSoundEvent” function, similar to requestAnimationFrame.
That is why we are looking forward to the Web Audio API to take a significant part of the load off the CPU and ensure acceptable timing. And we will wait soon. Here is the relevant piece of video from the Google I / O presentation.