NullReferenceException: The BlobAssetReference is null.
at Unity.Entities.BlobAssetReferenceData.ThrowIfNull () [0x0000f] in .\Library\PackageCache\com.unity.entities\Unity.Entities\Blobs.cs:292
at Unity.Entities.BlobAssetReferenceData.ValidateNotNull () [0x00001] in .\Library\PackageCache\com.unity.entities\Unity.Entities\Blobs.cs:282
at Unity.Entities.BlobAssetReference`1[T].get_Value () [0x00001] in .\Library\PackageCache\com.unity.entities\Unity.Entities\Blobs.cs:448
at Unity.Physics.CompoundCollider.CreateInternal (Unity.Collections.NativeArray`1[T] children, System.UInt32 forceUniqueBlobID) [0x00022] in .\Packages\com.unity.physics\Unity.Physics\Collision\Colliders\CompoundCollider.cs:328
at Unity.Physics.Authoring.BuildCompoundCollidersBakingSystem+BlobCalculationJobHandleJob.Execute (Unity.Entities.Entity rootEntity, Unity.Physics.Authoring.PhysicsCompoundData& rootBaking, Unity.Physics.PhysicsCollider& rootCollider) [0x00207] in .\Packages\com.unity.physics\Unity.Physics.Hybrid\EntitiesBaking\BakingSystems\BuildCompoundCollidersBakingSystem.cs:192
at Unity.Physics.Authoring.BuildCompoundCollidersBakingSystem+BlobCalculationJobHandleJob.Execute (Unity.Entities.ArchetypeChunk& chunk, System.Int32 chunkIndexInQuery, System.Boolean useEnabledMask, Unity.Burst.Intrinsics.v128& chunkEnabledMask) [0x0007f] in .\JobEntityGenerator\Unity.Entities.SourceGen.JobEntityGenerator.JobEntityGenerator\Temp\GeneratedCode\Unity.Physics.Hybrid\BuildCompoundCollidersBakingSystem__JobEntity_307786259109.g.cs:33 ```
As discussed in [#1064581837055348857](/guild/489222168727519232/channel/1064581837055348857/) While not how I'm breaking it in practice, just opening a large subscene and clicking a mesh it's already broken for me, I finally found a reliable repo for this
duplicate some static mesh colliders a few times, then undo a couple of times
#[BUG] BlobAssetReference exception in Physics Baking
1 messages · Page 1 of 1 (latest)
FYI; I've definitely had this issue. Probably even right now, but I'm currently not working on my bigger scene. Started occurring for me at around the same time my project got completely corrupted some versions ago, and ended up having to recreate it all manually... (could be unrelated - but now this message gives me PTSD lol)
This was reported in IN-71257
Any update on this one? I have found forum posts describing (probably) the same issue back in 2023, but no fix yet
QA responded this was already know and tracked internally
I see that's good, hope they will fix it soon
1.3 should have a significant amount of physics changes
So hopefully fixed in the rework somewhere
Have there been official news regarding 1.3 already or just forum/chat discussions?
Either way it's good to hear
Was announced at gdc 1.3 would be the version where the physics performance updates would finally arrive
@real drift : Hi! Yes, we are aware of that one as you mentioned.
I suspect a race condition during compound collider baking but haven't been able to nail the root cause down yet.
We have a test scene internally which reliably reproduces this issue. It happens (among others) when you have a parent and child collider (in the simplest case both static, i.e., no rigid body or physics body component), and change the scale of the child to something non-uniform.
That checks out
Actually:
fungi_cluster03- Scale: 1 & no collider or anything except transformfungi01- Scale: 0.068 & has collidertop- Scale: 1 & has colllider
Any time I click on any one of them anything in my scene, the errors are spat out. Extremely annoying. Correction: It's a big-ish scene, and considering anything I do it spits these errors out, I don't know where it's coming from... but it's my third project with this issue through different entities versions.
Just to confirm, while being annoying, these errors should not have any impact on the actual playmode behavior unless I am mistaken. I think it's some baking system screw up on data that shouldn't even be there to begin with (hence the null blob asset).
I have this one on my radar now and will do some more investigation to see if I can figure out what's going on.
I will say, it's really bad for me error wise - i can't click anything without constant error spam
however, i have not noticed anything in particular breaking at runtime
every click of a gameobject in a subscene is 3+ errors
Yeah it sucks big time. I will look into this. Sorry about the mess.
But it's good to hear that things seem at least functional once the game is running. That's actually already a good hint into what might be going wrong here.
Alright, so I have a fix (I think). Maybe someone here could test it to see if it resolves the issues also in their project and doesn't cause any other problems on first sight.
I'll continue working on it to confirm that this is the right approach.
It's very simple. Just change the ChildrenGatheringJobHandleJob in BuildCompoundCollidersBakingSystem.cs to the following:
[WithOptions(EntityQueryOptions.IncludePrefab | EntityQueryOptions.IncludeDisabledEntities)]
partial struct ChildrenGatheringJobHandleJob : IJobEntity
{
[ReadOnly] public NativeParallelHashMap<Entity, int> rootEntitiesLookUp;
[ReadOnly] public BlobAssetComputationContext<int, Collider> blobComputationContext;
public NativeParallelMultiHashMap<Entity, ChildInstance>.ParallelWriter childrenPerRootWriter;
private void Execute(in PhysicsColliderBakedData blobBakingData)
{
// Check if we care about this entity
if (rootEntitiesLookUp.ContainsKey(blobBakingData.BodyEntity))
{
>>>> var blobFound = blobComputationContext.GetBlobAsset(blobBakingData.Hash, out var blobAsset);
>>>> if (!blobFound)
>>>> {
>>>> return;
>>>> }
// else:
childrenPerRootWriter.Add(blobBakingData.BodyEntity, new ChildInstance()
{
Hash = blobBakingData.Hash,
IsLeaf = blobBakingData.IsLeafEntityBody,
Child = new CompoundCollider.ColliderBlobInstance
{
Collider = blobAsset,
CompoundFromChild = blobBakingData.BodyFromShape,
Entity = blobBakingData.ChildEntity,
}
});
}
}
}
I marked the new lines with >>>> above
Will have a look when I get home from gym thanks
Brilliant. Thank you!
What's happening in a nutshell seems that the compound baking system is run without the base collider baking system (which produces the children) and then can't find the colliders here (since they were not created). So, simply doing nothing does the job as the colliders have already been baked. I am not entirely sure yet why this is happening, but might have something to do with triggering of the baking system in cases where no actual relevant change occurred (such as just clicking on the entity).
Hmmm... this might only fix the issue when completely rebaking from scratch (close / re-open subscene). But incremental baking is not working seemingly, as it now produces compound colliders with missing children.
Getting close though!
I'll hold off on testing then 🙂
Yeah I get now what is happening.
Essentially, the code above would get rid of the error, leading to the same behavior you have today. That would be a workaround for the annoying errors you have right now, but the actual problem is more complex.
In a nutshell, you don't get any issues in-game because full baking works fine, but incremental baking (which is triggered when moving things around or even just selecting things) doesn't work and throws these errors. The patch above just prevents the error but not the consequence of the bug, which makes incremental baking fail. So you walk away with missing colliders in compounds during incremental baking with open sub-scenes.
Just closing and re-opening the subscene fixes this.