Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

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

Discussion in 'Unity Transport' started by Kichang-Kim, Mar 30, 2022.

  1. Kichang-Kim

    Kichang-Kim

    Joined:
    Oct 19, 2010
    Posts:
    979
    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.
     
  2. simon-lemay-unity

    simon-lemay-unity

    Unity Technologies

    Joined:
    Jul 19, 2021
    Posts:
    383
    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?
     
    Last edited: Mar 30, 2022
  3. Kichang-Kim

    Kichang-Kim

    Joined:
    Oct 19, 2010
    Posts:
    979
    @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.
     
    simon-lemay-unity likes this.