fix: Attachables destroy order of operations#3931
Open
NoelStephensUnity wants to merge 15 commits intodevelop-2.0.0from
Open
fix: Attachables destroy order of operations#3931NoelStephensUnity wants to merge 15 commits intodevelop-2.0.0from
NoelStephensUnity wants to merge 15 commits intodevelop-2.0.0from
Conversation
Adding change log entry. Fixing some typos.
EmandM
reviewed
Apr 8, 2026
Member
EmandM
left a comment
There was a problem hiding this comment.
Hmmm, I think I maybe don't understand the full process of what the issue is here
This includes some additional edge case fixes... specifically for the scenario where we know a scene is being unloaded that will result in either an `AttachableNode` or `AttachableBehaviour` being destroyed and they are attached.
Fixing an edge case that requires manually testing due to how integration tests additively load everything to avoid unloading the test runner test scene when loading a scene. Two parts: - When a server is destroying spawned scene objects due to a single mode scene load, it should also include a check for this and handle marking the NetworkObject and associated NetworkBehaviours as being destroyed and then destroy the object. - Just prior to handling a scene loading event, we need to mark anything that will be destroyed (i.e. destroy with scene) as being destroyed when migrating spawned objects into the DDOL.
Member
Author
|
/crc |
There was a problem hiding this comment.
The review has identified several critical issues related to the execution order of destruction hooks and the handling of attached states, particularly in pooling scenarios. Key findings include:
- Execution Timing: The
IsDestroyingflag is set too late inNetworkBehaviour, causing safety checks inInternalDetachto be bypassed. - State Management:
AttachableBehaviourfails to correctly notify/update state during destruction, risking stale data in pooled objects. - Reference Cleanup:
AttachableNodemay leave stale references when behaviours with authority are being destroyed. - Code Quality: Improvements suggested for null safety and documentation of scene-state checks.
🤖 Helpful? 👍/👎
…rors-scene-changes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Purpose of this PR
Fixing an issue with attachables where either an
AttachableBehaviouror anAttachableNodecan throw an exception or erroneously log an error message if they are attached together prior to a scene unload event where one of the two persists the scene unload event and the other does not.Jira ticket
MTT-14831
Changelog
AttachableBehaviouror anAttachableNodecan throw an exception or erroneously log an error message if they are attached during a scene unload where one of the two persists the scene unload event and the other does not.Documentation
Testing & QA (How your changes can be verified during release Playtest)
Functional Testing
Manual testing :
Manual testing doneAutomated tests:
Covered by existing automated testsCovered by new automated testsAttachableBehaviourSceneLoadTests.Does the change require QA team to:
Review automated tests?Execute manual tests?Provide feedback about the PR?If any boxes above are checked the QA team will be automatically added as a PR reviewer.
Backports
This is v2.x.x. specific.