CanvasRenderTarget2D UpdateResource stalls

Hello

I am working with a CanvasRenderTarget2D references from Blueprints, which requires a a call to UpdateResource, which broadcasts the Blueprint callback for drawing.

The problem is that UpdateResource is destroying the underlying resource every frame, which stalls the frame by 13ms!

The workaround seems to be exposing FastUpdateResource, which does not re-create the resource, and insteads just clears the texture - which is the intended behaviour - but this contradicts the documentation!

  • Updates the the canvas render target texture’s resource. This is where the render target will create or
    * find a canvas object to use. It also calls UpdateResourceImmediate() to clear the render target texture
    * from the deferred rendering list, to stop the texture from being cleared the next frame. From there it
    * will ask the rendering thread to set up the RHI viewport. The canvas is then set up for rendering and
    * then the user’s update delegate is called. The canvas is then flushed and the RHI resolves the
    * texture to make it available for rendering.

Is this a known issue?

The canvas render target is updated via AHUD::ReceiveDrawHUD.

The profiler shows:

Function/Script/Engine.CanvasRenderTarget2D.UpdateResource
  Game thread idle time
    CPU stall - Wait for Event (13.003ms)
    Self (0.019ms)
    Pump Messages (0.006ms)