API v1.1.0 released

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

Moderators: Lapo, Bax

User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: API v1.1.0 released

Postby Lapo » 19 Apr 2013, 13:10

Yes, I have done more testing under Windows 7 64bit and Windows 8.
As I reported earlier I was able to reproduce the problem using our Lobby Example. Today I did some more testing in order to create a repro-case for the Unity team and I was able to solve the issue :)

It turns out that if you add this code:

Code: Select all

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


all problems go away, both in the Unity Editor and in the native binary.

Cheers
Lapo
--
gotoAndPlay()
...addicted to flash games
Ferz
Posts: 21
Joined: 27 Aug 2011, 08:17

Re: API v1.1.0 released

Postby Ferz » 19 Apr 2013, 14:26

We will try it. Thank you.
Ferz
Posts: 21
Joined: 27 Aug 2011, 08:17

Re: API v1.1.0 released

Postby Ferz » 14 May 2013, 07:19

Hello!
We tried this. Nothing was changed.
Our code

Code: Select all

public void OnApplicationQuit()
    {      
        if (_smartFox != null)
        {
            if (_smartFox.IsConnected)
            {
                _smartFox.RemoveAllEventListeners();
                _smartFox.Disconnect();
            }
            _smartFox = null;
        }
    }


Another problem case, which could help you:
1. Connect to server
2. Try init UDP on the wrong port (which server does not listen). UDP inititalization will be failed.
3. Try to close application. It will hangs.
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: API v1.1.0 released

Postby Lapo » 14 May 2013, 08:48

Hi, unfortunately it is not so simple.
We have discussed these issues time and time again in other threads, like this:
viewtopic.php?f=20&t=15165
and we have tested under MacOSX, Windows 7 32, Windows 7 64 and Windows 8.

Under the same exact conditions, using the same exact source we have seen different behaviors. Sometimes it hangs, some other it doesn't. The problem is not with the API but it has to be found way down in the native code that is generated by Unity from the C# bytecode.

With the latest API and using the OnApplicationQuit trick we were able to remove the problem on all platforms we have tested, however there are still reports of problems even though we're not able to reproduce it, at the moment.

I proposed to submit a bug report to the Unity Team but so far we haven't got a reproducible case. If you have one you might go ahead and provide your sources to the Unity dev team to take a look.

Thanks
Lapo

--

gotoAndPlay()

...addicted to flash games
Ferz
Posts: 21
Joined: 27 Aug 2011, 08:17

Re: API v1.1.0 released

Postby Ferz » 14 May 2013, 10:27

The problem is not with the API but it has to be found way down in the native code that is generated by Unity from the C# bytecode.

Unity does not do it. It uses SFSClient library untouched, and then mono execute it in runtime.

I understand, that this issue is not obvious how to fix, but it is very annoying.
Could you answer: what differences are between TCP readers-writers threads and UDP readers-writers threads? Maybe there is some key in this differences, which help to understand why using UDP hangs application?

Could it be that UDP socket layer do not lways stop it's reader-writes threads on disconnect? Otherwise how such kind of logs:

[SFS - WARN] Unexpected UDP I/O Error. Error reading data from socket: Операция блокирования прервана вызовом WSACancelBlockingCall.

could appears AFTER SFS event OnConnectionLost was fired?
(SFSConnector.OnConnectionLost reason = manual)
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: API v1.1.0 released

Postby Lapo » 14 May 2013, 10:41

Unity does not do it. It uses SFSClient library untouched, and then mono execute it in runtime.

I don't understand your point. What I am saying here is that there's a bug in the runtime, possibly with the proper shutdown of threads when quitting the application. Using the OnApplicationQuit event has solved the problem for us under Windows, while under MacOSX the problem doesn't even exist. I hope this is clear.

Could it be that UDP socket layer do not lways stop it's reader-writes threads on disconnect? Otherwise how such kind of logs:

Yes, and again by disconnecting the client OnApplicationQuit you are properly shutting down all threads.
I hope you are using the latest API, which is version 1.2.0 even though this thread is still about the previous version. If not please upgrade.
Lapo

--

gotoAndPlay()

...addicted to flash games
Ferz
Posts: 21
Joined: 27 Aug 2011, 08:17

Re: API v1.1.0 released

Postby Ferz » 15 May 2013, 07:45

Version 1.2.0 did not help. We decided to use such kind a code, to avoid hangs:

if (!Application.isEditor)
{
System.Diagnostics.Process.GetCurrentProcess().Kill();
}
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: API v1.1.0 released

Postby Lapo » 15 May 2013, 11:53

If you a proof of concept that you can send us we'll test it over here and see if we can reproduce the issue.
If we can we'll get in touch with the Unity dev team to see what they can do about it.

You can send it to our support@... mailbox adding a reference to this post.
Lapo

--

gotoAndPlay()

...addicted to flash games
Ferz
Posts: 21
Joined: 27 Aug 2011, 08:17

Re: API v1.1.0 released

Postby Ferz » 16 May 2013, 12:03

I created proof of concept: http://rwars.org/FPSDemoBuild.zip
Anybody can download it and try on my test server, or any other server.

Use case:
1. Connect
2. Login.
3. Create game and move a little.
4. Kill internet connection.
5. Try to close application. It will hangs. Not always, but very often.

Is it anough, or I must to send a letter?

P.S. FPS Demo project connects to server at first and then shows editable fields "Server name", "Server port". It's a liitle bit frustrating, so I't will be nice if you will fix this behaviour in demo project.

Return to “SFS2X C# API”

Who is online

Users browsing this forum: No registered users and 21 guests