|
1 | 1 | # Known Issues
|
2 | 2 |
|
3 |
| -Currently, there are no known issues. If you found a bug, please report it by opening a **[GitHub issue]**. |
| 3 | +Below you can find current known issues. If you found a bug, please report it by opening a **[GitHub issue]**. |
| 4 | + |
| 5 | +### [#333]: AtomicSafetyHandle may throw InvalidOperationException |
| 6 | + |
| 7 | +`[email protected]+` has an unresolved bug, as you can read [here ](https://docs.unity3d.com/Packages/[email protected]/manual/issues.html): |
| 8 | + |
| 9 | +> [!QUOTE] |
| 10 | +> All containers allocated with `Allocator.Temp` on the same thread use a shared `AtomicSafetyHandle` instance rather than each having their own. |
| 11 | +
|
| 12 | +This can lead to safety check error throws like this: |
| 13 | + |
| 14 | +```txt |
| 15 | +InvalidOperationException: The Unity.Collections.NativeList`1[System.Int32] |
| 16 | +has been declared as [WriteOnly] in the job, but you are reading from it. |
| 17 | +``` |
| 18 | + |
| 19 | +when using [`UnsafeTriangulator`][unsafe-triangulator] with `Allocator.Temp`. Consider the following example: |
| 20 | + |
| 21 | +```csharp |
| 22 | +using var positions = new NativeList<double2>(Allocator.Temp); |
| 23 | +positions.Add(...); |
| 24 | + |
| 25 | +new UnsafeTriangulator().Triangulate(input: new(){ Positions = positions.AsArray() }, ...); |
| 26 | +``` |
| 27 | + |
| 28 | +Unfortunately, due to `AsArray()` call, which should be safe, the above example will trigger an exception from the safety handle. |
| 29 | +Currently the only way to resolve this issue is: |
| 30 | + |
| 31 | +- Disable safety checks, or |
| 32 | +- Call [`ToArray(Allocator)`][to-array] |
| 33 | + |
| 34 | +I recommend the second option, calling [ToArray][to-array], unless you are certain about what you are doing. |
| 35 | + |
| 36 | +```csharp |
| 37 | +using var positions = new NativeList<double2>(Allocator.Temp); |
| 38 | +positions.Add(...); |
| 39 | + |
| 40 | +using var p = postions.ToArray(Allocator.Temp); |
| 41 | +new UnsafeTriangulator().Triangulate(input: new(){ Positions = p }, ...); |
| 42 | +``` |
4 | 43 |
|
5 | 44 | [GitHub issue]: https://github.com/andywiecko/BurstTriangulator/issues/new?template=Blank+issue
|
| 45 | +[#333]: https://github.com/andywiecko/BurstTriangulator/issues/333 |
| 46 | +[unsafe-triangulator]: xref:andywiecko.BurstTriangulator.LowLevel.Unsafe.UnsafeTriangulator |
| 47 | +[to-array]: https://docs.unity3d.com/Packages/[email protected]/api/Unity.Collections.NativeList-1.html#Unity_Collections_NativeList_1_ToArray_Unity_Collections_AllocatorManager_AllocatorHandle_ |
6 | 48 |
|
7 | 49 | ---
|
8 | 50 |
|
|
0 commit comments