Problems with HTML5

Published on May 16, 2011

Problems with HTML5 <Audio>

    When the Angry Birds HTML5 was shown at the Google I / O conference , in a stream of joy, few people noticed that the game actually requires Flash. The question is, why? After all, the game is written in the Google Web Toolkit (GWT) and uses the GWT-voices library to process sound.

    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 Microsoft camp, they spoke 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 are not yet approved.

    In fact, the reasons are slightly different, and the main one is that HTML5 <Audio> is not suitable for use in games or professional audio applications.

    The developer Ray Cromwell, who ported Quake2 to HTML5 a year ago (GwtQuake), points out two main shortcomings of HTML5 <Audio>

    First, in its current form, the HTML5 functionality does not allow the browser direct access to audio data, so it is impossible to synthesize sound on the fly, receive and process samples, apply additional effects, or even work properly with stereo.

    Secondly, HTML5 does not provide the necessary control over timing, but it is very important for perception - the human ear responds to sound delay even in a few milliseconds. Here it is almost impossible to start audio in that millisecond when it is required. In practice, in game development, a delay of not more than 7 ms is considered normal. However, in HTML5 you can only assign sounds with the setInterval or setTimeout commands, and this is too unreliable: exact timing is not guaranteed, there may be delays of up to 16 ms, and when these commands are used intensively, the browser starts to slow down. If you switch to another tab, the browser can greatly slow down the script to reduce the load on the CPU, because there is no "requestSoundEvent" function similar to requestAnimationFrame.

    That's why we look forwardWeb Audio API to remove a significant portion of the load from the CPU and provide acceptable timing. And we'll wait soon. Here's the relevant snippet from the Google I / O presentation.