- Home /
System.Threading.Thread use causing error on player exit in OSX
I'm using System.Threading.Thread to handle HttpWebRequests and in OSX standalone builds a system-level error occurs (complete with a "Report to Apple" window). No noticeable errors occur in Windows standalone builds or in the Editor (in OSX). I added a check in OnApplicationQuit that checks if any of the threads I've created are still alive, and it reports that there aren't any. The relevant area of the console log is presented below:
Total Object count 291 (Before unload 135)
Live threads at quit: 0 out of 1 created. UnityEngine.Debug:Log(Object) DatabaseConnection:OnApplicationQuit()
(Filename: /Users/build/builds/unity-26/unity-2.6.x/Projects/../Runtime/Export/Generated/BaseClass.cpp Line: 1783)
Cleanup player
ERROR **: file error.c: line 62 (SetLastError): assertion failed: (ret == 0) aborting...
ERROR **: file error.c: line 62 (SetLastError): assertion failed: (ret == 0) aborting...
Again, I don't see this error in the Editor or Windows standalone builds. Suggestions on how I can properly clean up my program on exit would be appreciated.
I would recommend not using .net threading in Unity. It causes more problems than it's worth. Use coroutines ins$$anonymous$$d.
Answer by Lucas Meijer 1 · May 28, 2010 at 10:01 AM
We have quite a few issues with HttpWebRequest (allthough most are in the webplayer, not in the standalone). I'd suggest using the WWW class instead. Also, please be aware that Unity2.6 has a bug where exceptions thrown on the non-main thread will crash the application. I'm currently working on this bug for the next version of Unity.
Ah, okay. Thanks. We were using WWW until we found out we needed to have Proxy support (http://answers.unity3d.com/questions/6780/how-do-i-use-the-www-class-using-a-proxy-server). I haven't run into any problems while the game was running (as I said, the error only occurs when quitting an OSX standalone), so I'll just mark it as a known issue for the time being. Thanks again for the info!
Is the problem with HttpWebRequest endemic to all $$anonymous$$ono System.Net classes? That is, would I get the same result using WebClient?
Your answer
Follow this Question
Related Questions
MySql compiler error help~ (OSX) 0 Answers
Game Quits Unexpectedly on Launch 0 Answers
Thread assert error message when using SmartFoxServer 2 Answers
"Assertion failed: Error querying default thread scheduling params: 3" 0 Answers
Build Problem (Mac) 1 Answer