Hello there, (I am updating this thread as I find out more info)
Got a very serious and bizarre audio problem on a released iOS app that has several symptoms (while only running on device):
1) Can only be described as all sounds in the "Sounds" folder (SFX) becoming downpitched and low Q/bitcrushed.
2) Device will sometimes emit a loud BZZT or POP (no such sound exists in game) and after this, audio as a whole usually doesn't work, SOMETIMES EVEN IF you close the app and restart it. To get audio to work again you need to load another app to get some sound to play and then open ours again which forces it to work. It's as if something is temporarily BREAKING on the device.
3) Audio can just not work.
EDIT: 4) Forgot to mention that if you press the home button to come out of the game (but game is still running in background), when you re-enter the game EVERY SFX that has been played so far inside that layout will play at the same time. Can be repeated.
All of these problems generally happen quite randomly (and less than 50% of the time in our tests) with a slightly higher chance happening when a new layout is loaded or a new audio track plays, or after an Admob advert has been watched. Restarting the app can sometimes even cause or fix these problems!
Only tested this on iOS so far but it does happen across different iOS devices (iPhone, iPad). The fact we had a few players tell us is pretty worrying.
Some maybe relevant technical details (since I cannot provide CAPX):
- 6 music tracks, on average 45s long for each.
- 18 SFX files.
- The most demanding layout will play all of these bar one music track.
- Even so, the problems can still occur in the menu layout which is much less performance heavy.
- EDIT: Minifying script changes nothing.
We haven't got the slightest clue what's causing it, hence why I posted in General. So far we've suspected:
- Bad audio code (done a complete overhaul, read below)
- Bad audio performance (maybe something to do with bandwith or overloading the audio thing on the device, hence bitcrushing esque noise)
- Construct bug
- We updated Construct (EDIT: tests have now shown this is unlikely a cause)
Something to do with the HTML5 limitation that requires a tap to trigger audio. Can sometimes emit the BZZT or POP on the first touch.
I will now elaborate on a few of these below to try to give you as much info as pos. Brace for wall of text:
We're leaning away from it being a problem in our code as we've since re-coded the whole audio system in the game to be more efficient, and the problem still exists. But just in case someone spots anything weird, here's the old audio system we had:
The audio system always had to be a bit dodgy in the first place. We export as Cordova out of Construct and we use Intel XDK to wrap it as an app. Now, with this workflow, I've read Crosswalk cannot fire a "Set Silent" or similar event and I do remember we had problems with this way back in early dev. So we had to find ways around that to mute music and SFX independently.
Our game is essentially an endless reaction game, and as you score higher you go through "zones" within the same game layout that each have a different audio track. Each audio track was composed to the second according to how long it would take to transition to the next zone. So when you hit a new zone, track 1 is already tailing off and track 2 begins. Due to latency issues/HTML5 only playing things when the screen has been touched, we had to set all music tracks to play on start of layout and then immediately pause all of them if they hadn't been set to muted (in that case, they were just stopped), meaning when we needed to play a certain one, we would tell which one to resume and it would play instantly as the screen had been touched way earlier in the game. This led us to think all this paused audio was sort of hogging resources. Oh and I forgot to mention, for all the SFX, when muted we would add a mute effect to every single one. Doesn't seem too efficient, adding a mute EFFECT? Which is why we did the following:
All SFX now are inside a function in its own event sheet that gets included where needed in the project. No SFX ever has a mute effect any more, the function behaves in a way that just listens for when a SFX is needed, picks the appropriate SFX, and only plays it IF muting is OFF. A lot more efficient right? I have no idea why we didn't do that in the first place.
As for the music, it now works as a sort of relay system, so that 2 tracks are only ever loaded at once instead of 5. So at the start of the layout track 1 and 2 are set to play but then 2 gets immediately paused. When 1 finishes, 2 resumes, 3 is set to play and then paused. And so on. So is it safe to say the sound in the game and the way it's coded is not the problem? We (maybe) think so! An update to the game that incorporates this new system will be pushed tomorrow (not that it fixes the problem...).
Finally, we built the majority of the game in Construct version 200 and since about a month ago we've updated and are using the latest versions. We cannot help but wonder... is it related? We don't think we had these problems before then... Did any updates since 200 address or cause any audio issues?
Anyway we haven't had the time to replicate the problem yet (nor do we even know how...).
Apologies for lack of details, but given the nature of the problem... what can I do? I do apologize for not uploading a CAPX but we obviously don't want to give people our game. You can find the game on the App Store (search for Fallen). We would greatly appreciate if anyone could try and reproduce the bug and post their thoughts. Try opening/closing the app and muting/un-muting to try and get it to trigger. You'll know it when it happens! It will be updated to version 1.0.1 probably within the week. That version will have the new audio code as described above.
Long post... but looking forward to see if anyone has any ideas!
EDIT: We've opened an old build built with version 200 and and exported with the new and old sound code and the problems STILL OCCUR.