Search Issue Tracker
By Design
Votes
1
Found in [Package]
1.3.X - Entities
Issue ID
ECSB-1291
Regression
No
ArgumentException error when using EntityCommandBuffer in Play mode
Reproduction steps:
1. Open the attached project "Repro"
2. Open “Assets/Scenes/SampleScene.unity“ scene
3. Enter the Play mode and wait a few minutes
Expected result: The Play mode continues
Actual result: “ArgumentException: System.ArgumentException: System.String Unity.Entities.EntityComponentStore::AppendRemovedComponentRecordError(Unity.Entities.Entity,Unity.Entities.ComponentType)” exception is thrown, Objects in the scene stop spawning
Reproducible with: 1.2.3 (2022.3.40f1, 6000.0.13f1)
Couldn’t test with: 1.0.16 (2023.3.0a19) “Burst internal compiler error: Burst.Compiler.IL.Aot.AotLinkerException:“
Reproducible on: Windows 11
Not reproducible on: No other environment tested
Note: Reporter said it also crashes after getting the errors but this could not be locally reproduced
First few lines of stack trace:
{noformat}0x00007FF80190C9E9 (lib_burst_generated) burst.initialize.statics.d75218db5dfdcc623eed8c53e4ab4870_avx2
0x00007FF80190C8F0 (lib_burst_generated) burst.initialize.statics.d75218db5dfdcc623eed8c53e4ab4870_avx2
0x00007FF8019B4927 (lib_burst_generated) d75218db5dfdcc623eed8c53e4ab4870{noformat}
Add comment
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- Certain textures are incorrectly marked in the render pass list when observed through Render Graph Viewer
- "Assertion failed on expression" error occurs when multiple Animation Components are instantiated after changing the Culling Type
- MacOS persistentDataPath uses old path when built compared to Editor Play mode
- Crash on RaiseException when entering Play Mode in a specific project
- Debug Console does not reappear when disabling and re-enabling Debug.developerConsoleEnabled
Resolution Note:
This error occurs due to the fact that the sort key for all command entries in the ECB is 0. The sort key is used to determine the order in which the commands are played back. As the sort key is the same for all commands, there is no deterministic order in which the commands are played back.
This means that there is a chance that a SetComponent command added by the second job will be executed before the corresponding AddComponent command in the first job.
The error can be avoided by either explicitly making the sort key for the second job larger than the sort key of the first job, e.g. 0 and 1.
Or by using two ECBs that have both been created using the same system. This makes it so that the ECBs created via the system are played back in the same order they were created.
Note that adding a component and setting it's data can be done in one operation using AddComponentData. This is slightly faster than doing it in two separate operations.