Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cracking audio with Godot 4 no-threads Web builds #87329

Closed
Tracked by #76797
akien-mga opened this issue Jan 18, 2024 · 13 comments · Fixed by #91382
Closed
Tracked by #76797

Cracking audio with Godot 4 no-threads Web builds #87329

akien-mga opened this issue Jan 18, 2024 · 13 comments · Fixed by #91382

Comments

@akien-mga
Copy link
Member

Tested versions

Reproducible in 4.3.dev (1952f64) with a threads=no Web template.
The issue was "introduced" in #85939 since it wasn't possible to make single-threaded Web builds in Godot 4 before that.

System information

Mageia 9 - Vulkan (Forward+) - dedicated AMD Radeon RX Vega M GL Graphics (RADV VEGAM) () - Intel(R) Core(TM) i7-8705G CPU @ 3.10GHz (8 Threads)

Issue description

The newly reintroduced single-threaded Web export has audio issues, as expected.

On my Linux system, it's pretty dire on any demo that has background music, sfx, and any game logic or rendering effort that's non trivial (i.e. the CPU is kept busy).

Here's an example with the GDQuest TPS demo, uploaded to itch.io, with threads disabled (built from #85939):

https://akien.itch.io/godot4-nothreads-audio-test

(Ignore the weird rendering (Compatibility while the demo is designed for Forward+) and the fact that rotating the camera with the mouse seems to be broken in the Web build.)

Here's how the game sounds like on a native Linux build (editor):

simplescreenrecorder-2024-01-18_12.13.30.mp4

Here's the threads=no Web build (debug) on currently Firefox Nightly (123.0a1 (2024-01-17)) on the same Linux system:

simplescreenrecorder-2024-01-18_12.07.44.mp4

And the same on Chromium (120.0.6099.216) on the same Linux system:

simplescreenrecorder-2024-01-18_12.16.01.mp4

The issue is likely linked to OS, browser, and CPU, so for testers who can or cannot reproduce it, please include full info about what platform you tested on.

$ inxi -CSG
System:
  Host: cauldron Kernel: 6.5.13-desktop-6.mga9 arch: x86_64 bits: 64
    Desktop: KDE Plasma v: 5.27.5 Distro: Mageia 9
CPU:
  Info: quad core model: Intel Core i7-8705G bits: 64 type: MT MCP cache:
    L2: 1024 KiB
  Speed (MHz): avg: 900 min/max: 800/4100 cores: 1: 900 2: 900 3: 900 4: 900
    5: 900 6: 901 7: 900 8: 900
Graphics:
  Device-1: Intel HD Graphics 630 driver: i915 v: kernel
  Device-2: AMD Polaris 22 XL [Radeon RX Vega M GL] driver: amdgpu v: kernel
  Device-3: Cheng Uei Precision Industry (Foxlink) HP Wide Vision FHD Camera
    type: USB driver: uvcvideo
  Display: x11 server: X.org v: 1.21.1.8 with: Xwayland v: 22.1.9 driver: X:
    loaded: intel,v4l dri: i965 gpu: i915 resolution: 2048x1152~60Hz
  API: OpenGL v: 4.6 Mesa 23.3.2 renderer: Mesa Intel HD Graphics 630 (KBL
    GT2)

Steps to reproduce

  • Export a project with audio and some non-trivial game logic to the Web, with threads disabled (in 4.3-dev3 or later, or custom builds from master with threads=no)
  • Run it on an affected system. At least reproducible on my Linux laptop.

Minimal reproduction project (MRP)

https://akien.itch.io/godot4-nothreads-audio-test

@akien-mga
Copy link
Member Author

Same issue on Android 14 with a Pixel 7a, both with Firefox Beta 122.0b9 and Chrome 120.0.6099.210.

@popcar2
Copy link

popcar2 commented Jan 18, 2024

Windows 11 v23H2 here (full specs later). I'm also getting audio cackling in your example project on Firefox, Chrome, and Edge. It sometimes sounds fine probably when the game is running at full speed though.
Chrome and Edge also have major artifacts on the intro screen.

Firefox 121.0.1:

Firefox.1.mp4

Notes: Similar results to the post above, but it runs a lot smoother on my end due to better specs.

Microsoft Edge 120.0.2210.144 (WARNING: FLASHING COLORS):

Edge.1.mp4

Notes:

  • For some reason the intro screen is completely broken on Edge with lots of flashing and artifacting. This could possibly be its own issue, not sure if there is correlation between this and no-threads build.

  • After compiling shaders the sound seems stable, but it completely breaks again when I leave fullscreen. Entering fullscreen again doesn't fix it. Could also be its own issue?

Google Chrome Version 120.0.6099.225:

Notes: Exact same results as Microsoft Edge (see video above). Broken intro screen, good audio after shader compilation, audio breaks when exiting fullscreen.

