fix: scene message handler duplicate key - #8821
Conversation
|
Windows and Mac build successful in Unity Cloud! You can find a link to the downloadable artifact below. |
|
Claude finished @lorux0's task in 1m 58s —— View job Review
Root-cause assessmentProblem being solved: Root cause or symptom? This is a symptom fix. The underlying cause is an improper disposal ordering — the old scene module instance isn't fully torn down before the new one registers. PR #8702 attempted to address that lifecycle issue. This PR defensively prevents the crash when it still occurs. That said, silently replacing the handler is the correct semantic (the newest registration should win), so this is a reasonable defensive measure — provided the removal side is updated to match (see blocking issue below). Blocking issue
Before this PR, step 2 would throw, making the ordering problem visible. Now the duplicate add is absorbed but the destructive removal still happens. See inline comment on Non-blockingThe comment REVIEW_RESULT: FAIL ❌ |
|
Claude finished @lorux0's task in 1m 10s —— View job Review
Root-cause assessmentProblem being solved: Root cause or symptom? Symptom fix. The underlying cause is improper disposal ordering; PR #8702 attempted to address that. This PR defensively prevents the crash. Swapping to the indexer is the correct semantic (newest registration wins), so the fix is reasonable — but only if the removal side is also updated to match. Blocking issue — still unaddressedThe previous review flagged that With the new replacement strategy the sequence becomes:
The fix needed (see inline comment on line 97): lock (sceneMessageHandlers)
{
if (sceneMessageHandlers.TryGetValue(key, out var current) && current == onSceneMessage)
sceneMessageHandlers.Remove(key);
}REVIEW_RESULT: FAIL ❌ |
|
Claude finished @lorux0's task in 1m 2s —— View job Review
Root-cause assessmentProblem being solved: Root cause or symptom? Symptom fix. The underlying cause remains improper disposal ordering (PR #8702 attempted that fix). This PR provides the correct defensive guard, and the fix is semantically sound (newest registration wins), now paired with a corrected removal path. Previous blocking issue — now fixed ✅
if (sceneMessageHandlers.TryGetValue(key, out var current) && current == onSceneMessage)
sceneMessageHandlers.Remove(key);This correctly prevents Instance A's Previous non-blocking — now fixed ✅The what-comment No blocking issues remain. REVIEW_RESULT: PASS ✅ |
|
✅ PR reviewed and approved by QA on both platforms following the PR test instructions. Build: Test results:
Unrelated errors noted (do not affect verdict):
Verdict: PASS ✅ Additional note (unrelated to this PR): On Mac, during the first session, teleporting from Genesis Plaza to a World caused all GP users to appear as ghost avatars in the destination World. This did not reproduce after restarting the build (second session). Windows was not affected. Will file separately if reproducible. Logs: Issue reproduced only once and no longer reproduced while testing this PR 19.05.2026_17.40.15_REC.PR-8821.first.teleport.mp419.05.2026_17.45.14_REC.PR-8821.mp4 |

What does this PR change?
Fixes #8183
Fixes any possible key duplication when registering the scene message handler.
The root of the issue might be caused due disposal issues, but it should have been fixed here: #8702
Test Instructions
Go through different scenes. Check that they work normally.
Quality Checklist
Code Review Reference
Please review our Branch & PR Standards before submitting. It explains the automated review flow, QA/DEV approval requirements, and what each label does — especially useful for first-time contributors.