Godot: Stuttering Audio on Chrome/Chromium (HTML5, Threads)

Created on 30 Oct 2020  路  5Comments  路  Source: godotengine/godot

Godot version:
3.2.4 Beta 1

OS/device including version:
Windows 10 - GLES2 - Custom Build with Threads

Issue description:
Stuttering Audio with Godot 3.2.4 Beta 1 (HTML5 Build)
Unfortunately with all tests we have done so far any build exported for Web have its audios heavily stuttering.

Steps to reproduce:
I've made a simple example below for testing purposes, this example has only one audio.

Minimal reproduction project:
Source Code:
AudioTest.zip

Online access:
https://jogosdev.afinando.com.br/AudioTest/

bug confirmed html5 regression audio

Most helpful comment

As a side note, nice issue number. :p

All 5 comments

Is it only in 3.2.4 Beta 4 or does it happen with 3.2.3 stable too?

It does happen on 3.2.3 stable too, but only for users with low performance computers, it is a know open issue.

But with 3.2.4 Beta 1 it is happening even with computer of high performance, we don't have users testing the 3.2.4 Beta 1 yet, this performance test I'm talking about was ran on the computers of our development team. Which are high performance computers.

I can confirm the issue on Linux, with Chrome/Chromium, but it works fine with Firefox (which is I guess why I didn't spot it).
I'll update the issue, and see what I can do.

As a side note, nice issue number. :p

See https://github.com/Faless/godot/tree/js/3.x_audio_latency_fix for a fixed 3.2 branch, or apply this patch to try the fix while we work towards the next 3.2.4 beta:

diff --git a/platform/javascript/audio_driver_javascript.cpp b/platform/javascript/audio_driver_javascript.cpp
index 36f6cb13d8..15fe5c8dca 100644
--- a/platform/javascript/audio_driver_javascript.cpp
+++ b/platform/javascript/audio_driver_javascript.cpp
@@ -101,7 +101,7 @@ Error AudioDriverJavaScript::init() {
    int latency = GLOBAL_GET("audio/output_latency");

    channel_count = godot_audio_init(mix_rate, latency);
-   buffer_length = closest_power_of_2((latency * mix_rate / 1000) * channel_count);
+   buffer_length = closest_power_of_2(latency * mix_rate / 1000);
    buffer_length = godot_audio_create_processor(buffer_length, channel_count);
    if (!buffer_length) {
        return FAILED;
diff --git a/platform/javascript/native/library_godot_audio.js b/platform/javascript/native/library_godot_audio.js
index d300280ccd..4e7f3e2af5 100644
--- a/platform/javascript/native/library_godot_audio.js
+++ b/platform/javascript/native/library_godot_audio.js
@@ -47,7 +47,7 @@ var GodotAudio = {
    godot_audio_init: function(mix_rate, latency) {
        GodotAudio.ctx = new (window.AudioContext || window.webkitAudioContext)({
            sampleRate: mix_rate,
-           latencyHint: latency
+           // latencyHint: latency / 1000 // Do not specify, leave 'interactive' for good performance.
        });
        return GodotAudio.ctx.destination.channelCount;
    },
Was this page helpful?
0 / 5 - 0 ratings