example crash

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

Moderators: Lapo, Bax

mytoaster
Posts: 6
Joined: 27 Oct 2010, 15:18
Location: california, usa

example crash

Postby mytoaster » 27 Oct 2010, 15:42

Getting a browser crash (firefox and chrome) with the unity examples.

Open two windows and login to the tris example. Close one of the windows, it will close then crash all your other windows. Is this a onapplicationquit problem with the smartfox client?

When you close the window, it doesn't log you out of the server either. On the remaining window open, it will still show that user logged in.

is anyone else seeing this?
ThomasLund
Posts: 1297
Joined: 14 Mar 2008, 07:52
Location: Sweden

Postby ThomasLund » 27 Oct 2010, 16:44

OS? Version of Unity?

(And no - not seeing it. Unity 3 on Mac using Firefox and Safari)
mytoaster
Posts: 6
Joined: 27 Oct 2010, 15:18
Location: california, usa

Postby mytoaster » 27 Oct 2010, 17:26

windows 7, unity 3.0 plugin. seeing this on the downloaded version (i haven't tried building the examples from unity editor yet.)
ThomasLund
Posts: 1297
Joined: 14 Mar 2008, 07:52
Location: Sweden

Postby ThomasLund » 27 Oct 2010, 18:00

Dont have Windows 7 here - so cant test on that platform.

Can you dig up any logfiles - player.log/editor.log or similar?

Thanks

/Thomas
mytoaster
Posts: 6
Joined: 27 Oct 2010, 15:18
Location: california, usa

Postby mytoaster » 27 Oct 2010, 18:31

So i built SFS2X-Lobby and ran it as an exe and am getting the same crash on exit. here's the end of the log, which isn't particular helpful. I manually logged out and tried to close the window and it hangs.

Is the source code available for the client dll? I was having some problems with the 1.6 client until i recompiled it with monodevelop. maybe a mono compile problem?

Code: Select all

[SFS - INFO] Message: Logout { Message id: 2 }
{ Dump: }

   (utf_string) zn: SimpleChat


[SFS DEBUG] Message: Logout { Message id: 2 }
{ Dump: }

   (utf_string) zn: SimpleChat

 
(Filename: ..\..\Runtime\Export\Generated\BaseClass.cpp Line: 2535)

OnLogout
UnityEngine.Debug:Internal_Log(Int32, String, Object)
UnityEngine.Debug:Log(Object)
LobbyGUI:OnLogout(BaseEvent)
Sfs2X.Core.EventDispatcher:DispatchEvent(BaseEvent)
Sfs2X.SmartFox:ProcessEvents()
LobbyGUI:FixedUpdate()
 
(Filename: ..\..\Runtime\Export\Generated\BaseClass.cpp Line: 2535)
stevets
Posts: 60
Joined: 11 Jul 2010, 12:22
Location: USA

Postby stevets » 27 Oct 2010, 18:59

Hi mytoaster,

I am getting a similar disconnect problem.
What happens in the editor when you shut down the program and go back to the scene mode?

Here is a link that might be of interest.
http://www.smartfoxserver.com/forums/viewtopic.php?t=8576
mytoaster
Posts: 6
Joined: 27 Oct 2010, 15:18
Location: california, usa

Postby mytoaster » 27 Oct 2010, 19:38

with the downloaded dll:
crashes on any quitting of the application. editor stops as well when trying to start and stop the unity app.

with dll downloaded from the forum thread you pointed me to:
doesn't crash on close of window. editor becomes REALLY slow when you start and stop the app.

for me all these problems were resolved for 1.6 when i recompiled the client dll from source code. I'm assuming this is a compile issue between compiling from mono (on other platforms) or from .net (windows).
ThomasLund
Posts: 1297
Joined: 14 Mar 2008, 07:52
Location: Sweden

Postby ThomasLund » 27 Oct 2010, 20:22

The dll that is packages with the release is compiled using Visual Studio in a Win XP vmware.

Let me quickly compile it with MonoDevelop on OSX and upload for you to test.

Try this one and report please:

http://www.fullcontrol.dk/downloads/SFS ... rc1-md.dll

/Thomas
stevets
Posts: 60
Joined: 11 Jul 2010, 12:22
Location: USA

Postby stevets » 27 Oct 2010, 22:03

I still have the same problem with the new dll.

Could someone explain.....Is Unity responsible for closing the connection to the smartfoxserver on the client end or is SFS2X supposed to close down all connections.

For example, when the lobby example is run (connection aquired and room joined) and then stopped using the play arrow in unity, does Unity automatically handle the closing of any open connections?
I know that the session on the server will eventually time out, but Unity 3 seems to have problems handling that gracefully. At least on the win version. I do not seem to have this problem on the mac version of Unity 3.
ThomasLund
Posts: 1297
Joined: 14 Mar 2008, 07:52
Location: Sweden

Postby ThomasLund » 28 Oct 2010, 06:03

Damn - really weird this one then.

When the server detects a disconnect of a user, it sends a "disconnected" event to the client and shuts down the socket.

You can manually trigger a disconnect from the server by doing smartFox.Disconnect()

This will both send a message to the server that we disconnected as well as force a shutdown of the socket in the API _right now_

None of the examples use the manual disconnect - which might be what causes this. Could you try to add a

Code: Select all

   void OnApplicationQuit() {
      smartFox.Disconnect();
   }


in your code (in the scene that is active) and see if that helps?

Thanks for helping track this bugger

/Thomas
mytoaster
Posts: 6
Joined: 27 Oct 2010, 15:18
Location: california, usa

Postby mytoaster » 28 Oct 2010, 06:07

yea, still have problems with the new dll as well. i guess the workaround is to make sure to not leave any hanging connections on exit, or unity freaks out. Modified SmartFoxConnection.cs to do that. Everything closes/stops/starts correctly now. Thanks for the help!!!

Code: Select all

public class SmartFoxConnection : MonoBehaviour
{
    private static SmartFoxConnection mInstance;

   private static SmartFox smartFox;
   public static SmartFox Connection
   {
      get
        {
            if (mInstance == null)
            {
                mInstance = new GameObject("SmartFoxConnection").AddComponent(typeof(SmartFoxConnection)) as SmartFoxConnection;
            }
            return smartFox;
        }
      set
        {
            if (mInstance == null)
            {
                mInstance = new GameObject("SmartFoxConnection").AddComponent(typeof(SmartFoxConnection)) as SmartFoxConnection;
            }
            smartFox = value;
        }
   }

   public static bool IsInitialized
   {
      get { return (smartFox != null); }
   }

    // handle disconnection
    void OnApplicationQuit()
    {
        //Debug.Log("disconnecting from smartfox server");
        if (smartFox.IsConnected)
        {
            smartFox.Disconnect();
        }
    }
}
ThomasLund
Posts: 1297
Joined: 14 Mar 2008, 07:52
Location: Sweden

Postby ThomasLund » 28 Oct 2010, 06:18

So a manual Disconnect() solves the issue for you mytoaster?

If so, I'll add that similar to how you got it. No reason people need to know this by themselves and have their Windows boxes crash.

/Thomas
mytoaster
Posts: 6
Joined: 27 Oct 2010, 15:18
Location: california, usa

Postby mytoaster » 28 Oct 2010, 06:20

yep, everything works! thank ya!
ThomasLund
Posts: 1297
Joined: 14 Mar 2008, 07:52
Location: Sweden

Postby ThomasLund » 28 Oct 2010, 06:23

Fantastic - thanks for the help.

Will add and make sure to put in a fat comment about not removing if you got Windows users around :-D

/Thomas
stevets
Posts: 60
Joined: 11 Jul 2010, 12:22
Location: USA

Postby stevets » 28 Oct 2010, 17:42

Works perfectly when I add it to the LobbyGUI.cs .

Thanks Thomas

I am still wondering why we do not need this for the mac equivalent case.

Steve

Return to “SFS2X C# API”

Who is online

Users browsing this forum: Baidu [Spider] and 57 guests