Commit Graph

1875 Commits

Author SHA1 Message Date
HP van Braam b88a62f805 Fix ResourceLoader deadlocks
This fixes several issues:
 * There was a bug in the cycle detection. It was possible for the cycle
   detection to fail because the current thread isn't in the list. Fix
   this by just seeing if any of the next threads were already in the
   cycle.
 * By way of an optimization the thread_waiting_on bookkeeping was done
   under the same thread_load_mutex as the cycle detection. But there is
   also an early exit after yields. If we exit through the yield the
   thread_waiting_on entry is stale and can cause other threads to fail
   to do cycle detection.
 * When multiple threads end up finishing a resource simultaneously
   anyway, probably through cycle detection, there's a small chance that
   the original thread finished more-or-less at the same time if the
   original thing blocking load completed. We solve this now by letting
   only one of the threads do the initial registration.
2026-06-08 04:57:26 +02:00
Thaddeus Crews 93d16cc84c Merge pull request #119757 from hpvb/fix-threaded-loader-again
Fix `ResourceLoader::load_threaded_get()` deadlocks
2026-05-29 10:47:41 -05:00
Thaddeus Crews bc209b4f1d Merge pull request #119598 from nikitalita/ensure-bptc-textures
Ensure that BPTC LayeredTexture images get compressed with same signedness
2026-05-29 10:47:39 -05:00
HP van Braam 374102cfbe Fix ResourceLoader::load_threaded_get() deadlocks
This fixes several issues in ResourceLoader
 * When waiting on resources being loaded on the main thread it is
   possible that the resource was waiting on the message queue. Flush
   the message queue in this situation. This was an existing bug.
 * When re-starting a load for deadlock-prevention reasons, and this
   type of resource has nested resources and uses resource changed
   connections we end up with references to resourcese being deleted
   as duplicates in the dependent task. We now keep a reference to these
   resources for the duration of the dependent load task. This closes
   the race but does not entirely eliminate it during intial import.
   This is an existing bug seemingly specific to TileSetSource but there
   might be others.
 * When threads are waiting during teardown we ended up deadlocking
   because the waiting thread would never end up completing. This is a
   bug introduced by f63ab5f
 * When a thread loading a resource ends up calling back into the
   WorkerThreadPool to wait cooperatively it expects that other threads
   complete, or new requests are made, so that work moves forward. If
   all OTHER threads end up blocked by the WorkerThreadPool waiting
   thread then no forward progress can be made anymore. We now solve
   this problem by yielding whenever we are blocked by another task. We
   wake up each every task whenever any progress is made to see if
   further progress can be made. This is a bug introduced by f63ab5f
 * When dependencies get introduced while loading it is possible to form
   a dependency cycle. Normally this isn't a problem but when all
   threads are already waiting when the cycle is introduced no forward
   progress can be made anymore. We now break such cycles. This is a bug
   introduced by f63ab5f
