Quick answer: Web exports use the browser's Web Audio API instead of native audio drivers. The default buffer size is often too small for web playback, causing underruns that manifest as crackling. The browser may also resample audio if sample rates differ from project settings.

Here is how to fix Godot audio crackling web export. Your game sounds perfect in the Godot editor. You export to HTML5 and the audio is a mess — crackling, popping, distortion, or complete silence on first load. This stems from fundamental differences between native audio drivers and the browser’s Web Audio API, which handles buffering, sample rates, and autoplay restrictions very differently.

The Symptom

Audio in your web-exported Godot 4 game crackles, cuts in and out, or is completely silent until the user clicks something. The issue varies across browsers — Chrome might crackle while Firefox plays fine. In the developer console you may see AudioContext was not allowed to start. Desktop exports and the editor sound perfect.

What Causes This

1. Audio buffer size too small. Godot’s default output latency is 15ms, which works natively but causes buffer underruns in browsers. The Web Audio API adds processing overhead, and a 15ms buffer is not enough time for the browser to consistently fill the audio pipeline.

2. Sample rate mismatch. Your project mix rate may differ from the browser’s Web Audio context rate. When they differ, the browser resamples audio in real time, which is expensive and introduces artifacts on lower-end hardware.

3. Browser autoplay policy. Every modern browser blocks audio until user interaction. If your game plays background music on a title screen that auto-loads, the Web Audio context stays suspended and produces silence or garbled output when it resumes.

The Fix

Increase the audio buffer for web builds and handle the autoplay restriction with a user interaction gate:

# Autoload script to configure web audio
extends Node

func _ready():
  if OS.has_feature("web"):
    AudioServer.set("driver/output_latency", 50)
    print("Web audio latency set to 50ms")
  var mix_rate = AudioServer.get_mix_rate()
  print("Active mix rate: ", mix_rate, " Hz")

For the autoplay policy, mute the master bus until the player interacts with the page, then unmute on the first click:

# Click-to-start screen for web builds
extends Control

@onready var start_button = $StartButton

func _ready():
  start_button.pressed.connect(_on_start)
  AudioServer.set_bus_mute(0, true)

func _on_start():
  AudioServer.set_bus_mute(0, false)
  get_tree().change_scene_to_file("res://scenes/main_menu.tscn")

In Project Settings, set Audio > Driver > Mix Rate to 44100 or 48000 to match common browser defaults and avoid resampling artifacts.

Related Issues

If your web export shows a blank screen instead of audio issues, see HTML5 web export white/black screen. If audio crackles specifically when looping tracks on all platforms, check audio popping between loops for loop-point configuration fixes.

Always test web audio on both Chrome and Firefox. They handle Web Audio buffer scheduling differently.