Have encountered a case where the physics authoring of colliders ended up with two diverging BlobAsset-hashes, where both of the hashes resulted in the identical hash for the in the BlobAssetStore, breaking conversion. I dug in the packages and logged some:
This is the full callstack:
ArgumentException: There is already a BlobAsset with the hash: c47f879e57e102f4292a13899e2d602f in the Store or the Computed list. You should add a newly computed BlobAsset only once.
at Unity.Entities.BlobAssetComputationContext`2[TS,TB].AddComputedBlobAsset (Unity.Entities.Hash128 hash, Unity.Entities.BlobAssetReference`1[T] blob) [0x00050] in C:\SLS\ProjectM_2\Game\Packages\com.unity.entities@0.17.0-preview.41\Unity.Entities.Hybrid\GameObjectConversion\BlobAssetComputationContext.cs:116
at Unity.Physics.Authoring.BaseShapeConversionSystem`1[T].OnUpdate () [0x002af] in C:\SLS\ProjectM_2\Game\Packages\com.unity.physics@0.5.1-preview.2\Unity.Physics.Hybrid\Conversion\BaseShapeConversionSystem.cs:253
at Unity.Entities.ComponentSystem.Update () [0x0005f] in C:\SLS\ProjectM_2\Game\Packages\com.unity.entities@0.17.0-preview.41\Unity.Entities\ComponentSystem.cs:114
at Unity.Entities.ComponentSystemGroup.UpdateAllSystems () [0x000c7] in C:\SLS\ProjectM_2\Game\Packages\com.unity.entities@0.17.0-preview.41\Unity.Entities\ComponentSystemGroup.cs:472
The log is however misleading, as I eventually found out that it’s actually two different physics hashes that gets combined with a type, and then becomes the same hash which caused a collision in the BlobAssetStore. I added these logs where the issue occurs:
In the screenshot above, BlobAssetStore.TryAdd is called. The next screenshot is from the BlobAssetStore.TryAdd method, where I add a second log that catches the failure.
The result showed that two different physics hashes ended up becoming the same BlobAssetStore hash, resulting in a hash-collision. See the logs below:
// d9a37f4c0c94eeb5fcef25ac00bdb738 is a hash generated in the physics conversion. In TryAdd it's combined with the generic collider type and becomes d62e0153d62e0153d62e0153d62e0153
BaseShapeConversionSystem Hash: d9a37f4c0c94eeb5fcef25ac00bdb738
BlobAssetStore.TryAdd<Unity.Physics.Collider>
Hash: d9a37f4c0c94eeb5fcef25ac00bdb738, TypedHash: d62e0153d62e0153d62e0153d62e0153
// c47f879e57e102f4292a13899e2d602f is a hash generated in the physics conversion. In TryAdd it's combined with the generic collider type and also becomes d62e0153d62e0153d62e0153d62e0153, and therefore collides with the different hash above!
BaseShapeConversionSystem Hash: c47f879e57e102f4292a13899e2d602f
BlobAssetStore.TryAdd<Unity.Physics.Collider>
Hash: c47f879e57e102f4292a13899e2d602f, TypedHash: d62e0153d62e0153d62e0153d62e0153
Both of these hash registrations originate from BaseShapeConversionSystem.cs:253. Note that the physics hashes are the same, but the TypedHash that is registered in the BlobAssetStore becomes the same hash after the ComputeKeyAndTypeHash function.
I can unfortunately not share the massive project, and can’t reproduce it in a smaller scene. I can remove the issue by modifying one of the prefabs a little, which results in a different hash.
One can quite likely reproduce this by just taking the hashes from the logs and running them through the BlobAssetStore.TryAdd, which will result in the collision.