Standalone build on Unity 5.1.3 & 5.2 for Win crash on exit.

Post here your questions about the Unity / .Net / Mono / Windows 8 / Windows Phone 8 API for SFS2X

Moderators: Lapo, Bax

User avatar
AndyMartin458
Posts: 55
Joined: 15 May 2012, 21:57

Standalone build on Unity 5.1.3 & 5.2 for Win crash on exit.

Postby AndyMartin458 » 21 Sep 2015, 03:15

I was hoping to release a beta version of my game this weekend, but the game freezes and fails to respond when I close the player window. I recently updated to the latest version of SmartFox on my server and client. C# client API 1.61 and server version 2.10 on Windows 10.

I've been trying to track down a bug in my code, but my investigation shows that it is caused by SmartFox. You can reproduce the issue by downloading and running the latest version of the Connector example with Unity 5.1.3 or 5.2.0 (those are the two versions I've tested). After successfully connecting, click the X to close the app. This is when the app freezes and stops responding. It requires a force close after that. Please help by releasing a new version of the client API.
User avatar
Bax
Site Admin
Posts: 4609
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Re: Standalone build on Unity 5.1.3 & 5.2 for Win crash on e

Postby Bax » 21 Sep 2015, 09:20

Thank you for reporting. Are you testing a standalone build?
Also, did you test under Windows 10 only? Or do you see the same behavior in Windows 8?
Also can you provide more info on your investigation? What makes you think it is caused by SFS?
Thanks for your help.
Paolo Bax
The SmartFoxServer Team
User avatar
AndyMartin458
Posts: 55
Joined: 15 May 2012, 21:57

Re: Standalone build on Unity 5.1.3 & 5.2 for Win crash on e

Postby AndyMartin458 » 21 Sep 2015, 16:16

In my investigation, I slowly stripped away my code until all that was left was the call to the smart fox server constructor, and the calls to connect. I then built a small extra project sample to determine that. I would wait until there was a response that the SmartFox instance was connect. In the editor, I would close the game, and it would be fine. So I had to keep building out to the player to test. When I would go to close the player after connecting, it would crash.

I then downloaded the official Unity 5 SmartFox examples and used the Connector example to connect to my server (running sfs 2.10). The same issue happened. It closed fine in the editor but not in a standalone player. That's how I know it specifically has to do with SmartFox.

I have only tested on Windows 10. I am currently downloading the latest version of Unity to Windows 8.1 laptop to check it.
User avatar
AndyMartin458
Posts: 55
Joined: 15 May 2012, 21:57

Re: Standalone build on Unity 5.1.3 & 5.2 for Win crash on e

Postby AndyMartin458 » 21 Sep 2015, 16:26

Bax wrote: Are you testing a standalone build?
Also, did you test under Windows 10 only? Or do you see the same behavior in Windows 8?


I copied the standalone build to my Windows 8.1 machine and experienced the same issue. The Connector example freezes when closing.

Thank you for your time, and I hope it is able to be fixed soon. As a guess, it appears to be a thread that is not closing properly and running some kind of loop.
User avatar
Lapo
Site Admin
Posts: 23007
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Standalone build on Unity 5.1.3 & 5.2 for Win crash on e

Postby Lapo » 21 Sep 2015, 16:33

Thanks for the details.
Do you see any specific errors after the client crash?
Does window give you some logging information?

thanks
Lapo
--
gotoAndPlay()
...addicted to flash games
User avatar
AndyMartin458
Posts: 55
Joined: 15 May 2012, 21:57

Re: Standalone build on Unity 5.1.3 & 5.2 for Win crash on e

Postby AndyMartin458 » 21 Sep 2015, 17:01

I have looked in the output_log.txt that is generated by the Unity player. It doesn't show anything that makes it seem like a freeze / crash is happening. I haven't looked specifically for the windows event crash log, but that seems like the logical next step. I wasn't aware Windows generated those separately.
User avatar
AndyMartin458
Posts: 55
Joined: 15 May 2012, 21:57

Re: Standalone build on Unity 5.1.3 & 5.2 for Win crash on e

Postby AndyMartin458 » 21 Sep 2015, 17:30

I looked throught the Windows event logs and there are no errors from the time frame when the app was run and exited. I think that is as far as I am able to take this investigation.
User avatar
Lapo
Site Admin
Posts: 23007
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Standalone build on Unity 5.1.3 & 5.2 for Win crash on e

Postby Lapo » 22 Sep 2015, 07:48

Thank you very much.
Lapo

--

gotoAndPlay()

...addicted to flash games
User avatar
Bax
Site Admin
Posts: 4609
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Re: Standalone build on Unity 5.1.3 & 5.2 for Win crash on e

Postby Bax » 23 Sep 2015, 21:39

We started investigating...
Given that with a previous version of Unity (the one available when we created the examples) everything worked fine, now we tested with Unity 5.2.1f1 both under Windows 8 and OSX.

