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

Document that accessing Multiplayer from Node is not thread-safe #79326

Closed
wants to merge 1 commit into from

Conversation

AThousandShips
Copy link
Member

@AThousandShips AThousandShips commented Jul 11, 2023

Unsure about the exact wording so took that from the error message of SceneTree

Only added to Node as the API isn't necessarily restricted but the access to it from SceneTree is, and SceneTree is stated to be non-safe

Closes: #79323

@AThousandShips AThousandShips added documentation topic:multiplayer cherrypick:4.1 Considered for cherry-picking into a future 4.1.x release labels Jul 11, 2023
@AThousandShips AThousandShips added this to the 4.2 milestone Jul 11, 2023
@AThousandShips AThousandShips requested a review from a team as a code owner July 11, 2023 09:30
@akien-mga akien-mga requested a review from a team July 11, 2023 09:31
@AThousandShips
Copy link
Member Author

AThousandShips commented Jul 11, 2023

An additional option to reduce crashes in some contexts would be to add null checks in some methods on Node to catch cases, will investigate

Edit: done, #79332

@AThousandShips
Copy link
Member Author

Ping @Faless

@mhilbrunner
Copy link
Member

mhilbrunner commented Sep 27, 2023

I'm torn on this. It is useful info in the edge case that you are calling them from another thread, but it also adds a lot of clutter if we add this bit in all functions that are not thread safe everywhere. The default assumption should be that things are not thread-safe unless stated otherwise, especially anything interacting with nodes or the scene/SceneTree, IMO.

OTOH, if you are new, you may not expect "multiplayer.function()" to be interacting with the Node/SceneTree like it is and think it is some kind of global thing, or something.

I'm undecided. :/

@AThousandShips AThousandShips modified the milestones: 4.2, 4.3 Oct 26, 2023
@AThousandShips AThousandShips added cherrypick:4.2 Considered for cherry-picking into a future 4.2.x release and removed topic:multiplayer labels Oct 26, 2023
@Mickeon
Copy link
Contributor

Mickeon commented Jan 16, 2024

Wouldn't it make sense to add it to the @rpc documentation, instead of all this? It would catch basically everyone wanting to mess with multiplayer, without needing to be needlessly repetitive.

It could be a warning instead of a note, as well.

@AThousandShips
Copy link
Member Author

AThousandShips commented Jan 16, 2024

Not sure about the location (as not all who use the multiplayer use @rpc), but warning is a good detail thank you, will add when I next update

@Mickeon
Copy link
Contributor

Mickeon commented Jan 16, 2024

I feel very strongly for the warning in @rpc, but it doesn't have to be only there, I suppose. Perhaps it only really needs to be in multiplayer's description. That's the second place users would look when messing with... multiplayer.

@YuriSizov
Copy link
Contributor

It is useful info in the edge case that you are calling them from another thread, but it also adds a lot of clutter if we add this bit in all functions that are not thread safe everywhere. The default assumption should be that things are not thread-safe unless stated otherwise, especially anything interacting with nodes or the scene/SceneTree, IMO.

I agree with this POV. With the crashes fixed by #79332, I think the original issue should be closed and we don't need to add warnings specifically in these few methods. Instead it should be made clear in the multiplayer documentation in the manual.

@AThousandShips
Copy link
Member Author

Closing as per above, will look at the manual side 🙂

@AThousandShips AThousandShips removed this from the 4.3 milestone Jan 23, 2024
@AThousandShips AThousandShips added archived and removed cherrypick:4.1 Considered for cherry-picking into a future 4.1.x release cherrypick:4.2 Considered for cherry-picking into a future 4.2.x release labels Jan 23, 2024
@AThousandShips AThousandShips deleted the mp_doc branch February 24, 2024 16:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Calling MultiplayerAPI in a thread results in crashes.
4 participants