7320 Commits

Author SHA1 Message Date
133780f530 Core: Sidestep GCC false-positives
(cherry picked from commit acdb8667b5)

Adds some more fixes for 4.5 and earlier.

Co-authored-by: Rémi Verschelde <rverschelde@gmail.com>
2025-10-28 21:53:35 +01:00
1a1be139e2 Revert "Initialize Quaternion variant with identity"
This reverts commit 379792802f.

This may be correct, but it breaks compatibility so it shouldn't be
cherry-picked to stable branches.
2025-10-08 02:35:19 +02:00
379792802f Initialize Quaternion variant with identity
(cherry picked from commit c0e36dc493)
2025-09-30 11:50:31 -05:00
e6522a4e1c CI: Sync configuration with 4.4 branch
Includes cherry-picks of warning fixes from a44f691fc7
and 8d1462c748.
2025-04-24 23:55:20 +02:00
2b8acb2015 GDExtension: Fix method binds not saying if they are varargs
(cherry picked from commit 2599df3b8a)
2025-02-07 14:00:02 +01:00
758a42196c Merge pull request #98964 from RandomShaper/fix_classdb_deadlock_4.3
[4.3] Fix deadlocks related to ClassDB queries about global classes
2024-11-15 19:08:18 +01:00
f89d1e0376 Merge pull request #96606 from RandomShaper/res_loader_cherrypicks_4.3
[4.3] Cherry-picks related to `ResourceLoader`
2024-11-15 19:08:11 +01:00
a5f6e49862 Fix deadlocks related to ClassDB queries about global classes
`ClassDB::can_instantiate()` and other reflection methods deadlock if the type is an script global class, when such script indirectly uses a not-yet-registered class. The reason is the `ClassDB` read lock is still held when invoking the `ResourceLoader` to load the class script, which may in turn need to lock for writing (for the class registration).

In particular, this happens with some types related to animation tree, that aren't registered at engine startup, but can happen with others, especially ones from the user. Registration statements are also added for the animation-related types that were lacking them.
2024-11-08 18:17:53 +01:00
a0c17446ad ResourceLoader: Report error if resource type unrecognized
Co-authored-by: Summersay415 <summersay415@gmail.com>

(cherry picked from commit fe21913ee8)
2024-11-06 14:31:27 +01:00
251237d2b4 ResourceLoader: Fixup resource changed feature
This is a complement to: https://github.com/godotengine/godot/pull/96593

(cherry picked from commit 97197ff5e9)
2024-09-23 18:55:54 +02:00
ea651a150b ResourceLoader: Add last resort life-time insurance for tokens
(cherry picked from commit ccd470d33c)
2024-09-23 18:55:54 +02:00
f806cfb72b ResourceLoader: Add thread-aware resource changed mechanism
(cherry picked from commit 0f3ee922e07fd4d16d9ef6dac150beb9c84ac527)
2024-09-23 18:55:54 +02:00
cd32705508 ResourceLoader: Simplify handling of unregistered tasks
(cherry picked from commit c450f4d667)
2024-09-23 18:55:53 +02:00
f2d0f66eca Fix ResourceLoader is not verbosely printing a resource path on loading
(cherry picked from commit bfb5570c03)
2024-09-23 18:55:53 +02:00
2c612abdd1 WorkerThreadPool: Fix end-of-yield logic potentially leading to deadlocks
(cherry picked from commit 5dade0e08b)
2024-09-17 09:55:10 +02:00
018f8be3d5 Object: Let debug lock handle callee destruction within call chain gracefully
Co-authored-by: lawnjelly <lawnjelly@gmail.com>
(cherry picked from commit 10e2318bde)
2024-09-17 08:57:45 +02:00
d92f9017c6 Fix gamepad triggers not working on web exports
Fixes #81758

DisplayServerWeb::process_joypads handles buttons 6 and 7 of the
HTML5 Standard Gamepad as a special case by doing:
`input->joy_axis(idx, (JoyAxis)b, s_btns[b]);`

This doesn't work because there is no JoyAxis 6 or 7 in the enum

To fix this we use JoyAxis::TRIGGER_LEFT and TRIGGER_RIGHT for button 6
and 7

However since we are now lying to input->joy_axis we also need to lie in
the mappings for the standard gamepad in godotcontrollersdb.txt,
otherwise input->joy_axis will try to find a mapping to axis 4(LT) and
axis 5(RT) that's not defined.

Therefore we set lefttrigger to +a4 and righttrigger to +a5 in the
mapping, to match what we are actually sending.

