playMaker

Author Topic: My Game Lags... Especially Audio... [SOLVED] [UPDATED]  (Read 3938 times)

HeathClose

  • Full Member
  • ***
  • Posts: 226
My Game Lags... Especially Audio... [SOLVED] [UPDATED]
« on: January 25, 2017, 11:05:34 AM »
So I'm not sure I'm in the right section of the forums... but because this might not be directly a playmaker question, general seemed more appropriate...

My game lags in the editor, but on my iphone, it was playing fine... until I added sounds...

My first concern is that my 2d game lags in the editor... it isn't complex by any means, it is a bit of a pineapple pen type game, shooting something at a moving object tweening back and forth on the screen, hitting off objects in layers... just like armored pineapple in pineapple pen, but I honestly don't know if I have thrown best practices out the window because I'm not sure what best practices for optimising playmaker usage is...

I'm going to search around for a good profiler vid to watch... I think this 50 min one from unity might be a good one...

in the meantime, I was wondering if anyone might have any advice on keeping games lean...

what are some common newbie mistakes I might have made?

I wish I knew what questions to ask.. but after I watch this profiler vid... I might be better equipped to ask a more specific optimization question.
« Last Edit: January 26, 2017, 08:17:04 PM by HeathClose »

HeathClose

  • Full Member
  • ***
  • Posts: 226
Re: My Game Lags... Especially Audio...
« Reply #1 on: January 25, 2017, 11:23:43 AM »
here's a shot of my profiler, I can see it's way high on some things compared to this game he's showing in the video.. which is a beautiful 3d game.. and my little made for mobile game is way more intensive... still learning to read this thing.. but this might start a conversation with someone who knows what they are looking at.


HeathClose

  • Full Member
  • ***
  • Posts: 226
Re: My Game Lags... Especially Audio...
« Reply #2 on: January 25, 2017, 01:24:08 PM »
so i ran sprite packer and it didn't seem to have any affect but here is another screenshot with the some really high numbers

« Last Edit: January 25, 2017, 01:41:48 PM by HeathClose »

HeathClose

  • Full Member
  • ***
  • Posts: 226
Re: My Game Lags... Especially Audio...
« Reply #3 on: January 25, 2017, 05:19:05 PM »
I also ran it through Xcode Instruments if anyone knows how to look at that...

https://www.dropbox.com/sh/53quev3tm4dbfdn/AADW9HKd6CWdGfmccZlEtaAna?dl=0

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: My Game Lags... Especially Audio...
« Reply #4 on: January 26, 2017, 02:04:54 AM »
Hi,

 I recall a previous project where we had this.

 What's happening is that likely you need to compress your audio differently and also avoid decompression at runtime. what happens is that when you play a sound it lags because it's doing too much work to uncompress and play the audio.

so it seems to be lagging because of colliders triggers or PlayMaker, but it's simply because it's the starting point of you willing to play a sound, and that sounds makes it lag to playback.

I would ask Unity forum for the best way to compress and playback audio and avoid lags. Technology is evolving fast so their might be new tricks to be aware of.


 Bye,

 Jean

HeathClose

  • Full Member
  • ***
  • Posts: 226
Re: My Game Lags... Especially Audio...
« Reply #5 on: January 26, 2017, 12:16:53 PM »
Hi,

 I recall a previous project where we had this.

 What's happening is that likely you need to compress your audio differently and also avoid decompression at runtime. what happens is that when you play a sound it lags because it's doing too much work to uncompress and play the audio.

so it seems to be lagging because of colliders triggers or PlayMaker, but it's simply because it's the starting point of you willing to play a sound, and that sounds makes it lag to playback.

I would ask Unity forum for the best way to compress and playback audio and avoid lags. Technology is evolving fast so their might be new tricks to be aware of.


 Bye,

 Jean

so i replaced all the audio in the game with .wav files per unity's suggestion... they say on mobile use wav for fastest performance... and it didn't make a difference with the audio lag... it DID however make a difference with graphical lag, but the audio still plays at a delay...

Here you can see some stats of the time audio plays


I also attached the peaks in the game.. this is profiler data in a new clean project  that is coming from the iphone as it's being played so editor overhead is minimal...

I think the data look TONS TONS better, which might be because the profiler is remote data from the iphone and not from the editor... but the audio is still delayed when it's called from the audio play action from audio source components on the objects the actions are on


 

HeathClose

  • Full Member
  • ***
  • Posts: 226
Re: My Game Lags... Especially Audio...
« Reply #6 on: January 26, 2017, 12:50:15 PM »
 I think I may have found a solution I'll report back as soon as I try but it might have to do with the DSP buffer size not being set to best latency

HeathClose

  • Full Member
  • ***
  • Posts: 226
Re: My Game Lags... Especially Audio... [SOLVED]
« Reply #7 on: January 26, 2017, 03:06:42 PM »
So solving this lag was twofold...

1. using .wav files
 - this solved the graphical lag

2. edit ->  project settings ->  audio ->  DSP buffer size ->  best latency
 - this solved the audio lag

HeathClose

  • Full Member
  • ***
  • Posts: 226
Re: My Game Lags... Especially Audio... [SOLVED] [UPDATED]
« Reply #8 on: January 26, 2017, 08:19:00 PM »
So those massive issues in the editor itself was from playmaker forwarding logs to unity logs... after turning that off... look at the difference in the numbers! so happy!