(Case 1415880) Unity Transport cannot handle iOS's app suspension

Hi. I found that Unity Transport does not handle iOS's app suspension correctly.

Here is reproducible steps:
1. Run unity app in both editor and iOS.
2. From iOS, connect to Editor's instance.
3. Check connection is valid and send packet works.
4. Turn off iOS's screen about 3-4 seconds.
5. Turn on iOS's screen and resume app.
6. You can see that NetworkDriver on iOS still works and Send request does not return any error code. It seems that connection is alive, but actually, internal UDP socket is invalid and your send request will fail
silently. After 30s (default disconnection timeout), the connection is disconnected.

I think this is unintended behaviour and NetworkDriver should fail to send immediately after Step 5.

Is there any method for checking internal socket status without waiting very long disconnection timeout?

Note : C#'s UdpClient return error correctly after iOS's app suspension.

Interesting find! Thanks for bringing this to our attention!

Did you already file a bug about this? If not, would you mind entering one and letting me know what the ID is? It would make it easier for us to track this (since this is definitely something we'll want to keep track of).

Unfortunately there is no API to check the internal socket status. I know it's not an ideal solution, but in this situation one option could be to decrease the disconnection timeout to get notified sooner that there was a problem (you could also set up more frequent heartbeats to avoid "normal" inactivity from triggering a disconnection).

Also, if you try to re-establish a connection afterwards using the same driver, does it work? Is the behavior the same if the iOS application is acting as the server?

@simon-lemay-unity Hi. I uploaded reproducible project as Case 1415880.

if you try to re-establish a connection afterwards using the same driver, does it work?
I tested this and found that I can't re-establish connection by using same driver until re-create driver (app relaunch).

I hope that this will help you.

1 Like