• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
3
Question by x4000 · Oct 12, 2010 at 04:49 PM · soundlagmusicgc

How to stop sound from skipping during GC collection?

I've seen this question, of course. Granted, you want the GC to run as infrequently as possible. But, I have a very large game, and in mine it often runs about every 8 seconds.

This is most troubling for the music, though it's annoying in general. It essentially causes the music to skip every 8 seconds or so. I've tried setting the priority of the audiosource to 0, but that doesn't seem to affect the priority of the music itself. I should mention that I'm streaming this off the disk from a WWW class.

In the past, using DirectSound through SlimDX, the music ran in a separate thread that I could set the priority on. No matter what happened with playback in my game, GC collections or otherwise, the music would keep going. Is there some way to make this happen in Unity?

Why The GC Runs That Often

To go ahead and answer the inevitable question: no, I'm not crazy, and yes, this should work -- AI War has been out since May 2009 on a different platform, and I'm just now porting it to Unity.

I'm keeping track of 10,000 to 175,000 player units, and hundreds of thousands of small objects (floating junk, weapon shots, etc), and beyond that am processing a very large amount of targeting data. Not to mention several thousand commands per second, often. And a really intensive AI thread, with data being passed back and forth from the main thread to it.

All this is to say, the GC runs a lot, and to stave off the suggestions of "make it run less frequently," I can say that I'm amazed it runs as infrequently as it does (overall -- granted, it seems to like to keep a smaller memory footprint at the start than I'd prefer, collecting every time the cap hits 400ish MB when there are hundreds more available).

With a better GC -- like the one I used to have in .NET or, apparently, the experimental one in Mono 2.8 -- this wouldn't even be an issue. But the GC in Mono 2.6 is substantially more limited and lower-performance, so my main goal right now is to avoid the music skipping at the very least.

Comment
Add comment · Show 3
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image dingben · Oct 08, 2011 at 02:20 PM 0
Share

I don't have an answer, just sharing my small experience... I have stated that elsewhere but can't put my finger on it now. If I do rapid changes in the editor including going back and forth rapidly from PLAY to Edit I get that 8 second sound glitch. The only way I have gotten around it is to make a small change in any script(like opening a space and closing it) to cause recompilation, and I do that slowly giving ample time for the save before I hit PLAY, hick-up is gone. (web build) WIN 7 Pro indie(all versions)

avatar image dingben · Oct 08, 2011 at 02:23 PM 0
Share

I have upgraded to $$anonymous$$onoDevelop and still experience the same glitch

avatar image Myrddraal · Jan 22, 2014 at 03:55 PM 0
Share

Hi x4000, did you ever find an answer to this problem. I'm experiencing the same thing when running intensive AI calculations in a separate thread. Although the AI runs in its own thread, the knock-on effect on the GC causes lots of music hickups.

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by Draco18s · Jul 27, 2011 at 09:32 PM

F*ck. I'm not the only one seeing this issue (hi X!) and I can't find a solution.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by themipper · Nov 16, 2012 at 10:29 AM

Has anybody found a solution to the sound stuttering?

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Polymo · Nov 16, 2012 at 10:57 AM 0
Share

just a suggestion, maybe a coroutine playing the music will help.

avatar image themipper · Nov 19, 2012 at 12:17 PM 0
Share

The thing is that the music is on a loop and has to be started only once. So moving the start command into a coroutine sadly doesn't change anything :-(

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Setting menu music 1 Answer

Quick Questions about sounds for my game. 1 Answer

Android sound lags on Arm v6 Devices Solution? 0 Answers

Why can't I hear my audio? 5 Answers

Music lags on client when connected to server 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges