Skip to content
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

MultiplayerSynchronizer visibility results in client peer not finding cached object #90908

Open
graydoubt opened this issue Apr 19, 2024 · 1 comment

Comments

@graydoubt
Copy link

Tested versions

  • Reproducible in v4.2.2.stable.official.15073afe3
  • Reproducible in v4.2.2.rc3.official.16a8334b8
  • Reproducible in v4.2.2.rc2.official.c61a68614
  • Reproducible in v4.2.2.rc1.official.c7fb0645a
  • Not reproducible in v4.2.1.stable.official.b09f793f5

System information

Godot v4.2.2.stable - Windows 10.0.19045 - Vulkan (Forward+) - dedicated NVIDIA GeForce GTX 1070 Ti (NVIDIA; 31.0.15.5176) - Intel(R) Core(TM) i7-4790K CPU @ 4.00GHz (8 Threads)

Issue description

I have a multiplayer setup where characters have limited vision using the MultiplayerSynchronizer's visibility settings.

Characters have two MultiplayerSynchronizers:

  • The main "Sync" MS is for the server to sync character properties to clients
  • The second "Motion" MS syncs its own properties (target_position) from the client to the server, for movement interpolation

image

The "NetworkClientScope2D" and "NetworkScopedObject2D" are Area2D nodes that detect when a character is in range and update the "Sync" MP's visibility for the corresponding peer accordingly.

In Godot 4.2.1, this works as expected.
The Host (on the left) always sees the client.
The client (on the right) only sees the host when they're in range:

Godot_v4 2 1-stable_win64_2024-04-19_11-31-38

In Godot 4.2.2, the visibility setting works once. Upon exiting the visibility range, and re-entering the Area2D, the client can no longer receive updates from the "Motion" MS.

Godot_v4 2 2-stable_win64_2024-04-19_11-28-20

Instead, the client will report error messages for each synchronization update:

E 0:00:21:0159   get_cached_object: ID 3 not found in cache of peer 1.
  <C++ Error>    Parameter "oid" is null.
  <C++ Source>   modules/multiplayer/scene_cache_interface.cpp:278 @ get_cached_object()

and, as a result:

E 0:00:21:0167   on_delta_receive: Ignoring delta for non-authority or invalid synchronizer.
  <C++ Error>    Condition "true" is true. Continuing.
  <C++ Source>   modules/multiplayer/scene_replication_interface.cpp:783 @ on_delta_receive()

I believe this may be related to PR 87190 ([MP] Handle cleanup of "scene cache" nodes)

Steps to reproduce

I recommend enabling Visible Collision Shapes from the debug menu

  • Launch two instances of the MRP.
  • Start one as host, and have the other join as client (The MRP is set up to host and connect to localhost over WebSocket).
  • Move the players towards each other (order does not matter) until they're in visibility range.
  • Note how both characters correctly sync their positions
  • Move the character apart, so they're no longer in visibility range
  • Move the characters back together
    • In Godot 4.2.1, this works fine.
    • In Godot 4.2.2 (starting with RC1), the host character can no longer synchronize its position to the client. Instead, the client will report get_cached_object errors.

Minimal reproduction project (MRP)

https://github.com/graydoubt/422-mp-regression

@Faless
Copy link
Collaborator

Faless commented Apr 21, 2024

Thanks for the detailed report, I think I understand what is going on, I'll try to get a fix out next week.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants