Author Topic: Music Issue since Unity switch  (Read 2558 times)

Offline styx

  • Newbie
  • *
  • Posts: 2
Music Issue since Unity switch
« on: December 05, 2010, 05:24:04 pm »
Ever since the switch to Unity I've been getting skipping / stuttering (similar to what was mentioned here: http://www.arcengames.com/forums/index.php/topic,7424.0.html ) in the music. All other sounds are fine, but the music skips for about a second every now and then.
And as far as I can tell the skipping isn't connected with a specific action of my own, or any of my constructions / ships, nor is it at any regular interval (sometimes a gap of about 10 seconds, other times it can be about a minute in-between), but it does prevent me from fully enjoying the music (which apart from this one issue I love).

Any ideas on what I could do to fix this?

Offline keith.lamothe

  • Arcen Games Staff
  • Arcen Staff
  • Zenith Council Member Mark III
  • *****
  • Posts: 19,505
Re: Music Issue since Unity switch
« Reply #1 on: December 05, 2010, 05:29:46 pm »
The skip is from the garbage collector running, over which we have strikingly little control, and we can't run the music in a separate thread like we could before.

There are probably better solutions, but if it's often enough to bother you I'd suggest just making a playlist of the tracks you like (they're plain ol ogg files in RuntimeData/Music/ and RuntimeData/Expansions/1/Music, and expansions/2, etc) and playing them in winamp or whatever you like to use for standalone music playback.
Have ideas or bug reports for one of our games? Mantis for Suggestions and Bug Reports. Thanks for helping to make our games better!

Offline styx

  • Newbie
  • *
  • Posts: 2
Re: Music Issue since Unity switch
« Reply #2 on: December 05, 2010, 06:23:04 pm »
Okay, I'll do that.
Thanks for the quick response and keep up the great work with this awesome game!  :)

Offline TechSY730

  • Core Member Mark V
  • *****
  • Posts: 4,570
Re: Music Issue since Unity switch
« Reply #3 on: December 11, 2010, 09:49:00 am »
Are Unity's threading capabilities that limited? Are you able to even able to set priorities for each thread?

Offline keith.lamothe

  • Arcen Games Staff
  • Arcen Staff
  • Zenith Council Member Mark III
  • *****
  • Posts: 19,505
Re: Music Issue since Unity switch
« Reply #4 on: December 11, 2010, 09:53:15 am »
All sound handling happens in the main thread.
Have ideas or bug reports for one of our games? Mantis for Suggestions and Bug Reports. Thanks for helping to make our games better!

Offline TechSY730

  • Core Member Mark V
  • *****
  • Posts: 4,570
Re: Music Issue since Unity switch
« Reply #5 on: December 11, 2010, 09:54:20 am »
That's an unfortunate API limitation.  :(

Offline x4000

  • Chris McElligott Park, Arcen Founder and Lead Dev
  • Arcen Staff
  • Zenith Council Member Mark III
  • *****
  • Posts: 31,651
Re: Music Issue since Unity switch
« Reply #6 on: December 13, 2010, 08:31:28 pm »
That's actually not true -- music handling is on its own thread.  However, due to the nature of the mono garbage collector, apparently it takes precedence and interrupts even the background threads while it runs.  The API is good, aside from not letting us set the priority of those background music threads, but the GC is... unfriendly.
Have ideas or bug reports for one of our games?  Mantis for Suggestions and Bug Reports. Thanks for helping to make our games better!

Offline Echo35

  • Master Member Mark II
  • *****
  • Posts: 1,703
  • More turrets! MORE TURRETS!
Re: Music Issue since Unity switch
« Reply #7 on: December 13, 2010, 08:38:51 pm »
I have noticed not the music skipping so much, but a lot of static and crackling when there's a lot of sounds going on at once.

Offline keith.lamothe

  • Arcen Games Staff
  • Arcen Staff
  • Zenith Council Member Mark III
  • *****
  • Posts: 19,505
Re: Music Issue since Unity switch
« Reply #8 on: December 13, 2010, 08:40:52 pm »
That's actually not true -- music handling is on its own thread.
Oh, I hadn't realized.  Well, glad to know that a long sim frame won't nail the music :)
Have ideas or bug reports for one of our games? Mantis for Suggestions and Bug Reports. Thanks for helping to make our games better!

Offline TechSY730

  • Core Member Mark V
  • *****
  • Posts: 4,570
Re: Music Issue since Unity switch
« Reply #9 on: December 14, 2010, 12:35:48 am »
Doesn't the latest version of mono have a good garbage collector? You know, one that only preempts threads that have stuff to be collected? I doubt the music thread is going to be creating many short lived objects after all.

Offline x4000

  • Chris McElligott Park, Arcen Founder and Lead Dev
  • Arcen Staff
  • Zenith Council Member Mark III
  • *****
  • Posts: 31,651
Re: Music Issue since Unity switch
« Reply #10 on: December 14, 2010, 10:53:58 am »
Yeah, mono 2.7 has an experimental garbage collector that is supposedly wicked good. But, it has to be enabled by a compiler flag specifically, as it's still considered experimental (as is mono 2.7 in general).  The latest stable version of mono is 2.6, to my knowledge.

More to the point, we don't interact directly with mono in any fashion -- it's compiled into the Unity 3D engine.  So even if mono 2.7 was out and fully stable, we'd be at the mercy of the unity folks as to when they decide to upgrade that inside the unity engine itself; and then we're at their mercy as far as which GC they choose to use, etc.

Naturally, of course, they have the same goals as all of us do as far as performance and efficiency, though, so I'd imagine they'd go with the most efficient possible thing, so long as it is rock-solid.  But for the time being, we're already on the latest version of Unity, and there's not much we can do beyond that when it comes to things of this nature.
Have ideas or bug reports for one of our games?  Mantis for Suggestions and Bug Reports. Thanks for helping to make our games better!

Offline keith.lamothe

  • Arcen Games Staff
  • Arcen Staff
  • Zenith Council Member Mark III
  • *****
  • Posts: 19,505
Re: Music Issue since Unity switch
« Reply #11 on: December 14, 2010, 10:57:59 am »
Yea, I'm reasonably sure that the next time Unity does a major update they'll pick the most up-to-date stable version of mono, which presumably by that time will include a non-experimental version of the new GC that is waaaay better than the one in 2.6 and earlier.  For the meantime we just have to sidestep the existing GC as much as we can :)
Have ideas or bug reports for one of our games? Mantis for Suggestions and Bug Reports. Thanks for helping to make our games better!