2026-05-29 16:12:02 +02:00
nikitalita 3a49491ff0 Ensure that BPTC LayeredTexture images get compressed with same signedness 2026-05-19 23:04:00 -07:00
Fredia Huya-Kouadio 948032c89c [Android] Fix the use of --main-pack 2026-05-15 23:03:54 -07:00
Manpreet Singh 9caa8180e9 fix: double ref 2026-05-11 08:08:21 +05:30
Thaddeus Crews 599f2bd5b9 Merge pull request #118824 from hpvb/fix-118085
Fix a race in `ResourceLoader::load_threaded_request()`
2026-05-06 14:56:33 -05:00
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
Dimitri Sukhankin e07737e0ba Add better error message when trying to decompress ZSTD with decompress_dynamic 2026-05-04 22:01:06 +04:00
Mikael Hermansson 6103c0bc42 Add error to error messages in FileAccessPack 2026-04-29 18:43:04 +02:00
bucket 9e674ece11 fix shortened ipv6 parsing 2026-04-21 15:18:46 +02:00
Thaddeus Crews f1edeb4acc Merge pull request #118527 from KoBeWi/ignore_error_problem_fixed
Don't print UID errors when cache is not initialized
2026-04-18 07:28:36 -05:00
Kaleb Reid f973e3e346 Remove p_ and add r_ prefixes to argument names 2026-04-15 13:47:15 -07:00
Thaddeus Crews 8d80b74623 Merge pull request #118514 from bruvzg/be
Remove unused and broken big endian support code.
2026-04-13 11:46:02 -05:00
Thaddeus Crews 5adbdac72b Merge pull request #117025 from brandonhare/fix-imported-resource-script-class
Fix quick load for resources imported by editor import plugins
2026-04-13 11:45:57 -05:00
kobewi 14568256a3 Don't print UID errors when cache is not initialized 2026-04-13 18:43:58 +02:00
Pāvels Nadtočajevs cdd274199e Remove unused and broken big endian support code. 2026-04-13 12:41:46 +03:00
Thaddeus Crews 803c6df71a Merge pull request #117800 from allenwp/exr-clipping
Add support for saving HDR screenshots to `Image.save_exr` functions.
2026-04-01 18:10:16 -05:00
Thaddeus Crews 656a268688 Merge pull request #117010 from bruvzg/voll_name_win
[Windows] Show drive names in file dialog.
2026-03-30 13:35:34 -05:00
Allen Pestaluky 2b9cea5f87 Add support for saving HDR screenshots to Image.save_exr functions. 2026-03-27 11:20:06 -04:00
StarryWorm 9ffc7d9f99 Split CacheMode from ResourceFormatLoader 2026-03-27 07:16:20 -04:00
StarryWorm d610492fef Separate ResourceFormat* methods from main classes 2026-03-27 07:16:20 -04:00
Michael Alexsander c766fb1ce8 Create a proper editor for MeshLibrary 2026-03-21 11:16:26 -03:00
Lukas Tenbrink 05c33acbb1 Make memnew(RefCounted) return Ref, to force callers to take ownership of it through a reference. 2026-03-18 20:34:08 +01:00
Rémi Verschelde 4336184ea4 Style: Tweak ordering of thirdparty includes with angle brackets 2026-03-18 10:41:59 +01:00
Rémi Verschelde 98868393cc Style: Enforce #include validation hook 2026-03-18 10:41:59 +01:00
Rémi Verschelde e33e98a26f Style: Apply clang-format grouping rules 2026-03-17 20:11:01 +01:00
passivestar 9d68328a6d Filter out metadata of excluded files on export 2026-03-16 17:48:44 +04:00
Lukas Tenbrink efcc97ee8a Move enum registration from ClassDB / ClassInfo to GDType.
Create caches across supertypes for faster lookup.
2026-03-13 19:20:30 +01:00
Pāvels Nadtočajevs fdda64e59e Handle UID path in packs. 2026-03-11 18:46:53 +02:00
Rémi Verschelde e015e8bde4 Remove unused includes in core with clangd-tidy 2026-03-11 06:41:36 +01:00
Yyf2333 282e4544b0 Split VariantCaster from binder_common.h 2026-03-10 17:59:33 +08:00
Rémi Verschelde 2dd1f4ef60 Decouple node.h from scene_tree.h, minimize its other includes 2026-03-05 13:54:46 +01:00
StarryWorm 3cb2d376f8 Get rid of all unnecessary class_db.h includers 2026-03-04 17:40:05 -05: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
Rémi Verschelde f332faf46b Explicitly include core/os/os.h where used 2026-03-04 09:54:10 +01:00
Pāvels Nadtočajevs c46414c44d [Windows] Show drive names in file dialog. 2026-03-03 15:35:58 +02:00
brandonhare d7955e56d7 Fix resource script class for imported resources 2026-03-04 00:33:36 +11:00
StarryWorm 357fa00a4a rm class_db.h from resource.h 2026-02-27 19:08:29 -05:00
Thaddeus Crews abdde1b69d Core: Remove class_db.h include from ref_counted.h 2026-02-26 18:14:23 -06: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
Mikael Hermansson f21053e4ef Allow providing Android APK/AAB as base packs for patch PCKs 2026-02-23 14:26:52 +01:00
Lukas Tenbrink a6adb12240 Remove message_queue.h include from object.h. 2026-02-20 00:27:41 +01:00
Lukas Tenbrink 0ea5ece984 Move binary math functions to Math namespace in math_funcs_binary header. 2026-02-17 12:24:35 +01:00
Thaddeus Crews 1e12317895 Merge pull request #115646 from Ivorforce/list-explicit-copy
Change `List` copy constructor from implicit to explicit.
2026-02-16 15:02:34 -06:00
Thaddeus Crews b151a2d966 Merge pull request #115396 from DeeJayLSP/faster-uid-path-2
Prevent unnecessary memory allocations when reading UID cache
2026-02-16 15:02:31 -06:00
Thaddeus Crews bf95b62586 Merge pull request #115883 from Gurvan/master
Make JSON.stringify use compact representation for empty `Dictionary`
2026-02-13 07:40:28 -06:00