1) generating the Connector's exe file in Unity for Windows causes an odd behavior: launching the exe crashes right after the Unity logo is displayed. No idea why, but this happens only with the examples based on the "Calibration Scene" project made available by the Unity team in the asset store.
Other examples (e.g. the Object Movement) which don't use that project show the same behavior you described: the application crashes when closing the window while the connection is active (if we disconnect before closing the windows, everything is fine).

2) generating the exe file in Unity for OSX and then launching it in Windows shows the behavior you described, no matter if the example is based on the "Calibration Scene" or not.

We will continue investigating and report here our findings.
Paolo Bax
The SmartFoxServer Team
User avatar
AndyMartin458
Posts: 55
Joined: 15 May 2012, 21:57

Re: Standalone build on Unity 5.1.3 & 5.2 for Win crash on e

Postby AndyMartin458 » 23 Sep 2015, 21:47

I'm glad to see that your investigation was in line with what I was seeing. Please continue to keep us posted on findings and potential release dates of a patch that fixes it.
User avatar
AndyMartin458
Posts: 55
Joined: 15 May 2012, 21:57

Re: Standalone build on Unity 5.1.3 & 5.2 for Win crash on e

Postby AndyMartin458 » 26 Sep 2015, 20:19

I think that the Disconnect event can no longer be processed in OnApplicationQuit. I have a small workaround. I've reworked my project to load a new scene when the app is closed. I noticed that when my game got disconnected in a normal way (not on quit), it did not hang when I closed it.

You can find my code and explanation on my blog: http://clubconsortya.blogspot.com/2015/09/how-to-disconnect-smartfox-in-unity-513.html
User avatar
Bax
Site Admin
Posts: 4609
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Re: Standalone build on Unity 5.1.3 & 5.2 for Win crash on e

Postby Bax » 28 Sep 2015, 08:33

I was going to suggest something similar... well, actually simpler:

Code: Select all

void OnApplicationQuit() {
   if (sfs != null && sfs.IsConnected)
      sfs.Disconnect ();
}

I tested this in Mac OSX, generating the .exe file for Windows: running it everything is fine and the application doesn't crash anymore on quit.

But then I also tested the same project compiling it in Unity for Windows... guess what? The crash still occurs!
I'm now going to send a bug report to the Unity team, given that the last time we did we never got a reply.
Paolo Bax
The SmartFoxServer Team
User avatar
AndyMartin458
Posts: 55
Joined: 15 May 2012, 21:57

Re: Standalone build on Unity 5.1.3 & 5.2 for Win crash on e

Postby AndyMartin458 » 29 Sep 2015, 03:44

I don't know if this is generally what is expected for a disconnect. I pulled this log from my output_log.txt. Maybe this error is what is causing the crash? The game still closed smoothly because of my workaround.

Setting up 3 worker threads for Enlighten.
Thread -> id: 10b8 -> priority: 1
Thread -> id: 18c8 -> priority: 1
Thread -> id: 3954 -> priority: 1
[SFS - ERROR] [TCPSocketLayer] General error reading data from socket: Read failure at System.Net.Sockets.NetworkStream.Read (System.Byte[] buffer, Int32 offset, Int32 size) [0x00000] in <filename unknown>:0

at Sfs2X.Core.Sockets.TCPSocketLayer.Read () [0x00000] in <filename unknown>:0

OnConnectionLost SFSManager
UnityEngine.Debug:Internal_Log(Int32, String, Object)
UnityEngine.Debug:Log(Object)
SmartFoxManager:OnConnectionLost(BaseEvent) (SmartFoxManager.cs:44)
Sfs2X.Core.EventDispatcher:DispatchEvent(BaseEvent)
Sfs2X.SmartFox:ProcessEvents()
SmartFoxManager:Update() (SmartFoxManager.cs:77)
User avatar
Bax
Site Admin
Posts: 4609
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Re: Standalone build on Unity 5.1.3 & 5.2 for Win crash on e

Postby Bax » 29 Sep 2015, 07:29

That error is expected.

Anyway we think we have found what is causing the inconsistent behavior of the SmartFox.Disconnect method when called in the OnApplicationQuit handler (which usage keeps being mandatory - in fact we should update all our examples accordingly).
We just made a small improvement to the API and we are testing it. If you want to get a pre-release version, please send us an email.
Paolo Bax
The SmartFoxServer Team
User avatar
AndyMartin458
Posts: 55
Joined: 15 May 2012, 21:57

Re: Standalone build on Unity 5.1.3 & 5.2 for Win crash on e

Postby AndyMartin458 » 30 Sep 2015, 01:58

I have updated my blog post accordingly. Version 1.6.2 does fix the hang. http://clubconsortya.blogspot.com/2015/ ... y-513.html

Return to “SFS2X C# API”

Who is online

Users browsing this forum: No registered users and 26 guests