Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Bug [1.1.0-exp.1] LockBufferForWrite: Multiple uploads in flight for buffer x of size 4194304

Discussion in 'Graphics for ECS' started by optimise, Sep 21, 2023.

  1. optimise

    optimise

    Joined:
    Jan 22, 2014
    Posts:
    2,068
    I get the following log at 1.1.0-exp.1 with Unity 2022.3.10f1

    LockBufferForWrite: Multiple uploads in flight for buffer 000001B464BDCE78 (bufferHandle: 8137) of size 4194304. Falling back to slow path. LockBufferForWrite() should be called only once per frame on D3D11.
    UnityEngine.GraphicsBuffer:LockBufferForWrite<byte> (int,int)
    Unity.Rendering.SparseUploader:Begin (int,int,int) (at ./Library/PackageCache/com.unity.entities.graphics@1.1.0-exp.1/Unity.Entities.Graphics/SparseUploader.cs:683)
    Unity.Rendering.EntitiesGraphicsSystem:StartUpdate (int,int,int) (at ./Library/PackageCache/com.unity.entities.graphics@1.1.0-exp.1/Unity.Entities.Graphics/EntitiesGraphicsSystem.cs:2530)
    Unity.Rendering.EntitiesGraphicsSystem:UpdateAllBatches (Unity.Jobs.JobHandle) (at ./Library/PackageCache/com.unity.entities.graphics@1.1.0-exp.1/Unity.Entities.Graphics/EntitiesGraphicsSystem.cs:2001)
    Unity.Rendering.EntitiesGraphicsSystem:UpdateEntitiesGraphicsBatches (Unity.Jobs.JobHandle) (at ./Library/PackageCache/com.unity.entities.graphics@1.1.0-exp.1/Unity.Entities.Graphics/EntitiesGraphicsSystem.cs:1227)
    Unity.Rendering.EntitiesGraphicsSystem:OnUpdate () (at ./Library/PackageCache/com.unity.entities.graphics@1.1.0-exp.1/Unity.Entities.Graphics/EntitiesGraphicsSystem.cs:1327)
    Unity.Entities.SystemBase:Update () (at ./Library/PackageCache/com.unity.entities@1.1.0-exp.1/Unity.Entities/SystemBase.cs:418)
    Unity.Entities.ComponentSystemGroup:UpdateAllSystems () (at ./Library/PackageCache/com.unity.entities@1.1.0-exp.1/Unity.Entities/ComponentSystemGroup.cs:723)
    Unity.Entities.ComponentSystemGroup:OnUpdate () (at ./Library/PackageCache/com.unity.entities@1.1.0-exp.1/Unity.Entities/ComponentSystemGroup.cs:681)
    Unity.Entities.SystemBase:Update () (at ./Library/PackageCache/com.unity.entities@1.1.0-exp.1/Unity.Entities/SystemBase.cs:418)
    Unity.Entities.ScriptBehaviourUpdateOrder/DummyDelegateWrapper:TriggerUpdate () (at ./Library/PackageCache/com.unity.entities@1.1.0-exp.1/Unity.Entities/ScriptBehaviourUpdateOrder.cs:523)
     
  2. JussiKnuuttila

    JussiKnuuttila

    Unity Technologies

    Joined:
    Jun 7, 2019
    Posts:
    335
    What kind of a scene do you have? This is definitely a bug, since OnUpdate is supposed to be called only once per frame.
     
  3. optimise

    optimise

    Joined:
    Jan 22, 2014
    Posts:
    2,068
    I believe it's just a environment subscene that able to run on mobile. Before that at 1.0.16, I never get this log. I only the log occasionally though at editor and seems like doesn't make the game stop working.
     
  4. optimise

    optimise

    Joined:
    Jan 22, 2014
    Posts:
    2,068
    New update. I get the same log at windows player runtime with extremely simple subscene.

    upload_2023-9-22_1-32-5.png
     
  5. JussiKnuuttila

    JussiKnuuttila

    Unity Technologies

    Joined:
    Jun 7, 2019
    Posts:
    335
    For clarity, the behavior of the code has not changed in the latest version, but this warning was made more visible and now contains more details. In previous versions the same warning was present, but it was likely buried in the log and went unnoticed.
     
    optimise likes this.
  6. Tony_Max

    Tony_Max

    Joined:
    Feb 7, 2017
    Posts:
    334
    I also get same logs on the same unity version.

    It happens with my package for rendering sprites for dots. I use writing to ComputeBuffer through NativeArray to pass data to StructurredBuffer on GPU, I use parallel jobs to fill array with data. This logs start to appear when both game and scene windows are NOT active and at the same time I'm starting to see graphics artifacts which seems like invalidated data was passed to buffer. It is odd, because I call BeginWrite and EndWrite 1 time each frame but logs tell me opposite. I try to find source of graphic artifacts for a long time already, maybe it is related to how buffers behaves, at least it has same reproduction way.

    UPD: this happens frequently when Profiler is opened and even if game window is opened
     
    Last edited: Sep 23, 2023
  7. JussiKnuuttila

    JussiKnuuttila

    Unity Technologies

    Joined:
    Jun 7, 2019
    Posts:
    335
    Unless something very unexpected is happening, this warning should not result in rendering artifacts, but it does mean that performance is being impacted.

    So far I have not been able to reproduce this issue myself, so it seems to require some specific circumstances to happen.
     
    Tony_Max likes this.
  8. optimise

    optimise

    Joined:
    Jan 22, 2014
    Posts:
    2,068
    Looks like it's regression at Unity 2022.3.10f1. It's reproducible at both 1.1.0-exp.1 and 1.0.16
     
  9. JussiKnuuttila

    JussiKnuuttila

    Unity Technologies

    Joined:
    Jun 7, 2019
    Posts:
    335
    Unity 2022.3.10f1 should only change how this warning is reported (it is displayed in the Console instead of being buried in the text only log file), it should not change whatever is actually causing the warning to get issued.
     
  10. optimise

    optimise

    Joined:
    Jan 22, 2014
    Posts:
    2,068
    Not sure whether it's related issue but currently when u have 2 subscene that has real time light and u keep swapping between 2 subscene at Scene Asset of Subscene game object, you will see the light intensity keep increasing until crazy exposure. Looks like graphics never release properly and keep stacking.