Unity 2017.2.1f1 Android crash on disconnect

Post here your questions about SFS2X. Here we discuss all server-side matters. For client API questions see the dedicated forums.

Moderators: Lapo, Bax

Vcrn
Posts: 29
Joined: 11 Apr 2017, 00:31

Unity 2017.2.1f1 Android crash on disconnect

Postby Vcrn » 20 Jan 2018, 17:55

After updating to Unity 2017.2.1f1, the application crashes on Android when calling the disconnect method from the client. The error log is as follows:

Code: Select all

01-20 13:04:04.896 16412 17855 D Unity   : [SFS - ERROR] [TCPSocketLayer] General error reading data from socket: Read failure   at System.Net.Sockets.NetworkStream.Read (System.Byte[] buffer, Int32 offset, Int32 size) [0x00065] in /Users/builduser/buildslave/mono/build/mcs/class/System/System.Net.Sockets/NetworkStream.cs:374
01-20 13:04:04.896 16412 17855 D Unity   :   at Sfs2X.Core.Sockets.TCPSocketLayer.Read () [0x00000] in <filename unknown>:0


Both the server and client use the most recent version releases.

Is there a way to fix this?
User avatar
Lapo
Site Admin
Posts: 22999
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Unity 2017.2.1f1 Android crash on disconnect

Postby Lapo » 22 Jan 2018, 08:38

Hi,
I am not sure there is one, unfortunately. But we'll take a look.
The fact that it happens only under Android means that something is incorrect in the way the code is exported for that platform. I fear the new Unity release has broken something.

What we can do is seeing if there's a way to work around it without affecting the other platforms. I would not get my hopes too high, since the issue seems on the Unity side, but it's worth a shot.

Stay tuned
Lapo
--
gotoAndPlay()
...addicted to flash games
User avatar
Lapo
Site Admin
Posts: 22999
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Unity 2017.2.1f1 Android crash on disconnect

Postby Lapo » 22 Jan 2018, 10:21

UPDATE:
I have tested under the latest Unity (2017.3.0f3) using Bluestacks (as Android simulator) and was not able to cause any issues when calling the manual disconnection.

Have you tested on multiple devices? Is the problem reproducible at will?

Thanks
Lapo

--

gotoAndPlay()

...addicted to flash games
Vcrn
Posts: 29
Joined: 11 Apr 2017, 00:31

Re: Unity 2017.2.1f1 Android crash on disconnect

Postby Vcrn » 22 Jan 2018, 22:33

Lapo wrote:UPDATE:
I have tested under the latest Unity (2017.3.0f3) using Bluestacks (as Android simulator) and was not able to cause any issues when calling the manual disconnection.

Have you tested on multiple devices? Is the problem reproducible at will?

Thanks


It happens on multiple devices.

I was able to replicate the error with a blank Unity project, using SmartFoxServer 2X and the Google Play Services plugin (although it does not crash). Could the plugin be interfering with SFS? Strangely we are using the same version of Google Play Services that was used before updating Unity (previous version was 5.6.1).
Vcrn
Posts: 29
Joined: 11 Apr 2017, 00:31

Re: Unity 2017.2.1f1 Android crash on disconnect

Postby Vcrn » 23 Jan 2018, 00:26

Also to note: after updating to Unity 2017.2.1f1, in the OnUserVariablesUpdate event, the following now returns a "cannot cast from source to destination type" error when this was previously not an issue.

Code: Select all

ArrayList changedVars = (ArrayList)evt.Params["changedVars"];
User avatar
Lapo
Site Admin
Posts: 22999
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Unity 2017.2.1f1 Android crash on disconnect

Postby Lapo » 23 Jan 2018, 10:03

Vcrn wrote:
Lapo wrote:UPDATE:
I have tested under the latest Unity (2017.3.0f3) using Bluestacks (as Android simulator) and was not able to cause any issues when calling the manual disconnection.

Have you tested on multiple devices? Is the problem reproducible at will?

Thanks


It happens on multiple devices.

I was able to replicate the error with a blank Unity project, using SmartFoxServer 2X and the Google Play Services plugin (although it does not crash). Could the plugin be interfering with SFS?

Can you try without the google library? Otherwise you could try one of our Examples from our example pack:
http://smartfoxserver.com/download/#p=examples

Thanks
Lapo

--

gotoAndPlay()

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

Re: Unity 2017.2.1f1 Android crash on disconnect

Postby Bax » 23 Jan 2018, 10:47

Vcrn wrote:Also to note: after updating to Unity 2017.2.1f1, in the OnUserVariablesUpdate event, the following now returns a "cannot cast from source to destination type" error when this was previously not an issue.

Code: Select all

ArrayList changedVars = (ArrayList)evt.Params["changedVars"];

I just tested the OnUserVariablesUpdate event in Unity 2017.3.0.p1 using the ObjectMovement example, and no issue occurred.

I'd suggest to access the "changedVars" array like this:

Code: Select all

List<string> changedVars = (List<string>)evt.Params["changedVars"];

