Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Android / PlaySound causes stuttering/lag on Android

Author
Message
CommanderJersey
4
Years of Service
User Offline
Joined: 3rd May 2018
Location:
Posted: 25th Jul 2022 05:02
Hello all, I was wondering if anyone else has had this issue or knows of a solution/workaround. In short, I am experiencing the same issue as seen in these threads:

https://forum.thegamecreators.com/thread/226308
https://forum.thegamecreators.com/thread/219938

When I try to play any sound, the game usually lags/stops for a split second. This happens around 80% of the time, and only on Android; I've never experienced this on Windows or iOS. This issue has happened to me on both the Samsung Galaxy S22 Ultra (released in 2022) and on the Goodle Pixel 4a (released in 2020).

I have tried the following fixes, but none have solved the issue:

-Converting the sound file to stereo instead of mono (sound was already in stereo, tried it in both stereo and mono).
-Making the sound longer than .5 seconds.
-Having the sound be in .ogg instead of .wav; on my current project, the sounds are in .ogg and are still causing the issue, similar to previous projects, where the sounds were in .wav format.
-Turning on/off VSync.

Here is a video I found that shows the issue as well: https://www.youtube.com/watch?v=fpQoNaR9Szo

Is there any known solution to this problem? Thank you!
Virtual Nomad
Moderator
16
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 25th Jul 2022 13:42
hi, CommanderJersey.

a user HERE suggests using PlayMusicOGG while it may not be a viable solution if you need to "control music and sound volume independently".

SFSW
19
Years of Service
User Offline
Joined: 9th Oct 2002
Location:
Posted: 25th Jul 2022 23:25
Yeah, I've struggled with this a lot. You can use the PlayMusicOGG option for a moderate performance improvement, but then your audio samples will click/pop whenever they have to play over each other (such as when shooting a weapon repeatedly) because the sound sample is abruptly stopped to be restarted again (the music option doesn't support multiple instances of playback like PlaySound does). And you lose a variety of controls. Ironically, performance is also often worse on PC with the MusicOGG option as well.

There appears to be no effective programmer-side solution. It seems related to and primarily impacted by the performance of some devices (and yes, some older devices are able to handle audio sequences far better than more 'current' devices). It seems that an initial PlaySound request can take upwards of around 0.3 seconds on some devices, with later repeat playback taking anywhere from 0.01-0.03 or so (times and durations of stutters may vary). When AGK/S hands over a sound sample to the device's audio stack, it may be the method and/or the device itself that may be running into the problem of not sufficiently threading or otherwise handling the playback. If it can be improved, it's probably up to TGC for a solution.
Virtual Nomad
Moderator
16
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 26th Jul 2022 01:40 Edited at: 26th Jul 2022 01:41
Quote: "the problem of not sufficiently threading or otherwise handling the playback. "

that's what rick elluded to 2 years ago, then GGMax happened.

i think paul is involved with AppGameKit again in some capacity and hope this finally gets resolved soon between him, mike and whatever decisions TGC make for the next update...

Login to post a reply

Server time is: 2022-08-18 12:37:59
Your offset time is: 2022-08-18 12:37:59