-
-
Notifications
You must be signed in to change notification settings - Fork 21.2k
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
ResourceLoader: Add thread-aware resource changed mechanism #96593
Merged
akien-mga
merged 2 commits into
godotengine:master
from
RandomShaper:res_changed_multiverse
Sep 6, 2024
Merged
ResourceLoader: Add thread-aware resource changed mechanism #96593
akien-mga
merged 2 commits into
godotengine:master
from
RandomShaper:res_changed_multiverse
Sep 6, 2024
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
RandomShaper
added
topic:core
regression
cherrypick:4.3
Considered for cherry-picking into a future 4.3.x release
labels
Sep 5, 2024
Cherry-pick for 4.3 included in #96606. |
akien-mga
removed
the
cherrypick:4.3
Considered for cherry-picking into a future 4.3.x release
label
Sep 5, 2024
akien-mga
reviewed
Sep 5, 2024
RandomShaper
force-pushed
the
res_changed_multiverse
branch
from
September 6, 2024 06:57
0f3ee92
to
74b9c38
Compare
akien-mga
approved these changes
Sep 6, 2024
RandomShaper
added a commit
to RandomShaper/godot
that referenced
this pull request
Sep 6, 2024
This is a complement to: godotengine#96593
RandomShaper
added a commit
to RandomShaper/godot
that referenced
this pull request
Sep 6, 2024
This is a complement to: godotengine#96593 (cherry picked from commit ab29964)
RandomShaper
added a commit
to RandomShaper/godot
that referenced
this pull request
Sep 6, 2024
This is a complement to: godotengine#96593
RandomShaper
added a commit
to RandomShaper/godot
that referenced
this pull request
Sep 6, 2024
This is a complement to: godotengine#96593 (cherry picked from commit ef365d0)
RandomShaper
added a commit
to RandomShaper/godot
that referenced
this pull request
Sep 6, 2024
This is a complement to: godotengine#96593
RandomShaper
added a commit
to RandomShaper/godot
that referenced
this pull request
Sep 6, 2024
This is a complement to: godotengine#96593 (cherry picked from commit 97197ff)
maidopi-usagi
pushed a commit
to maidopi-usagi/godot
that referenced
this pull request
Sep 11, 2024
This is a complement to: godotengine#96593
RandomShaper
added a commit
to RandomShaper/godot
that referenced
this pull request
Sep 13, 2024
This is a complement to: godotengine#96593 (cherry picked from commit 97197ff)
RandomShaper
added a commit
to RandomShaper/godot
that referenced
this pull request
Sep 23, 2024
This is a complement to: godotengine#96593 (cherry picked from commit 97197ff)
npinsker
pushed a commit
to npinsker/godot
that referenced
this pull request
Oct 3, 2024
This is a complement to: godotengine#96593
ChrisBase
pushed a commit
to ChrisBase/godot
that referenced
this pull request
Nov 15, 2024
This is a complement to: godotengine#96593
jss2a98aj
pushed a commit
to jss2a98aj/blazium
that referenced
this pull request
Nov 18, 2024
This is a complement to: godotengine#96593 (cherry picked from commit 97197ff)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The unregistered task mechnaism is used to isolate a uncached load from a cached one with the same path. This commit simplifies how unregistered loads are handled.
That brings the benefit of more code shared between both, which removes the constraint of uncached loads having to complete synchronously.
Signals are not thread-safe. Therefore, resource loaders shouldn't deal with them. However, there's a special signal in
Resource
,changed
, which is a common need during resource loading. Fortunately, it has its own API.This commit lets the
ResourceLoader
intervene that API during threaded loading so the handling of thechanged
signal can happen in a safe manner.The general idea is that during loads, only the resources known to a loader thread participate in the signal. When a load is awaited by another, the awaited one propagates its record of connections to the awaiter, which can happen recursively. The awaited one keeps its records until it dies, so they are available to any other load chaining with it. Finally, when a leaf task is awaited, the connections are migrated to the standard signal mechanism on the main thread.
This replaces the current attempt at thread-safe
changed
signaling, which wasn't good enough because 1) it tried to achieve safety by deferring the calls within a load thread, which changed the expected flow too much; and 2) it couldn't avoid multiple load threads from dealing with the connection maps of the objects involved, therefore not being as robust as desirable. That said, the mechanism in this PR is much more resilient, but, at the end of the day, signals are not thread-safe in Godot, so it can only guarantee correctness within its realm (resource loading).The implementation tries to be simple in these ways:
CONNECT_REFERENCE_COUNTED
is used, likeAnimationNodeBlendTree
, or other flags, this implementation will forward them to the standard signal mechanism, but won't honor them during loads.Fixes #96115.