#Constantly creating GraphicsBuffers is eventually freezing the editor

1 messages · Page 1 of 1 (latest)

pastel mist
#

I'm using a Macbook with the Metal backend. I'm using the HDRP in Unity 6.2.

Due to an error in my code, my script is creating a small GraphicsBuffer every single frame.

I noticed that this causes the editor to freeze if I hide the editor window for a minute or so. The freeze doesn't happen if the window is visible (it doesn't have to be focused).

The hang happens on this line:

var array = dataBuffer.LockBufferForWrite<uint>(0, 4);

I'm guessing that, because the editor is completely hidden, a huge queue of uploads is piling up. I tried switching from LateUpdate to subscribing to RenderPipelineManager.beginCameraRendering, but this didn't help (and I can see my code is still running once per frame, even with the editor hidden).

Obviously, I'm going to fix the bug, but I'm curious if:

  • This is why the freeze is happening
  • I can do anything to detect and prevent this
#

It takes about a minute, during which time almost 10,000 buffers are being created

#

As long as the editor is visible, it's okay

#

and yes: fixing the buffer spam has prevented the freezing

#

I don't expect buffers to change that often (it only updates this buffer when a feature is added or removed...which is only going to happen once upon entity creation, really)