| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| { | ||
| if (Application.isPlaying) | ||
| { | ||
| #if UNITY_2023_1_OR_NEWER |
There was a problem hiding this comment.
NGOv2.X offers support from 6000.0 editor so I don't think this if is needed
Sorry, something went wrong.
There was a problem hiding this comment.
The same check is used elsewhere in the same file, but happy to remove it if it's not needed.
Sorry, something went wrong.
There was a problem hiding this comment.
Yeah, remove it. I guess we just missed some stuff to cleanup. I will follow up on it
Sorry, something went wrong.
There was a problem hiding this comment.
I'd rather have started NetworkManager's register themselves to be shutdown instead of doing a search. No need to make domain reloads any slower for users.
Also, how does Fast Enter Play Mode interact with this problem? Do we need to register against different callbacks for that?
Sorry, something went wrong.
| if (Application.isPlaying) | ||
| { | ||
| #if UNITY_2023_1_OR_NEWER | ||
| var networkManager = Object.FindAnyObjectByType<NetworkManager>(); |
There was a problem hiding this comment.
We added our own static API that hides all the different mutations FindObjects has gone through over time.
Though I think rather than searching for all NetworkManagers, it'd be better if any started NetworkManager registers themselves to something so they can be shut down. Objects.FindAll can be slow, I'd rather avoid needing to make Domain reloads any slower.
| var networkManager = Object.FindAnyObjectByType<NetworkManager>(); | |
| var networkManager = FindObjects.ByType<NetworkManager>(); |
Sorry, something went wrong.
There was a problem hiding this comment.
I modified the code to use NetworkManager.Singleton instead.
Sorry, something went wrong.
It pretty much doesn't. The problem only manifests if we are already in play mode (and have live state that can't be serialized) and then encounter a domain reload. The issues with Fast Enter Play Mode are mostly with statics which won't be automatically reset across play mode entry/exit. Here the issue is not with domain reloads happening (or not) when entering/exiting play mode, it's when a domain reload occurs during play mode. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Purpose of this PR
When the domain is reloaded while in play mode, a lot (most?) of the state in NetworkManager is lost because it's not serializable. This state gets lost without any opportunity to properly clean it up which results in memory leaks and sockets not being closed. (The last one is particularly problematic because the zombie sockets will cause issues as long as the editor is open.)
While ideally NGO would serialize all of its state and survive domain reloads, that's probably not very realistic in the short term as that would require extensive changes to the code. What we can do relatively easily however is properly shut down the NetworkManager when we do detect a domain reload. This at least avoids leaking resources.
Jira ticket
UUM-146443
Changelog
Documentation
Testing & QA
Functional Testing
Manual testing :
Automated tests:
Does the change require QA team to:
Backports
Probably not worth it.