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 jashan · Mar 04, 2011 at 11:14 AM · iphonenullreferenceexceptionxcodemonodevelopdebugger

Debugging NullReferenceExceptions in iOS Games

I'm currently getting crashes ("it simply disappears") in my game when running on the device. The message I get from the Xcode log is:

Unhandled Exception: System.NullReferenceException:

Debugger stopped. Program exited with status value:1.

The issue is 100% reproduceable on device (i.e. it happens every time) - but it never happens in the editor. While I do have some conditional compilation it's very unlikely that any of that makes the difference for this issue.

So, I've been trying to nail this down for a little while and finally decided to give the new on-device-debugging feature a try. This is working really great when I'm setting breakpoints. And fortunately MonoDevelop also provides the possibility to break on exceptions - so I also tried adding a break-condition for "System.NullReferenceException". But that never is triggered (but the issue is 100% reproduceable).

So, I created a test case to see if "break on exception" is really working in MonoDevelop, and it is: I built a deliberate NullReferenceException into the game when clicking a button, and when I add System.NullReferenceException to the exception triggers, MonoDevelop nicely stops when the exception occurs. So, for these cases it really does work (nice ;-) ).

Unfortunately, it doesn't help with my crash because there it still doesn't trigger.

So, there's three interesting things / questions:

a) This is the log in Xcode (when executing in Xcode; not when debugging, of course ;-) ):

Program received signal: EXC_BAD_ACCESS. warning: Unable to read symbols for /Developer/Platforms/iPhoneOS.platform/DeviceSupport/4.2.1 (8C148)/Symbols/Developer/usr/lib/libXcodeDebuggerSupport.dylib (file not found).

So that's different from the exception I'm trying to hunt down. Also - on this exception, my game simply freezes, while on the exception I'm trying to hunt down it "disappears". And, of course, I'm seeing this one in the editor as expected.

Why am I getting a System.NullReferenceException in the Xcode log one time, and a EXC_BAD_ACCESS the other time? Why do I get a "freeze" one time, and a "disappears" the other time?

b) My deliberate NullReferenceException does trigger the break-condition when debugging with MonoDevelop. So, in theory there would be a really easy way to find NullReferenceExceptions on the device - only it doesn't work for the specific case I need it for.

What could cause this?

c) When I play the game started from Xcode or started from the device without the debugger attached, the "crash" makes the game disappear. When the debugger is attached, the game just freezes - but the debugger doesn't go anywhere.

NOTE: While testing, I realized that sometimes MonoDevelop doesn't really seem to attach. Well, actually it does (it also leaves debug mode when the app is terminated on the device) - it just doesn't stop with the breakpoints. So, I thought maybe that's why I never got my exception triggering a debug-stop. But either breakpoints work or they don't - and I made sure to test in a session where they did work.

Comment
Add comment · Show 2
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 Statement · Mar 04, 2011 at 12:03 PM 0
Share

Are you using threading?

avatar image jashan · Mar 04, 2011 at 03:28 PM 0
Share

No, not anymore ;-) ... I did use threading in the past but that caused more trouble than any good ;-) ... but I think I found out what it was by now (it's good to have Unity Android as well - as it seems to be a little more stable with NullReferenceExceptions ... and I'm afraid I was wrong with "While I do have some conditional compilation it's very unlikely that any of that makes the difference for this issue." - it was in fact a "mobile only feature" that gave me the trouble ;-)

2 Replies

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

Answer by jashan · Mar 04, 2011 at 03:33 PM

Ah, it's good to have Unity Android as well: Turned out I was wrong with the "it's likely that it's something specific to the iPhone", in fact it was. So now that I know what the exact issue was, I also have an understanding of what the difference between my test case and the actual problem was:

Seems like the difference with NullReferenceExceptions is whether it happens on game objects or just plain C# objects. My testcase was with a string - the actual problem happened on a game object that was either destroyed or deactivated (still need to do some further testing on this).

So, when it's "really null", you get the EXC_BAD_ACCESS thing. When it's one of Unity's "special states" with its game objects, you might get the System.NullReferenceException. The first one seems to be comparatively easy to debug using MonoDevelop remote debugging, the latter one probably only works with trial and error or, if you have Unity Android, by trying it there and hopefully, you'll get the same issue there.

So: I saw the NullReferenceExceptions in my Android build - so I was lucky on that one. I probably would have never found this particular issue any other way (or it would have cost me many, many more frustrating hours).

Comment
Add comment · Show 1 · 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 Fehr · Feb 25, 2012 at 03:59 AM 0
Share

I'd just like to add my two cents and mention that this error occurred due to a gameobject beco$$anonymous$$g unassigned when it became inactive. Its near impossible to test this on a device, and I had to try and simulate everything my plugins where doing in ios within the editor to figure out exactly why. If possible this is probably the simplest solution to debugging the impossible null reference.

avatar image
-1

Answer by dreammakersgroupAdmin · Nov 22, 2013 at 04:41 PM

check this tool http://u3d.as/content/dreammakersgroup/in-game-logs/5E8

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

2 People are following this question.

avatar image avatar image

Related Questions

Information for developpement 1 Answer

Attaching MonoDevelop to iPhone? 3 Answers

XCode Debugger crash, but game runs on phone 0 Answers

Unity modules for iOS? 1 Answer

location of game object on x axis 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