-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix: null-reference on double disposal #2245
base: main
Are you sure you want to change the base?
Conversation
Windows and Mac build successfull in Unity Cloud! You can find a link to the downloadable artifact below.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 💪
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have doubts about this PR:
-
Dispose
is called from a single point, if it is called multiple time all systems will spam with the error, we don't callDispose
per system, we call dispose on the entire world -
I believe the source of the issue was diagnosed improperly:
Initialize
is called when the whole scene environment is constructed- When the loading is cancelled in the middle (this is what you see when the realm/scene is frequently loaded/changed/unloaded)
SceneInstanceDependencies
is disposed of beforeInitialize
is called, it's by design: take a look atSceneFactory
:
if (ct.IsCancellationRequested) { await UniTask.SwitchToMainThread(PlayerLoopTiming.Initialization); deps.Dispose(); sceneRuntime?.Dispose(); throw new OperationCanceledException(); }
So the only thing that should be done is nullity checks of raycasts results because they could be not initialized (and it's the correct flow). I propose to close this PR
{ | ||
if (isDisposed) | ||
{ | ||
ReportHub.LogError(ReportCategory.ENGINE, $"Attempt to dispose already disposed system: {this.GetType().Name}"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use GetReportData
instead to get the proper coordinates and log category
@mikhail-dcl So if the cause is defined improperly I think it's good to have this safety net since |
What does this PR change?
Added OnDispose safe method that guarantees it will not be called more than once. If such attempt occurs it will be logged and propagated to Sentry
How to test the changes?
Follow ticket: #2209
Our Code Review Standards
https://github.com/decentraland/unity-renderer/blob/master/docs/code-review-standards.md