Help with sound buffering

Hi! Congratulations -and thank you- for your awesome software. Excuse my english.

I’m finishing an Android game, but since GDevelop version 3.6.81 the music don’t work in the Crosswalk build (the audio is fine if I use 3.6.80 for exporting to Crosswalk). Well, in >3.6.81 the music plays, but takes a lot ot time before it starts (with a relatively small 2MB ogg file the game is running without sound and with huge performance drops for about a minute). Even with a small music file (600KBs), the music takes several seconds before start.

I investigated a lot about it, and according the Howler documentation I suspect I must enable the buffer property:

I tried to enable the property through soundmanager.js but I’m unable to achieve it due to my lack of knowledge.

Am I correct in my assumptions? I would appreciate some help. Thanks in advance.

I can try to change the property in the JS file and send you this file so as you can try ? But the file is not on the Internet when the game is played on Android. So, I don’t think this would solve the issue.

I’m thinking about the buffer property because the performance is very poor until the music starts to play, so I’m afraid the phone is decoding the ogg file.

I’m open to other theories, I’m not an expert at all.

Thanks for your time.

In the meantime, I just managed to create a little fix that seems to work in the Crosswalk build:

As you can see, it’s a very simple first scene acting as preloader/decoder for the ogg file.
Apparently, once the ogg file is decoded, it stays in memory between scenes and starts playing immediately when requested in-game. This preloader scene only takes a few seconds, but I’m planning to add some “Loading…” text if I can’t find a better fix before I release the game in a few days.

Nice idea. :smiley:
I think it’s the only solution for now.

I’d like to ask a couple of additional questions regarding Intel XDK/Crosswalk.

Is there any way to pause/stop the music when the game loses the focus? I mean, the music still plays when I minimize the app or press the Home button on the mobile, or even when I suspend it completely (with the screen off and locked). The Crosswalk device listener doesn’t seem to work at all for this purpouse.

My other “big problem”: When I open an URL from the game (ie: for sharing scores), there’s no way to go back to the game. Showing the link as a popup, like in the native HTML5 build, would be ideal, but Crosswalk uses the game window and restarts everytime from the beginning if I press the back button (not very convenient, especially if we take into account the mentioned pre-caching hack).

Thanks again for your time.

Just published my game (announced here).

The game focus and extenal URL problems are still there, but I wanted to mention that I solved all the audio caching problems replacing the latest soundmanager.js and soundtools.js in the export build with the ones included in v3.6.80 and removing the Howler call in the index.html file.

I know maybe it’s not the optimal solution (I replaced the new sound system with the old), but that way the game takes around 30 secs less to start (no precaching needed) and the general performance seems the same. I kept the precaching scene in the published version just in case.

Do you export with “Android + crosswalk” in the Intel XDK ?

Yes.

Can you try this soundmanager.js (don’t forget to reuse the new soundtools.js with it) :
soundmanager.js (4.85 KB)

Just checked it and unfortunately it keeps taking ~30 seconds to start playing the music. To be clear with my steps: I exported with the latest GDevelop version and replaced soundmanager.js with yours, keeping the Howler line in the index and also keeping the soundtools.js from the latest version.

As a side note, today I installed Node.js and noticed the Export to iOS or Android option in GDevelop now always minify the code (with no way to disable it), so I had to uninstall Node.js in order to replace soundmanager.js

I think it may be useful to being able to uncheck the minify option when exporting to Android, just like when you export to a website.

Thanks again for your time.