Skip to content

fix: server not tracking scene handles for pre-loaded scenes - #4146

Open
NoelStephensUnity wants to merge 1 commit into
develop-3.x.xfrom
fix/server-not-tracking-scene-handles-for-pre-loaded-scenes-up-port
Open

fix: server not tracking scene handles for pre-loaded scenes#4146
NoelStephensUnity wants to merge 1 commit into
develop-3.x.xfrom
fix/server-not-tracking-scene-handles-for-pre-loaded-scenes-up-port

Conversation

@NoelStephensUnity

Copy link
Copy Markdown
Member

Up-port of #4145

Purpose of this PR

Scenes that were already loaded when a session starts were added to ScenesLoaded but never to the server-to-client scene handle tables, so UnloadScene passed its ScenesLoaded check and then failed inside RemoveServerClientSceneHandle. The scene unloaded on every peer, but an error was logged and the ScenesLoaded entry was never removed.

The client-server branch of the NetworkSceneManager constructor now registers those scenes the same way InitializeScenesLoaded does for distributed authority.

NetcodeIntegrationTestHelpers registered the test runner scene in ServerSceneHandleToClientSceneHandle unconditionally, which now collides with the constructor already having added it, so that add is guarded.

fix: #4140

Jira ticket

(Needs ticket)

Changelog

  • Fixed: Issue where scenes additively loaded before a session started were tracked as loaded on the server but had no scene handle entries, which caused NetworkSceneManager.UnloadScene to log an error and leave the scene registered as loaded even though it unloaded on all peers.

Documentation

  • No documentation changes or additions were necessary.

Testing & QA (How your changes can be verified during release Playtest)

Functional Testing

Manual testing :

  • Manual testing done

Automated tests:

  • Covered by existing automated tests
  • Covered by new automated tests

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.

Up-port

No up-port required.

Backports

No backport required.

Scenes that were already loaded when a session starts were added to
ScenesLoaded but never to the server-to-client scene handle tables, so
UnloadScene passed its ScenesLoaded check and then failed inside
RemoveServerClientSceneHandle. The scene unloaded on every peer, but an
error was logged and the ScenesLoaded entry was never removed.

The client-server branch of the NetworkSceneManager constructor now
registers those scenes the same way InitializeScenesLoaded does for
distributed authority.

NetcodeIntegrationTestHelpers registered the test runner scene in
ServerSceneHandleToClientSceneHandle unconditionally, which now collides
with the constructor already having added it, so that add is guarded.

@u-pr u-pr Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Harness Review

Ship it

The change consistently registers pre-start server scenes through the existing bidirectional handle helper while preserving loaded-scene population, and the accompanying test/helper adjustment matches that lifecycle. I examined the constructor, handle update/removal contract, scene population paths, and the startup test coverage.

Reviewed commit dab835f

🤖 Helpful? 👍/👎

@codecov-github-com

codecov-github-com Bot commented Aug 27, 2026

Copy link
Copy Markdown

Codecov Report

All modified and coverable lines are covered by tests ✅

@@              Coverage Diff               @@
##           develop-3.x.x    #4146   +/-   ##
==============================================
  Coverage          78.01%   78.01%           
==============================================
  Files                153      153           
  Lines              26260    26260           
==============================================
  Hits               20486    20486           
  Misses              5774     5774           
Flag Coverage Δ
NGOv2_project_testproject_ubuntu_pinnedTrunk 77.70% <100.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...cts/Runtime/SceneManagement/NetworkSceneManager.cs 79.49% <100.00%> (ø)
Components Coverage Δ
com.unity.netcode.gameobjects 78.01% <100.00%> (ø)

ℹ️ Need help interpreting these results?

@NoelStephensUnity
NoelStephensUnity enabled auto-merge (squash) August 27, 2026 15:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant