-
-
Notifications
You must be signed in to change notification settings - Fork 26
Open
Description
Unity.Collections@2.2+ has an unresolved bug, as you can read here:
...
All containers allocated withAllocator.Tempon the same thread use a sharedAtomicSafetyHandleinstance rather than each having their own.
This can lead to safety check error throws like this:
InvalidOperationException: The Unity.Collections.NativeList`1[System.Int32]
has been declared as [WriteOnly] in the job, but you are reading from it.when using UnsafeTriangulator with Allocator.Temp. Consider the following example:
using var positions = new NativeList<double2>(Allocator.Temp);
positions.Add(...);
new UnsafeTriangulator().Triangulate(input: new(){ Positions = positions.AsArray() }, ...);Unfortunately, due to AsArray() call, which should be safe, the above example will trigger an exception from the safety handle. Currently the only way to resolve this issue is:
- Disable safety checks, or
- Call
ToArray(Allocator)
I recommend the second option, calling ToArray, unless you are certain about what you are doing.
using var positions = new NativeList<double2>(Allocator.Temp);
positions.Add(...);
using var p = postions.ToArray(Allocator.Temp);
new UnsafeTriangulator().Triangulate(input: new(){ Positions = p }, ...);Metadata
Metadata
Assignees
Labels
No labels