Commit Graph

283 Commits

Author SHA1 Message Date
HP van Braam f63ab5fbd9 Fix a race in ResourceLoader::load_threaded_request()
When multiple threads try to load the same sub-resource the
ResourceLoader's anti-deadlock protection thinks that the other threads
loading the dependency are old threads blocked on a dependency.

The current thread will then immediately start to load the sub-resource
since they can't wait for it. This can then lead to multiple threads
loading the same resource concurrently.

We fix the problem by recording in the task when loading has ACTUALLY
started, and if so we simply wait.

This is no worse than before, at the point where we are waiting now we
previously re-started the load entirely.

Tested by running the MRP from the below issue (with and without asan
and msan), and loading and running various public and private Godot
projects.

This also fixes a use-after-free on resource_changed_connections when
multiple threads end up running the same import. This is a pre-existing
bug but this code widened the race window.

This also fixes a pre-existing memory leak in load_threaded_request,
when the user calls the function we capture the Ref<LoadToken> but
immediately drop the ref. Causing the refcount to go to 1. Later in
_run_load_task we unreference manually, bringing the refcount to 0. This
then later prevents the Ref<> from memdeleting the LoadToken.

This fixes #118085
2026-05-05 15:11:05 +02:00
StarryWorm 9ffc7d9f99 Split CacheMode from ResourceFormatLoader 2026-03-27 07:16:20 -04:00
Rémi Verschelde eabb9a63d4 Rename callable_method_pointer.h to callable_mp.h and include it explicitly
This allows removing it from `class_db.h`, significantly reducing the amount of files
that include it transitively.

Also includes some include cleanup in `control.h` and `rich_text_label.h` done while
ensure they don't depend on `callable_mp`.
2026-03-04 16:23:23 +01:00
Rémi Verschelde 765362b033 Explicitly include core/config/engine.h where used 2026-03-04 10:17:10 +01:00
Thaddeus Crews e380a41752 Style: Add class_db.h includes explicitly 2026-02-26 15:50:28 -06:00
Jules 8cf4c5d9b2 Fix multithreaded load status progress 2026-02-24 09:23:26 +01:00
Lukas Tenbrink a6adb12240 Remove message_queue.h include from object.h. 2026-02-20 00:27:41 +01:00
Lukas Tenbrink c5df0cb82b Don't right-align escaped newlines, e.g. for #define. This has previously led to long diffs in the commit history. 2026-02-04 19:31:28 +01:00
Thaddeus Crews ed1ec3a0ee Merge pull request #111387 from Chaosed0/core/fix-resource-loader-ignore-cache
Fix `load_threaded_get` returning `null` when used with `CACHE_MODE_IGNORE`
2025-12-10 18:10:27 -06:00
kobewi 60591dc7e8 Add reverse UID cache 2025-12-08 12:40:14 +01:00
Pedro J. Estébanez 5806e3c761 ResourceLoader: Fix potential infinite recursion in progress reporting 2025-12-01 12:33:48 +01:00
Haoyu Qiu c885098266 Remove unused methods in ResourceLoader 2025-10-30 08:13:20 +08:00
Ed Lu 49efe2b3b8 load_threaded_get doesn't return null resources when used with CACHE_MODE_IGNORE 2025-10-07 16:31:27 -07:00
Aaron Franke 3d1c9fd5de Move server files into their subfolders 2025-09-30 19:39:39 -07:00
Thaddeus Crews fdf32d1b2a Merge pull request #108577 from YYF233333/global_class_list
Simplify `ScriptServer::get_global_class_list`
2025-09-30 11:19:10 -05:00
A Thousand Ships bd65cfa876 Revert "Replace many uses of is_class with derives_from."
This reverts commit 78b743cf4a.
2025-09-25 13:48:53 +02:00
Lukas Tenbrink 8ef4a43ada Replace many uses of is_class with derives_from. 2025-09-23 19:59:00 +02:00
Thaddeus Crews 9b96eaaf80 Merge pull request #107989 from Jojo-1000/docs-add-required-qualifier
Documentation: Add missing required qualifier for various classes
2025-09-19 09:17:06 -05:00
Yufeng Ying a50fc5acd8 Change ClassDB::get_class_list and related stuff. 2025-09-16 15:00:33 +08:00
Thaddeus Crews c2202d36c1 Merge pull request #103838 from ebeem/master
Core: Fix translation remaps incorrectly falling back
2025-08-01 11:45:22 -05:00
Almarhoon Ibraheem 9add19a4ad Core: Fix translation remaps incorrectly falling back 2025-08-01 19:23:06 +03:00
Jojo-1000 ab178719d9 Mark methods for various classes as required 2025-07-30 19:24:56 +02:00
Hugo Locurcio 16d551a8dd Improve error messages in ResourceLoader
- Remove part of the "Failed loading resource" message about opening
  the project in the editor, as it's sometimes misleading.
- Fix `(expected type: )` appearing at the end of the
  "No loader found for resource:" error message.