Here are my specs:

Windows 11 Home - Version 23H2 / Build 22631.3007
Processor: AMD Ryzen 5 5600 @ 3.5GHz
GPU: RTX 3060 Ti - driver 546.33
RAM: 16GB

@starry-abyss
Copy link
Contributor

I'm a newbie in this, but maybe we could use Web Audio backend code from miniaudio library in Godot?

@wojtekmal
Copy link

wojtekmal commented Jan 19, 2024

The audio in my game runs perfectly when I run the linux release export, but my game isn't cpu intensive so this isn't very significant. Anyway, two things caught my attention. Firstly, audio from MRP on itch.io is of low quality, but when I switch to another tab, the audio quality suddenly increases to near perfect. I use firefox 122.0 64 bit. Secondly, the game is completely silent when I launch my game from the editor with f5, however as I said previously, it works in the export.
Here are my specs:

System:
  Host: lapwo Kernel: 6.5.0-14-generic x86_64 bits: 64 Desktop: GNOME 42.9
    Distro: Ubuntu 22.04.3 LTS (Jammy Jellyfish)
CPU:
  Info: quad core model: 11th Gen Intel Core i5-1135G7 bits: 64 type: MT MCP
    cache: L2: 5 MiB
  Speed (MHz): avg: 1053 min/max: 400/4200 cores: 1: 1200 2: 559 3: 1088
    4: 976 5: 1200 6: 1069 7: 1176 8: 1158
Graphics:
  Device-1: Intel TigerLake-LP GT2 [Iris Xe Graphics] driver: i915 v: kernel
  Device-2: Realtek LG Camera type: USB driver: uvcvideo
  Display: x11 server: X.Org v: 1.21.1.4 driver: X: loaded: modesetting
    unloaded: fbdev,vesa gpu: i915 resolution: 2560x1600~60Hz
  OpenGL: renderer: Mesa Intel Xe Graphics (TGL GT2)
    v: 4.6 Mesa 23.0.4-0ubuntu1~22.04.1

Edit: updated the specs to ones printed out by inxi. Also, the thing where switching to another tab improves audio quality also works on Chrome, but I think that this is happening just because looking away from the game is optimized and reduces cpu load.

@octanejohn
Copy link

octanejohn commented Feb 3, 2024

pixel 6 android 13 Kiwi Browser 120.0.6099.116, cracking and missing textures

Screenshot_20240203-192618

@wojtekmal
Copy link

I noticed that audio is broken regardless of whether I export with the option "Thread support". Of course when I export from the normal editor with normal templates (built without --treads=no) it still works.

@ChronoDK
Copy link

If you increase audio output latency.web to 90 it mostly goes away.

@popcar2
Copy link

popcar2 commented Feb 14, 2024

If you increase audio output latency.web to 90 it mostly goes away.

This... Actually works, thanks! Hopefully that can help track down the issue.
Here's my testing with the no threads template:

Latency.web 50 (default) - audio starts at 0:17 - Notice the insane crackling in the game over screen

50_latency.mp4

Latency.web 90 - audio starts at 0:11 - Audio has minor skips on frame drops but does not crackle

90_latency.mp4

@fire
Copy link
Member

fire commented Feb 14, 2024

@jasonwinterpixel Mentioned using Latency.web 150 in Godot Engine 3, but I didn't get the complete details on what harm this causes.

@jasonwinterpixel
Copy link
Contributor

It seems like audio should only crack if the CPU is maxed out. If the CPU isnt maxed, it should be able to fill the buffer properly. In the case where the CPU is maxed, the audio should stop and not 'ring' around the other side like it does in web on godot 3 right now.

We use a high audio latency in our games in single threaded builds, and tbh it bothers me quite a bit. I think I'd only be willing to tolerate ~50ms of audio latency.

@akien-mga
Copy link
Member Author

Needs testing on several projects/devices, but I suggest we look into increasing the default audio latency for the Web export in 4.3, mitigating the current issues. I agree with @jasonwinterpixel that high latency is a bother, but it's better than the kind of cracking we have currently.

It's not a long term solution, but it should be a good first step to make things at least usable.

@graphific
Copy link

Just FYI changing the audio output latency.web from 50 to 90 fixed the crackling issue almost entirely (having about 4-6 audio players procedurally playing different sound layers and only sometimes a tiny bit hickup, but the sound stays clear), for this jam game: https://graphific.itch.io/bird-ruckus

@Silvanuz
Copy link

FYI too:
Can confirm that changing the latency.web to 100 (max value) does nothing in my case.
But the sound cracks only on the left channel on iOS. With a panner to the right channel only everything sounds clean.

nanodeath added a commit to nanodeath/tippy-towers that referenced this issue Jul 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.