Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • 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 wijesijp · Oct 17, 2013 at 11:22 AM · error

How to identify a freeze bug?

I am currently encountering a tough to identify bug in our game.

When I run the game in Unity it freezes over.

There are no errors on the Console before the freeze

The memory usage is around 350 Mb – 400 Mb and no high CPU usage

The freeze happens in various stages of the game. Sometime it is at the start sometimes in is in the middle or at the end.

I am finding it hard how to identify the cause of this error. Is there any method I can follow to get a clear idea what may be causing the problem?

Are there any tools I can use to figure out what is happening in the game?

Comment
Add comment · Show 12
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 meat5000 ♦ · Oct 17, 2013 at 11:40 AM 0
Share

Do you have Pro/ Profiler access?

During these freezes what does the stats page say in terms of Draw calls, Tris etc?

avatar image ShadoX · Oct 17, 2013 at 11:41 AM 0
Share

Perhaps some way of placing breakPoints in the code? The best assumption that I can come up with is some for/while cycle that doesn't stop for some reason.

avatar image CHPedersen · Oct 17, 2013 at 11:43 AM 0
Share

It's probably an infinite loop somewhere. Try to identify which gameobjects (and consequently, which scripts) are active when the freeze occurs. What script might it possibly be in the middle of executing? Is there an execution order, either explicitly set on the scripts, or implicitly because of the structure of your code? If so, put calls to Debug.Log in each step and pay attention to the console to see how many of them go through.

avatar image CHPedersen · Oct 17, 2013 at 12:02 PM 1
Share

Repeat NullRefs in Update do not constitute a freeze. The game is still technically running; Unity's runtime just prematurely aborts execution of the Update that contains the NullRef. This may trigger an avalanche of other exceptions later in control flow, but as long as the program state allows Unity's runtime to pump frames, it isn't technically frozen. The performance hit is probably due to the sudden added overhead of writing a massive amount of exceptions and attached callstacks to the logfile, and if IO can't keep up with that, the device might ter$$anonymous$$ate the process, I guess.

I maintain this is an infinite loop somewhere that causes it to get stuck in the frame it is currently rendering.

Question: When this happens in the editor, does it freeze the entire editor, too, so you have to restart Unity?

avatar image meat5000 ♦ · Oct 17, 2013 at 12:12 PM 1
Share

:P I didn't say every NullRef causes a freeze. I said repeat NullRefs CAN grind it to a halt resulting in a freeze then crash :) And it's very common.

Whereas you speak the truth in the technicality of the NullRef I'm simply stating an observation, and a frequent one at that.

If my game has frozen up and/or crashed ~80% of the time its a NullRef error and it's a NullRef that doesn't show up in Console. In fact (for Android) a lot of them I've only spotted through LogCat.

Show more comments

2 Replies

· Add your reply
  • Sort: 
avatar image
8
Best Answer

Answer by whydoidoit · Oct 17, 2013 at 12:04 PM

Attach MonoDevelop to the process and click "Pause". See where the code is in the call stack.

alt text

alt text


screenshot 2013-10-17 12.59.12.jpg (101.7 kB)
merged.jpg (218.1 kB)
Comment
Add comment · Show 8 · 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 whydoidoit · Oct 17, 2013 at 12:08 PM 0
Share

When this happens to me it's nearly always a coroutine that has a section that doesn't yield for some reason.

avatar image wijesijp · Oct 17, 2013 at 01:38 PM 0
Share

I have following question,

Let’s say unity is executing function A in class X, While it is doing that is it possible to receive an OnTriggerEnter event to class X ?

avatar image CHPedersen · Oct 17, 2013 at 01:40 PM 0
Share

No. The thread that executes function A in class X is the same thread that would call the OnTriggerEnter event, and one thread cannot have control flow in two different places simultaneously.

avatar image meat5000 ♦ · Oct 17, 2013 at 01:50 PM 0
Share

I have following question,

@wijesijp Submit as a separate question.

Add some closure to this one. Was your problem solved?

avatar image wijesijp · Oct 17, 2013 at 01:54 PM 0
Share

The problem is still there. I am trying to figure out why it is happening. I followed your suggestion but there is no output in call stack.

Show more comments
avatar image
0

Answer by ToneDP · Jan 17, 2019 at 11:13 PM

Love this answer, but I am unable to get the new Visual Studio for Mac to pause any Unity app under any conditions, though it does attach to the process.

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

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.

Follow this Question

Answers Answers and Comments

21 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Critical problem in importing scripts 3 Answers

Error building Player: Win32Exception - with plugin? 1 Answer

really weird error - parameter must be of type: 2 Answers

Why is Unity built in recorder not working? 0 Answers

Why does my setup finish then say "Problem executing C:/Users/christina/Documents/New folder/Editor/Unity.exe: 5"? 0 Answers


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