2025-06-13 02:00:59 +02:00
Lyuma f948ab5366 Implement uid Resource references in VariantWriter
VariantWriter now writes the uid and the path into Resource() references.
This change will affect ConfigFile, used for .import or project settings.
2025-06-08 06:11:35 -07:00
KaiN 19a94159a2 Fix async resource loading progress on empty p_original_path 2025-06-04 15:24:39 +02:00
RedMser a96e8ac62c Remove old path remaps system
Unused in public repositories, deprecated for over 6 years, and the
replacement system is well-tested by now.
2025-04-23 15:48:33 +02:00
Thaddeus Crews c67b9a43e3 Merge pull request #100086 from erodozer/multipart-ext-import
Support multi dot extensions in import plugins
2025-04-10 10:18:18 -05:00
Thaddeus Crews 1cb3cfaa8e Style: Convert namespaces to PascalCase 2025-03-23 19:10:24 -05:00
Rémi Verschelde 6ed10dee37 Merge pull request #104060 from bruvzg/resloader_ids
Fix `Invalid Task ID` errors in `ResourceLoader`.
2025-03-14 00:08:59 +01:00
Rémi Verschelde d912dcc26c Merge pull request #104013 from bruvzg/rload_nowait
[ResourceLoader] Do not wait for the main thread during initial reimport.
2025-03-14 00:08:53 +01:00
Pāvels Nadtočajevs d1b63ae16c Fix Invalid Task ID errors in ResourceLoader. 2025-03-13 08:41:53 +02:00
Yufeng Ying bebe037abf Add ConstIterator to Dictionary. 2025-03-13 01:28:46 +08:00
Pāvels Nadtočajevs 16865b6917 [ResourceLoader] Do not wait for the main thread during initial reimport. 2025-03-12 09:18:39 +02:00
erodozer e48fea73e6 Support multi part extensions in import plugins 2025-02-18 13:19:05 -05:00
kobewi 65509ae4ff Improve UID file creation condition 2025-02-06 17:08:00 +01:00
Tareq Anuar 9014cdb596 Fix ResourceLoader.has_cached() and ResourceLoader.get_cached_ref() not handling UIDs. 2025-01-20 20:36:23 +08:00
Thaddeus Crews 0c0c45d695 Merge pull request #99494 from RandomShaper/rerefix_res_unrecog
ResourceLoader: Report appropriate error code when no suitable loader is found
2025-01-16 17:18:03 -06:00
kobewi 9ad34ecc3e Fix UID path remap 2025-01-11 22:15:59 +01:00
Thaddeus Crews 3c304ab7cc Merge pull request #96076 from AThousandShips/improve_null_check_core_drivers
[Core,Drivers] Improve use of `Ref.is_null/valid`
2024-12-23 11:14:58 -06:00
Rémi Verschelde d328c00ad3 Merge pull request #99667 from RandomShaper/res_load_verb
ResourceLoader: Print load message only when actually loading
2024-12-18 09:53:06 +01:00
Pedro J. Estébanez 6740823e40 ResourceLoader: Print load message only when actually loading 2024-12-18 09:36:16 +01:00
Thaddeus Crews a135a6478a Merge pull request #98383 from RandomShaper/deprecate_unsafe_th_rend
Deprecate the pointless unsafe threading model for rendering
2024-12-03 14:40:56 -06:00
Pedro J. Estébanez f79b972d0d ResourceLoader: Report appropriate error code when no suitable loader is found 2024-11-21 13:52:16 +01:00
Rémi Verschelde 219b14b905 Revert "ResourceLoader: Report error if resource type unrecognized"
This reverts commit fe21913ee8.
2024-11-20 16:50:30 +01:00
A Thousand Ships 68f638cf02 Use (r)find_char instead of (r)find for single characters 2024-11-17 10:02:18 +01:00
Pedro J. Estébanez a46ea9d064 Deprecate the pointless unsafe threading model for rendering 2024-11-14 10:43:29 +01:00
Thaddeus Crews c8ff788052 Merge pull request #96590 from reduz/list-directory
Provide a reliable way to see original resources in a directory
2024-11-11 14:18:28 -06:00
Juan d57846087b Universalize UID support in all resource types
Ensures all resource types support UIDs in a project.

This is required to fix:
* Scripts and many other resource types can't be referenced by UID and when refactored the references are lost.
* Path export properties can't use UID for unsupported types.
* Refactoring problems when files are moved outside the editor (this PR effectively fixes it).
* Editor properly refreshing paths if they changed externally while opened (as example, git update).
  This needs to be addressed in a subsequent PR, but this one effectively sets the prerequisites.

Resource types that do not support UID will get a .uid file appended to them (this includes .gd, .gdshader, .gdextension, etc. files).
2024-11-11 15:59:56 +01:00
Thaddeus Crews 155f94adc0 Merge pull request #97370 from RandomShaper/refix_rl_not_found
ResourceLoader: Report error if resource type unrecognized
2024-11-10 12:12:51 -06:00
Pedro J. Estébanez fe21913ee8 ResourceLoader: Report error if resource type unrecognized
Co-authored-by: Summersay415 <summersay415@gmail.com>
2024-11-04 09:49:37 +01:00