Does this solve the issue? If not, please show an example of variables you are setting which cause the cast problem? Thanks.
Paolo Bax
The SmartFoxServer Team
Vcrn
Posts: 29
Joined: 11 Apr 2017, 00:31

Re: Unity 2017.2.1f1 Android crash on disconnect

Postby Vcrn » 23 Jan 2018, 15:48

Bax wrote:
Vcrn wrote:Also to note: after updating to Unity 2017.2.1f1, in the OnUserVariablesUpdate event, the following now returns a "cannot cast from source to destination type" error when this was previously not an issue.

Code: Select all

ArrayList changedVars = (ArrayList)evt.Params["changedVars"];

I just tested the OnUserVariablesUpdate event in Unity 2017.3.0.p1 using the ObjectMovement example, and no issue occurred.

I'd suggest to access the "changedVars" array like this:

Code: Select all

List<string> changedVars = (List<string>)evt.Params["changedVars"];

Does this solve the issue? If not, please show an example of variables you are setting which cause the cast problem? Thanks.


That fixes the issue with user variables, however the application still crashes.

Lapo wrote:Can you try without the google library? Otherwise you could try one of our Examples from our example pack:
http://smartfoxserver.com/download/#p=examples


I used a blank Unity project and the Connector example with no errors. After I imported Google Play Services, I would receive the disconnection error the first time I would disconnect. It wouldn't occur again unless I restarted the app.

Here is a more detailed log from the Android device at the time of the crash, which occurs just after disconnecting from the server.

Code: Select all

01-23 10:52:51.823  3856  3924 E Unity   : Connection to server failed: manual
01-23 10:52:51.823  3856  3924 E Unity   : Stacktrace is not supported on this platform.
01-23 10:52:51.823  3856  3924 E Unity   : (Filename: ./artifacts/generated/common/runtime/DebugBindings.gen.cpp Line: 51)
01-23 10:52:51.823  3856  3924 E Unity   :
01-23 10:52:52.752   780  2356 W ActivityManager:   Force finishing activity com.package/com.unity3d.player.UnityPlayerActivity
01-23 10:52:52.800  3856  3856 I Unity   : onPause
01-23 10:52:53.299   780   795 W ActivityManager: Activity pause timeout for ActivityRecord{f0f7a66 u0 com.package/com.unity3d.player.UnityPlayerActivity t193 f}
01-23 10:52:53.329   780   795 I ActivityManager: Config changes=480 {1.0 302mcc?mnc en_US ldltr sw360dp w360dp h568dp 480dpi nrml port finger -keyb/v/h -nav/h s.119}
01-23 10:52:56.800  3856  3856 W Unity   : Timeout while trying to pause the Unity Engine.
01-23 10:52:56.804  3856  3856 I Unity   : windowFocusChanged: false
01-23 10:53:00.854  3856  3856 I Unity   : onDestroy
01-23 10:53:01.186   780  2793 I ActivityManager: Process com.package (pid 3856) has died
01-23 10:53:01.186   780  2793 D ActivityManager: cleanUpApplicationRecord -- 3856
01-23 10:53:01.207   780  2793 W ActivityManager: Scheduling restart of crashed service com.package/com.onesignal.SyncService in 1000ms
01-23 10:53:01.220   780  2357 I ActivityManager: Process com.android.chrome:sandboxed_process5 (pid 4158) has died
01-23 10:53:01.221   780  2357 D ActivityManager: cleanUpApplicationRecord -- 4158
01-23 10:53:01.221   780  2357 W ActivityManager: Scheduling restart of crashed service com.android.chrome/org.chromium.content.app.SandboxedProcessService5 in 10987ms
01-23 10:53:02.229   780   795 I ActivityManager: Start proc 4439:com.package/u0a252 for service com.package/com.onesignal.SyncService
Vcrn
Posts: 29
Joined: 11 Apr 2017, 00:31

Re: Unity 2017.2.1f1 Android crash on disconnect

Postby Vcrn » 24 Jan 2018, 02:23

Update: I have discovered that kicking my device from the Admin Tool, or closing the server to make the client to timeout, causes the game to disconnect successfully without crashing. The crash seems to only occur when manually disconnecting via the client.
User avatar
Lapo
Site Admin
Posts: 22999
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Unity 2017.2.1f1 Android crash on disconnect

Postby Lapo » 24 Jan 2018, 09:55

What version(s) of Android are you testing with?
Have you tried testing in a simulator (running the same Android release) and see if it's also reproducible there?

Unfortunately we don't have access to all possible combinations of physical devices and Android versions, as there are thousands of them and we usually rely on simulators to test and reproduce issues.

If even the simulator is not affected by this it's going to be very tricky to find the cause.

Thanks
Lapo

--

gotoAndPlay()

...addicted to flash games
Vcrn
Posts: 29
Joined: 11 Apr 2017, 00:31

Re: Unity 2017.2.1f1 Android crash on disconnect

Postby Vcrn » 24 Jan 2018, 19:18

Lapo wrote:What version(s) of Android are you testing with?
Have you tried testing in a simulator (running the same Android release) and see if it's also reproducible there?

