Non matching Profiler.EndSample in EntityPatcherBlob.cs

I think in EntityPatcherBlob.cs there are cases when editing live sub scenes the profile end marker is never hit. I didnt dig too deep into this
s_ApplyBlobAssetChangesProfilerMarker.End()

public static unsafe partial class EntityPatcher
{
    static void ApplyBlobAssetChanges(
        EntityManager entityManager,
        NativeArray<EntityGuid> packedEntityGuids,
        NativeMultiHashMap<int, Entity> packedEntities,
        NativeArray<ComponentType> packedTypes,
        NativeArray<BlobAssetChange> createdBlobAssets,
        NativeArray<byte> createdBlobAssetData,
        NativeArray<ulong> destroyedBlobAssets,
        NativeArray<BlobAssetReferenceChange> blobAssetReferenceChanges)
    {
        if (createdBlobAssets.Length == 0 && blobAssetReferenceChanges.Length == 0)
            return;
        s_ApplyBlobAssetChangesProfilerMarker.Begin();
    
       //......
       s_ApplyBlobAssetChangesProfilerMarker.End();
       // ...

Error

Non matching Profiler.EndSample (BeginSample and EndSample count must match): EntityPatcher.ApplyBlobAssetChanges
Previous 5 samples:
EntityPatcher.ApplyBlobAssetChanges
EntityPatcher.ApplyEntityPatches
GC.Alloc
DisposeSentinel.Create
EntityPatcher.ApplyLinkedEntityGroupAdditions
In the scope:
EntityPatcher.ApplyChangeSet
Default World Unity.Scenes.Editor.EditorSubSceneLiveLinkSystem
Default World Unity.Scenes.Editor.LiveLinkEditorSystemGroup
Default World Unity.Entities.InitializationSystemGroup
UnityEngine.CoreModule.dll!::UpdateFunction.Invoke()

Unity 2020.1.0f1
Entities Version 0.11.1-preview.4 - June 16, 2020

1 Like

Thanks for reporting this. This is should already be fixed in 0.13.

1 Like

I’m having this error too,
I’m using entities 0.11 and can’t upgrade to other versions cause I’m stack in Unity 2019.x .
Is there a way to fix it manually in entities 0.11 ?

Yes. You merely need to move the line s_ApplyBlobAssetChangesProfilerMarker.End(); out of the loop such that it is at the same level as s_ApplyBlobAssetChangesProfilerMarker.Begin();.

1 Like