A cleaner, and more involved fix to this would be modifying
input->joy_button so that it can handle analog buttons and map them to
axes preserving their value instead of converting to boolean

(cherry picked from commit 9dd372f316)
2024-09-17 08:57:45 +02:00
1d790deedb Fix parsing of 4. in Expression
(cherry picked from commit ee9cea521d)
2024-09-17 08:57:44 +02:00
6ab9ec33f2 Add modf function and fix snap behavior
Fixes #96159

(cherry picked from commit fcc8518bce)
2024-09-17 08:57:41 +02:00
4acc73dbfa Make sure huf_decompress is only applied to 64-bit x86.
(cherry picked from commit 6b13236956)
2024-09-17 08:57:41 +02:00
c4351c8d98 Fix RandomPCG::rand_weighted incorrectly returning -1
(cherry picked from commit ab13513403)
2024-09-16 17:23:44 +02:00
df522db6f0 Fix virtual binding for ScriptLanguageExtension::_reload_scripts
(cherry picked from commit d65ea6fb9c)
2024-09-16 17:06:44 +02:00
5676d398e0 Avoid potential crash on signal disconnection
(cherry picked from commit 32b7f835d8)
2024-09-16 17:06:19 +02:00
bf5907b724 StringName: Use inline static field definitions
Before this change StringName used regular static field
definitions for its mutex, _table, configured and debug_stringname
fields.

Since in the general case the ordering of the static variable and field
initialization and destruction is undefined, it was possible that
the destruction of StringName's static fields happened prior to
the destruction of statically allocated StringName instances.

By changing the static field definitions to inline in string_name.h,
the C++17 standard guarantees the correct initialization and destruction
ordering.

(cherry picked from commit 723878bbab)
2024-09-16 17:05:50 +02:00
6e78eec37f Fix reload of GDExtension libraries in framework package on macos
`GDExtension::open_library` has a check in it to see if the library was loaded
from a temp file, and if it was to restore the original name as that is the one
we actually care about. This check is breaking extension reloading on Mac when
the library path is to a framework folder, as the file inside the framework
will not generally be the same name as the folder.

This check also shouldn't be necessary even on Windows, which is the only
platform that uses `generate_temp_files`, since disposal of the created temp
file is handled within `OS_Windows::open_dynamic_library`, and
`GDExtension::open_library` (which is the only function to call
`open_dynamic_library` with a `p_data` argument) only cares about the original
library file path and has to do extra work to remove the name of the temp file.
Instead, I have removed that check and set `OS_Windows::open_dynamic_library`
to return the name of the original file and not the name of the copy.

This fixes GDExtension reloading on macOS. I do not have a Windows machine
available to test that it still works properly on Windows, so someone should
check that before merging this.

(cherry picked from commit f44d6a235f)
2024-09-16 16:55:39 +02:00
562e583872 Fix split_floats behavior when spaces are used as separators
(cherry picked from commit f483c3aafa)
2024-09-16 16:40:48 +02:00
fac12603ef [.NET] Move search in files extension list definition to be after Scene level module init.
(cherry picked from commit 69d52ed081)
2024-09-16 16:38:08 +02:00
98e77113a2 ResourceLoader: Handle another case of user tokens
(cherry picked from commit 0441c67de6)
2024-09-05 13:30:56 +02:00
1fd87e8747 Change warning muting so it affects all levels, but locally
(cherry picked from commit 9cbc3f1419)
2024-09-05 13:30:25 +02:00
fe2e862e2e ResourceLoader: Use better error handling for possible engine bugs
(cherry picked from commit 31a9e10ddb)
2024-09-05 13:30:09 +02:00
c75c50ecac WorkerThreadPool (plus friends): Overhaul unlock allowance zones
This fixes a rare but possible deadlock, maybe due to undefined behavior. The new implementation is safer, at the cost of some added boilerplate.

(cherry picked from commit f4d76853b9)
2024-09-05 13:29:38 +02:00
b3e46a913d ResourceLoader: Fix edge cases in the management of user tokens
1. Make handling of user tokens atomic:
   Loads started with the external-facing API used to perform a two-step setup of the user token. Between both, the mutex was unlocked without its reference count having been increased. A non-user-initiated load could therefore destroy the load task when it unreferenced the token.
   Those stages now happen atomically so in the one hand, the described race condition can't happen so the load task life insurance doesn't have a gap anymore and, on the other hand, the ugliness that the call to load could return `ERR_BUSY` if happening while other thread was between both steps is gone.
   The code has been refactored so the user token concerns are still outside the inner load start function, which is agnostic to that for a cleaner implementation.
