-
-
Notifications
You must be signed in to change notification settings - Fork 21.1k
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
C++ A deep copy (COW) of TypedArray is sometimes incorrectly made #89191
Comments
… modified correctly (godotengine/godot#89191)
What happens if you do: TypedArray<int> typedArrayCopy;
typedArrayCopy = untypedArray; If that does work then it's a bug and the issue is here: godot/core/variant/typed_array.h Lines 48 to 53 in 39f9060
I'll test and look later and if that is the problem I can fix the relevant code |
Using the code you provided instead does not perform a deep copy! |
Then I'll write some fixes for this, it should work, will see! |
Tested versions
Reproducible on 7d2ca2d and also on 4.2-stable 46dc277
System information
Godot v4.3.dev (7d2ca2d) - Windows 10.0.22621 - Vulkan (Mobile) - dedicated NVIDIA GeForce GTX 980 Ti (NVIDIA; 31.0.15.3598) - 13th Gen Intel(R) Core(TM) i7-13700K (24 Threads)
Issue description
When casting from
TypedArray
toArray
and back again, a deep copy (COW) will be performed. This seems to also affect nestedArray
occurrences, thus making it impossible(?) to extract a reference to aTypedArray
as aTypedArray
from anArray
orTypedArray
.Steps to reproduce
A simple example is the following. Even though
untypedArray
in this example knows that it is, internally, a typed array, it will still perform a COW deep copy.This behaviour arguably becomes more problematic when dealing with nested
Array
scenarios:This second example demonstrates that it is difficult (and maybe impossible?) to extract a
TypedArray
from anArray
(orTypedArray
) and put it back into aTypedArray
container without doing a COW that may not be desirable.GDScript
This behaviour does not affect GDScript. In GDScript, I can do the following and a COW deep copy will never occur:
Minimal reproduction project (MRP)
(See above code snippets. Put them in something that you know will be called in the engine like
register_core_singletons()
ofregister_core_types.cpp
)The text was updated successfully, but these errors were encountered: