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.

AppGameKit Classic Chat / [Bug] PlaySound causes game to freeze for an instant

Author
Message
easter bunny
8
Years of Service
User Offline
Joined: 20th Nov 2012
Playing: Dota 2
Posted: 5th Jul 2017 05:21
I just got a new phone (Moto G5 Plus) and there's a really weird (and critical) bug with AGK. PlaySound inconsistently causes the game to freeze.

I have the following code:


Most of the time it prints out less than 0.02 for the time used to call PlaySound, but occasionally it takes about 0.18 which is very noticeable and makes the game basically unplayable. I can't figure out why it does it some frames but not others, but it happens for different SFX files, not just this one. While it's obviously freezing on that particular command, the bug does not occur on a fresh project that only plays sounds, indicating that the freeze is due to some other feature I'm using.
At this stage, I'm simply gonna detect if the freeze is occurring and disable sound effects when it is

My Games - Latest WIP - My Website: Immortal.Digital - FB - Twitter
130,000 installs with AppGameKit and counting
MikeMax
AGK Academic Backer
9
Years of Service
User Offline
Joined: 13th Dec 2011
Location: Paris
Posted: 5th Jul 2017 07:21
is it doing the same issue with any other sound or other sound format ? can you attach your sound file ?
--------------------------------
Join us on dedicated AppGameKit WeeKChat :
https://week.chat/room/AppGameKit
easter bunny
8
Years of Service
User Offline
Joined: 20th Nov 2012
Playing: Dota 2
Posted: 5th Jul 2017 08:18 Edited at: 5th Jul 2017 08:45
It does it on any of the sound effects, but it's only doing it for this particular project* which is what I find really strange. The bug doesn't occur on my old phone. It lags for both Ogg and Wav files.

* either it's only doing it on this project, or the impact isn't as large on a blank project

Wav File

Edit: also, if I repeat the PlaySound command several times in a row, it won't freeze on all of them, indicating that it doesn't have anything to do with that particular frame

My Games - Latest WIP - My Website: Immortal.Digital - FB - Twitter
130,000 installs with AppGameKit and counting

Attachments

Login to view attachments
Conjured Entertainment
AGK Developer
15
Years of Service
User Offline
Joined: 12th Sep 2005
Location: Nirvana
Posted: 5th Jul 2017 14:52
t#=timer()
print(timer()-t#)

Try moving that to the end, and have the sound stuff first thing after the condition is met.
Maybe sandwiching the timer() stuff in there is causing a slight delay.
Not sure if it will make a difference for you, but it would be easy to try.

Coding things my way since 1981 -- Currently using AppGameKit V2 Tier 1
easter bunny
8
Years of Service
User Offline
Joined: 20th Nov 2012
Playing: Dota 2
Posted: 6th Jul 2017 06:04
Quote: "Maybe sandwiching the timer() stuff in there is causing a slight delay."

Those commands are just there to test how long the PlaySound command takes to execute. I noticed the bug long before I added those lines, and spent about an hour trying to track down exactly what was causing the random freezes in my game. It occurs on any call of PlaySound in game, not just this particular one.

My Games - Latest WIP - My Website: Immortal.Digital - FB - Twitter
130,000 installs with AppGameKit and counting

Login to post a reply

Server time is: 2021-02-28 22:26:30
Your offset time is: 2021-02-28 22:26:30