Skip to content

Pure client skips loading a connection scene when the server's scene handle matches one of its own scenes - #1115

Open
Andy608 wants to merge 1 commit into
FirstGearGames:mainfrom
Andy608:fix/client-scene-lookup-by-name
Open

Andy608 wants to merge 1 commit into
FirstGearGames:mainfrom
Andy608:fix/client-scene-lookup-by-name

Conversation

@Andy608

@Andy608 Andy608 commented Oct 30, 2026

Copy link
Copy Markdown

Follow-up to #1069 (closed for lack of a repro). Still present on 4.7.4 / main; reproduced on 4.7.2 with Unity 6000.3, a macOS dedicated server build and a standalone client build.

What happens

On a dedicated server, a scene stays loaded on the server and connections are moved between scenes with LoadConnectionScenes / UnloadConnectionScenes (by name, AutomaticallyUnload = false). Going A → B works. Going back B → A, the client never loads A:

OnLoadStart  asServer=False Scene_Plaza
OnLoadEnd    asServer=False loaded=(none) skipped=MovedObjectsHolder
SceneId of 4017455039 not found in SceneObjects. ...

The server then spawns A's scene objects to a client that doesn't have A. Every time for us; a host, or a server in the Editor, doesn't show it (the handle numbers don't line up).

Why

  1. A is already loaded on the server, so SceneManager (server side, CanLoadScene false) broadcasts new SceneLookupData(s): the client receives the server's handle for A.
  2. On the client, CanLoadScene → SceneLookupData.GetScene looks that handle up first, among the client's scenes.
  3. Scene handles are process-local. The client's MovedObjectsHolder (made when it unloaded A) had the same number as the server's A, so the client treated A as already loaded and skipped it.

The same lookup resolves unloads, so a collision could also unload the wrong client scene.

Fix

GetScene trusts a handle only in the process that runs the server; a pure client resolves by name.

  • The client still echoes the server's lookup data back unchanged (ClientScenesLoadedBroadcast), so the server's handle-based pending-load check still matches.
  • Servers and hosts keep handle lookups (their handles are their own).
  • Uses InstanceFinder.IsServerStarted, so it assumes one NetworkManager per process.

We've run this patch on 4.7.2: the A → B → A round trip against a dedicated server build went from failing every time to passing every time.

🤖 Generated with Claude Code

…r's handle

A client receives the server's scene handle for a scene already loaded on the server. Handles are process-local, so
looking it up among the client's scenes can match an unrelated scene (e.g. MovedObjectsHolder) and skip the load, or
unload the wrong scene. Follow-up to FirstGearGames#1069.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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