# Crackling of sound - HTML5 bundle (DEF-2515) (SOLVED)

**URL:** <https://forum.defold.com/t/crackling-of-sound-html5-bundle-def-2515-solved/5432>\
**Category:** Bugs\
**Created:** [February 20, 2017, 1:11pm UTC](https://forum.defold.com/t/crackling-of-sound-html5-bundle-def-2515-solved/5432 "2017-02-20T13:11:08Z")\
**Posts on this page:** 19\
**Page:** 1

<div class="post-metadata">

**Author:** ![AGulev](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/agulev/32/4541_2.png) [@AGulev](https://forum.defold.com/u/AGulev)\
**Post date:** [February 20, 2017, 1:11pm UTC](https://forum.defold.com/t/crackling-of-sound-html5-bundle-def-2515-solved/5432/1 "2017-02-20T13:11:08Z")

</div>

Some of people who played our demo report about crackling in our music.

It isn’t reproduce on my mac, but it 100% on android chrome (I know that it official unsupported) and on some PC with windows 10 and 8.1 (any browsers).

Data of music track (ogg):

 ![](https://forum-defold-uploads.b-cdn.net/original/2X/a/a61de2c2d5594919ec70679141fd25d143528e23.png)

Demo: [bring-me-cakes.com&nbsp;-&nbsp;Diese Website steht zum Verkauf!&nbsp;-&nbsp;Informationen zum Thema bring me cakes.](http://bring-me-cakes.com/demo/)

---

<div class="post-metadata">

**Author:** ![britzl](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/britzl/32/23_2.png) [@britzl](https://forum.defold.com/u/britzl)\
**Post date:** [February 20, 2017, 1:37pm UTC](https://forum.defold.com/t/crackling-of-sound-html5-bundle-def-2515-solved/5432/2 "2017-02-20T13:37:16Z")

</div>

I can confirm that there’s some crackling on Android Chrome, but it’s as you say an unsupported platform. The game plays remarkably well on a phone btw!

---

<div class="post-metadata">

**Author:** ![AGulev](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/agulev/32/4541_2.png) [@AGulev](https://forum.defold.com/u/AGulev)\
**Post date:** [February 20, 2017, 1:40pm UTC](https://forum.defold.com/t/crackling-of-sound-html5-bundle-def-2515-solved/5432/3 "2017-02-20T13:40:36Z")

</div>

> [@britzl](#):
>
> I can confirm that there’s some crackling on Android Chrome, but it’s as you say an unsupported platform. The game plays remarkably well on a phone btw!

Yes, I know. But the same crackling on windows pc - thats the issue.  
I told about android only like a fast way to reproduce if you have no windows pc near.

---

<div class="post-metadata">

**Author:** ![britzl](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/britzl/32/23_2.png) [@britzl](https://forum.defold.com/u/britzl)\
**Post date:** [February 20, 2017, 3:31pm UTC](https://forum.defold.com/t/crackling-of-sound-html5-bundle-def-2515-solved/5432/4 "2017-02-20T15:31:48Z")

</div>

> [@AGulev](#):
>
> But the same crackling on windows pc - thats the issue.

Yup, I didn’t mean to sound as if there was no issue 🙂 Would you mind sharing the ogg so that we can try to reproduce and investigate?

---

<div class="post-metadata">

**Author:** ![AGulev](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/agulev/32/4541_2.png) [@AGulev](https://forum.defold.com/u/AGulev)\
**Post date:** [February 20, 2017, 3:43pm UTC](https://forum.defold.com/t/crackling-of-sound-html5-bundle-def-2515-solved/5432/5 "2017-02-20T15:43:00Z")

</div>

yes, of course.  
I will send you PM

UPD:  
@britzl  
Clean project has same issue  
[http://agulev.com/html5/test/](http://agulev.com/html5/test/)

---

<div class="post-metadata">

**Author:** ![britzl](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/britzl/32/23_2.png) [@britzl](https://forum.defold.com/u/britzl)\
**Post date:** [February 21, 2017, 7:21am UTC](https://forum.defold.com/t/crackling-of-sound-html5-bundle-def-2515-solved/5432/6 "2017-02-21T07:21:20Z")

</div>

Created a ticket: DEF-2515

---

<div class="post-metadata">

**Author:** ![cocopia](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/cocopia/32/3549_2.png) [@cocopia](https://forum.defold.com/u/cocopia)\
**Post date:** [February 21, 2017, 4:59pm UTC](https://forum.defold.com/t/crackling-of-sound-html5-bundle-def-2515-solved/5432/7 "2017-02-21T16:59:01Z")

</div>

Any Wav file on windows produces this for me, ogg is fine.

---

<div class="post-metadata">

**Author:** ![ross.grams](https://forum-defold.b-cdn.net/letter_avatar_proxy/v4/letter/r/cab0a1/32.png) [@ross.grams](https://forum.defold.com/u/ross.grams)\
**Post date:** [March 21, 2017, 11:20pm UTC](https://forum.defold.com/t/crackling-of-sound-html5-bundle-def-2515-solved/5432/8 "2017-03-21T23:20:13Z")

</div>

I get this on Android (and html5). I originally thought it had something to do with the browser turning on and off its sound, because it didn’t happen when there was continuous sound playing. I forgot about it because I solved the issue by looping a silent audio clip forever.

---

<div class="post-metadata">

**Author:** ![d954mas](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/d954mas/32/5401_2.png) [@d954mas](https://forum.defold.com/u/d954mas)\
**Post date:** [August 14, 2018, 7:54am UTC](https://forum.defold.com/t/crackling-of-sound-html5-bundle-def-2515-solved/5432/9 "2018-08-14T07:54:50Z")

</div>

[Three Men in a spaceship (To Say Nothing of the AI) by d954mas](https://d954mas.itch.io/ld42-spaceship) same problem

---

<div class="post-metadata">

**Author:** ![notbadgun](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/notbadgun/32/14901_2.png) [@notbadgun](https://forum.defold.com/u/notbadgun)\
**Post date:** [August 14, 2018, 8:07am UTC](https://forum.defold.com/t/crackling-of-sound-html5-bundle-def-2515-solved/5432/10 "2018-08-14T08:07:02Z")

</div>

[Junkyard by NOTBADGUN](https://notbadgun.itch.io/junkyard) same problem! crackling in music!

---

<div class="post-metadata">

**Author:** ![britzl](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/britzl/32/23_2.png) [@britzl](https://forum.defold.com/u/britzl)\
**Post date:** [August 14, 2018, 9:46am UTC](https://forum.defold.com/t/crackling-of-sound-html5-bundle-def-2515-solved/5432/11 "2018-08-14T09:46:46Z")

</div>

@inactive-vilse, ideas?

---

<div class="post-metadata">

**Author:** ![inactive-vilse](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/inactive-vilse/32/8117_2.png) [@inactive-vilse](https://forum.defold.com/u/inactive-vilse)\
**Post date:** [August 14, 2018, 11:43am UTC](https://forum.defold.com/t/crackling-of-sound-html5-bundle-def-2515-solved/5432/12 "2018-08-14T11:43:00Z")

</div>

Will need to investigate, but if the music is playing continuously and crackling it is possible that the sound thread does not fill in the sound buffers fast enough.

We do release audio focus when there is silence, but if there is constant music playing it should not come into effect.

---

<div class="post-metadata">

**Author:** ![aglitchman](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/aglitchman/32/19432_2.png) [@aglitchman](https://forum.defold.com/u/aglitchman)\
**Post date:** [August 14, 2018, 2:16pm UTC](https://forum.defold.com/t/crackling-of-sound-html5-bundle-def-2515-solved/5432/13 "2018-08-14T14:16:42Z")

</div>

Defold should encode sounds to .WAV/.MP3/.OGG/(.M4A?) and use high-level HTML5 APIs for audio playback.

Otherwise we’ll always hear cracklings.

---

<div class="post-metadata">

**Author:** ![Mathias\_Westerdahl](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/mathias_westerdahl/32/228_2.png) [@Mathias\_Westerdahl](https://forum.defold.com/u/Mathias_Westerdahl)\
**Post date:** [August 14, 2018, 3:08pm UTC](https://forum.defold.com/t/crackling-of-sound-html5-bundle-def-2515-solved/5432/14 "2018-08-14T15:08:36Z")

</div>

> Defold should encode sounds to .WAV/.MP3/.OGG/(.M4A?)

We already do decode from WAV and OGG.I’m guessing it’s not really a performance issue (e.g starving), but an actual bug somewhere.

---

<div class="post-metadata">

**Author:** ![aglitchman](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/aglitchman/32/19432_2.png) [@aglitchman](https://forum.defold.com/u/aglitchman)\
**Post date:** [August 15, 2018, 10:09am UTC](https://forum.defold.com/t/crackling-of-sound-html5-bundle-def-2515-solved/5432/15 "2018-08-15T10:09:22Z")

</div>

Looks like Defold was directly ported to HTML5 by the use of Emscripten.

Does Defold use OpenAL for audio playback? Emscripten [emulates OpenAL](https://github.com/kripken/emscripten/blob/1.38.11/src/library_openal.js) behavior by filling WebAudio AudioContext’s buffer every frame.  
=\> We’ll always hear cracklings because of inconsistent HTML5 frame time.

A clear example of the problem (Emscripten + OpenAL + OGG music):  
[http://www.raylib.com/examples/web/audio/loader.html?name=audio\_music\_stream](http://www.raylib.com/examples/web/audio/loader.html?name=audio_music_stream)

---

<div class="post-metadata">

**Author:** ![inactive-vilse](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/inactive-vilse/32/8117_2.png) [@inactive-vilse](https://forum.defold.com/u/inactive-vilse)\
**Post date:** [August 16, 2018, 9:48am UTC](https://forum.defold.com/t/crackling-of-sound-html5-bundle-def-2515-solved/5432/16 "2018-08-16T09:48:33Z")

</div>

@ross.grams, just to be clear here, do you get it when you bundle for Android or when you use a browser on Android?

Wan’t to make clear if this problem only manifests in browsers or on other platforms as well.

It might be that there are two things at play here, when you loop the silent audio clip I assume the gain for that sample and the group channel are not zero right? It is the sample data that is silent?

---

<div class="post-metadata">

**Author:** ![ross.grams](https://forum-defold.b-cdn.net/letter_avatar_proxy/v4/letter/r/cab0a1/32.png) [@ross.grams](https://forum.defold.com/u/ross.grams)\
**Post date:** [August 16, 2018, 10:46pm UTC](https://forum.defold.com/t/crackling-of-sound-html5-bundle-def-2515-solved/5432/17 "2018-08-16T22:46:35Z")

</div>

- It was when I bundled for Android.
- Yes, the sample data was silent, the gain was left at default.

That was a long time ago, and the Android device I used was also fairly old, so I wouldn’t worry unduly about that report if you can’t reproduce it.

---

<div class="post-metadata">

**Author:** ![inactive-vilse](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/inactive-vilse/32/8117_2.png) [@inactive-vilse](https://forum.defold.com/u/inactive-vilse)\
**Post date:** [August 23, 2018, 8:47am UTC](https://forum.defold.com/t/crackling-of-sound-html5-bundle-def-2515-solved/5432/18 "2018-08-23T08:47:10Z")

</div>

The crackling sound issue in HTML5 should be fixed in the next release, thanks for all the input.

---

<div class="post-metadata">

**Author:** ![britzl](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/britzl/32/23_2.png) [@britzl](https://forum.defold.com/u/britzl)\
**Post date:** [August 28, 2018, 4:21am UTC](https://forum.defold.com/t/crackling-of-sound-html5-bundle-def-2515-solved/5432/19 "2018-08-28T04:21:51Z")

</div>

Fixed in 1.2.135
