Putting app in background and resuming is not handled gracefully on Android
Bug Description
When running a game using Netcode with an Android client, pausing the app (for example, by going Home or locking the screen) and resuming the app does not seem to be handled gracefully. The screen will either go completely black or flicker, and I get the following error message from Netcode:

Reproduction steps
Create a project with Netcode and have a basic server/client setup Connect to server on an android build Put app in background, and resume App should not flicker or become completely black-screened.
Expected outcome
If the connection has been maintained upon resuming the app, I would expect the game to continue where it left off and not have a black screen and/or flicker. If the connection has been interrupted, I would expect the client to handle it gracefully and either try reconnecting automatically or disconnect completely and all the client to reconnect again manually. I would not expect a bunch of errors/exceptions from Netcode.
There may be some workarounds people have discovered, and if so, I would appreciate them! I have tried using the OnApplicationPause unity callback to try various things like restarting scene or shutting down network but I can't seem to get back to a "clean" state in which I could attempt a reconnect from the client.
Environment
OS: Windows 10 Unity Version: 2020.3 Netcode Version: 1.0.0
Added to our backlog as MTT-3017
I've found a workaround but it's kind of hacky and seems to work about 70-80% of the time (other times I get same black screen or flicker). Basically when the application pauses and unpausing (putting game in background/opening it up again), we can disconnect and reconnect the client:
void OnApplicationPause(bool pauseStatus)
{
if (pauseStatus)
{
NetworkManager.Shutdown();
NetworkManager.StartClient();
}
}
Another problem with this workaround is that NetworkManager.Shutdown() runs into the NotServerException error when run on the client because the client is trying to destroy objects instead of despawning them on the server. I believe this is an actual bug with the library. However since it does not block me I'm not going to focus on it right now and revisit it in the future.
It would be great if Unity3D could add support for pausing/resuming mobile applications directly into the library as this is a very common action (e.g. switching apps to respond to a message) players will perform and without it Netcode does not seem production-ready for mobile devices.
Hi @Shivang44 This has been fixed recently. Can you please try one of latest Unity Transport releases (1.3.0 is the latest as of today) and let us know. Thanks
We have verified that this issue is fixed. Please reopen if you encounter the same issue again.