Page 2 of 2

Re: API v1.1.0 released

Posted: 19 Apr 2013, 13:10
by Lapo
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

Re: API v1.1.0 released

Posted: 19 Apr 2013, 14:26
by Ferz
We will try it. Thank you.

Re: API v1.1.0 released

Posted: 14 May 2013, 07:19
by Ferz
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.

Re: API v1.1.0 released

Posted: 14 May 2013, 08:48
by Lapo
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

Re: API v1.1.0 released

Posted: 14 May 2013, 10:27
by Ferz
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)

Re: API v1.1.0 released

Posted: 14 May 2013, 10:41
by Lapo
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.

Re: API v1.1.0 released

Posted: 15 May 2013, 07:45
by Ferz
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();
}

Re: API v1.1.0 released

Posted: 15 May 2013, 11:53
by Lapo
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.

Re: API v1.1.0 released

Posted: 16 May 2013, 12:03
by Ferz
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.