Unfortunately we don't have access to all possible combinations of physical devices and Android versions, as there are thousands of them and we usually rely on simulators to test and reproduce issues.

If even the simulator is not affected by this it's going to be very tricky to find the cause.

Thanks


I don't believe it's a device-level issue as it occurs on multiple devices with different versions of Android.

I have found that the crashing only occurs if UDP has been initialized. If UDP is not initialized, the client can properly disconnect without crashing. I added UDP initialization to the Connector example in a blank project and no crash occurs. However, if I import the scenes/scripts from the Connector example into the original project, the crash will still occur. This leads me to believe it may be related to plugins.
User avatar
Lapo
Site Admin
Posts: 22999
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Unity 2017.2.1f1 Android crash on disconnect

Postby Lapo » 25 Jan 2018, 15:07

Thanks for the details.
We'll investigate a bit more. As I mentioned, if the problem affected all platforms it could be an issue with the API. However in this case it behaves strangely on a specific platform, which suggests the problem is at a lower level, i.e. the Unity Android exporter. And there's also the fact that the problem appeared under a more recent version of Unity while previously it was working fine.

From our side we haven't changed anything in the UDP code in a long time, so I don't feel like this falls under our control.
In any case we can investigate it further and see if there's anything we can do to work around it.

I'll report back when we find something.
Hope it helps
Lapo

--

gotoAndPlay()

...addicted to flash games
User avatar
Lapo
Site Admin
Posts: 22999
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Unity 2017.2.1f1 Android crash on disconnect

Postby Lapo » 26 Jan 2018, 15:53

UPDATE: we're currently not able to reproduce this. Would you be able to send us the logcat transcript of the application crash?
This would at least give us an hint as to where exactly the problem is occurring.

Thanks
Lapo

--

gotoAndPlay()

...addicted to flash games
Vcrn
Posts: 29
Joined: 11 Apr 2017, 00:31

Re: Unity 2017.2.1f1 Android crash on disconnect

Postby Vcrn » 30 Jan 2018, 17:38

Lapo wrote:UPDATE: we're currently not able to reproduce this. Would you be able to send us the logcat transcript of the application crash?
This would at least give us an hint as to where exactly the problem is occurring.

Thanks


I posted the logcat output in a previous reply:

Code: Select all

01-23 10:52:51.823  3856  3924 E Unity   : Connection to server failed: manual
01-23 10:52:51.823  3856  3924 E Unity   : Stacktrace is not supported on this platform.
01-23 10:52:51.823  3856  3924 E Unity   : (Filename: ./artifacts/generated/common/runtime/DebugBindings.gen.cpp Line: 51)
01-23 10:52:51.823  3856  3924 E Unity   :
01-23 10:52:52.752   780  2356 W ActivityManager:   Force finishing activity com.package/com.unity3d.player.UnityPlayerActivity
01-23 10:52:52.800  3856  3856 I Unity   : onPause
01-23 10:52:53.299   780   795 W ActivityManager: Activity pause timeout for ActivityRecord{f0f7a66 u0 com.package/com.unity3d.player.UnityPlayerActivity t193 f}
01-23 10:52:53.329   780   795 I ActivityManager: Config changes=480 {1.0 302mcc?mnc en_US ldltr sw360dp w360dp h568dp 480dpi nrml port finger -keyb/v/h -nav/h s.119}
01-23 10:52:56.800  3856  3856 W Unity   : Timeout while trying to pause the Unity Engine.
01-23 10:52:56.804  3856  3856 I Unity   : windowFocusChanged: false
01-23 10:53:00.854  3856  3856 I Unity   : onDestroy
01-23 10:53:01.186   780  2793 I ActivityManager: Process com.package (pid 3856) has died
01-23 10:53:01.186   780  2793 D ActivityManager: cleanUpApplicationRecord -- 3856
01-23 10:53:01.207   780  2793 W ActivityManager: Scheduling restart of crashed service com.package/com.onesignal.SyncService in 1000ms
01-23 10:53:01.220   780  2357 I ActivityManager: Process com.android.chrome:sandboxed_process5 (pid 4158) has died
01-23 10:53:01.221   780  2357 D ActivityManager: cleanUpApplicationRecord -- 4158
01-23 10:53:01.221   780  2357 W ActivityManager: Scheduling restart of crashed service com.android.chrome/org.chromium.content.app.SandboxedProcessService5 in 10987ms
01-23 10:53:02.229   780   795 I ActivityManager: Start proc 4439:com.package/u0a252 for service com.package/com.onesignal.SyncService


Also, we've tested the same project on iOS and no crash occurs. It only crashes on our Android devices.
Vcrn
Posts: 29
Joined: 11 Apr 2017, 00:31

Re: Unity 2017.2.1f1 Android crash on disconnect

Postby Vcrn » 30 Jan 2018, 18:39

Update: I've discovered that exporting the apk using IL2CPP allows the app to function properly without crashing. The crash appears to only occur when using Mono to export.

Return to “SFS2X Questions”

Who is online

Users browsing this forum: No registered users and 41 guests