2. Clear ambiguity between load operations running on `WorkerThreadPool`:
   The two cases are: single-loaded thread directly started by a user pool task and a load started by the system as part of a multi-threaded load.
   Since ensuring all the code dealing with this distinction would make it very complex, and error-prone, a different measure is applied instead: just take one of the cases out of the dicotomy. We now ensure every load happening on a pool thread has been initiated by the system.
   The way of achieving that is that a single-threaded user-started load initiated from a pool thread, is run as another task.

(cherry picked from commit df23858488)
2024-09-05 13:29:38 +02:00
8a78f5c323 ResourceLoader: Optimize remap check by deferring until a non-mutex zone
(cherry picked from commit 5c970db2e4)
2024-09-05 13:29:38 +02:00
ea28ac510d ResourceLoader: Enhance deadlock prevention
Benefits:
- Simpler code. The main load function is renamed so it's apparent that it's not just a thread entry point anymore.
- Cache and thread modes of the original task are honored. A beautiful consequence of this is that, unlike formerly, re-issued loads can use the resource cache, which makes this mechanism much more performant.
- The newly added getter for caller task id in WorkerThreadPool allows to remove the custom tracking of that in ResourceLoader.
- The check to replace a cached resource and the replacement itself happen atomically. That fixes deadlock prevention leading to multiple resource instances of the same one on disk. As a side effect, it also makes the regular check for replace load mode more robust.

(cherry picked from commit 28619e26cf)
2024-09-05 13:29:38 +02:00
ece392538e ResourceLoader: Properly push & pop TLS state on recursive load tasks
(cherry picked from commit bd0959ebdd)
2024-09-05 13:29:38 +02:00
257dd2f9e5 Fix use condition_variable after free
(cherry picked from commit 2ff6594928)
2024-09-05 13:28:58 +02:00
1c4849b162 ResourceLoader: Revert workaround resource loading crashes due to buggy TLS
This reverts commit 41c0785636.

(cherry picked from commit e9407d4877)
2024-09-05 13:24:16 +02:00
17ea4b405a ResourceLoader: Fix error on querying progress for uncached loads 2024-08-13 12:41:11 +02:00
613600fa89 Fix use-after-free in FileAccess::exists 2024-08-09 03:33:51 +02:00
f5bb14dceb [ResourceLoader] Add check to prevent double free crashes. 2024-08-06 08:31:03 +03:00
1ed723bd19 Fix global class cache file not present when no class name 2024-07-31 16:57:25 -04:00
372b3f8437 Merge pull request #94910 from RandomShaper/res_load_unlocked
ResourceLoader: Let resource setup late steps invoke loading in turn
2024-07-31 11:37:41 +02:00
5640e8adc9 ResourceLoader: Let resource setup late steps invoke loading in turn 2024-07-29 18:13:37 +02:00
c9f4436073 Fix use-after-free in WorkerThreadPool 2024-07-29 14:26:48 +02:00
8f3e2c96eb [Core] Fix Variant::construct of Object
Variant type was not updated correctly causing leaks in ref-counted
2024-07-25 12:25:29 +02:00
25f78a5eb6 Replace .NET detection code with ClassDB::class_exists("CSharpScript"). 2024-07-23 23:46:14 +03:00
0ed45629fd Support 64-bit image sizes for VRAM compression 2024-07-21 21:06:14 +02:00
0445ccf428 Fix Image CowData crash when baking large lightmaps
This switches to 64-bit integers in select locations of the Image
class, so that image resolutions of 16384×16384 (used by
lightmap texture arrays) can be used properly. Values that are larger
should also work.

VRAM compression is also supported, although most VRAM-compressed
formats are limited to individual slices of 16384×16384. WebP
is limited to 16383×16383 due to format limitations.
2024-07-19 16:04:30 +02:00
293c0f7646 Merge pull request #94526 from RandomShaper/wtp_rl_prize_prequel
Batch of fixes for WorkerThreadPool and ResourceLoader (safe set)
2024-07-19 11:11:03 +02:00
28a7a95531 ResourceLoader: Fix sync issues with error reporting
This is about not letting the resource format loader set the error code directly on the task anymore. Instead, it's stored locally and assigned only when it is right to do so.

Otherwise, other tasks may see an error code in the current one before it's state having transitioned to errored. While this, besides the technically true data race, may not be a problem in practice, it causes surprising situations during debugging as it breaks assumptions.
2024-07-19 10:00:41 +02:00