How I Fixed LibGDX Sounds Causing Game Lag on Android

• 2 min read

tl;dr add silence to your sound files if they’re too short.

The release of my first ever mobile game Platform Pixels is coming up, so I’ve been testing it on as many devices as I can. I was confident after seeing it run on an old HTC One X (2012) but was saddened when I later saw it stutter on a more powerful Nexus 7 (2013). Then I noticed something. The stutter disappeared completely when I disabled the sound.

The framework that the game uses is libGDX so naturally I began searching for things like android libGDX audio lag to try to find a solution. Unfortunatly, there didn’t seem to be many people experiencing the same problem. This led me to believe that it was my fault, so I went through a few libGDX sound tutorials to be certain that I was doing everything correctly. I was.

Then, after about an hour more of debugging and searching, I came across this very understated Stack Overflow answer

Stack Overflow answer to audio lag

That’s it? Make the sounds longer? How could that possibly be a solution to the problem? It seemed like a troll answer since it only had one up vote and no comments, but I had tried everything else already and had no more ideas. So, I gave it a shot and it worked! I added a second of silence to the end of every sound and the stutter went away. I could finally relax in peace.

Thanks for reading, and I hope this saved you a lot of time if you had the same problem. If you have any thoughts or reasoning on the issue I would love to hear from you. If not, I guess I’ll just have to suffer eternally for not knowing. Thanks a lot Google.

Be the first to cheers
Now look what you've done 🌋
Stop clicking and run for your life! 😱
Uh oh, I don't think the system can't handle it! 🔥
Stop it, you're too kind 😄
Thanks for the love! ❤️
Thanks, glad you enjoyed it! Care to share?
Hacker News Reddit

More Posts ✍🏻

See All »
• 2 min read • 697 votes
🗓 2019 Year in Review: Prioritizing Health
Read Post »
• 4 min read • 4169 votes
😈 Productive Procrastination
Read Post »
• 6 min read • 388 votes
👔 Quit With Positivity
Read Post »
• 6 min read • 366 votes
🎈 Abandoning the Static Site
Read Post »
• 5 min read • 532 votes
🚀 Getting Over the Fear of Launching
Read Post »
• 3 min read • 402 votes
📈 Indie to Acquisition
Read Post »
• 3 min read • 278 votes
🌁 Unlimited Potential
Read Post »

Be the first to hear about posts, right in your inbox 💌