Fix thread safety issue in resource changed callbacks during imports#107218
Closed
d6e wants to merge 1 commit intogodotengine:masterfrom
Closed
Fix thread safety issue in resource changed callbacks during imports#107218d6e wants to merge 1 commit intogodotengine:masterfrom
d6e wants to merge 1 commit intogodotengine:masterfrom
Conversation
Use call_deferred() instead of direct call() in ResourceLoader::resource_changed_emit() to ensure resource change callbacks execute on the main thread. This prevents segfaults when font imports trigger node operations from background threads.
Author
|
Closed because #107224 supersedes it |
This file contains hidden or 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
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.
Summary
Fixes a segmentation fault that occurs when font resources are imported in background threads and emit “changed” signals that trigger thread-unsafe node operations.
Problem
When importing font files, the ResourceLoader can emit “resource changed” callbacks from background threads. These callbacks may be connected to GUI nodes (for example, RichTextLabel) that perform operations requiring main‐thread access, causing thread‐safety violations and crashes.
The specific error trace is:
Solution
Modify
ResourceLoader::resource_changed_emit()to usecall_deferred()instead of a directcall()when invoking callbacks. This ensures all “resource changed” signals run on the main thread, preventing thread‐safety violations.