Description from licensee:

We're seeing an ensure get tripped up in FDebugRenderSceneProxy that says "DrawDelegate is already Registered!". Debugging the issue, we have confirmed that the DrawDelegate does indeed attempt to get registered twice and we believe we've root caused the issue to be related to the bDeferredRegister member in FDebugDrawDelegateHelper. I've put our suggested one liner fix at the bottom


The specific flow that's causing this issue is this:

  1. LevelStreaming will trigger RequestRegisterDebugDrawDelegate to get called. Context is not null so the delegate registration is deferred (bDeferredRegister = true)
    1. Note: Nothing ever actually triggers the delegate to get registered
  2. At the end of frame update, the render state is triggered to be recreated (RecreateRenderState_Concurrent)
  3. RecreateRenderState_Concurrent first calls DestroyRenderState_Concurrent. This in turn calls UnregisterDebugDrawDelegate. Nothing has been registered so nothing of interest is done here, HOWEVER, bDeferredRegister is also left untouched so it's still left as true
  4. RecreateRenderState_Concurrent calls CreateRenderState_Concurrent next. This calls down to FScene::AddPrimitive->UDebugDrawComponent::CreateSceneProxy which calls ProcessDeferredRegister(). Because bDeferredRegister was left to true, this registers the delegate
  5. The last line of UDebugDrawComponent::CreateRenderState_Concurrent calls RequestRegisterDebugDrawDelegate. Uh oh! Delegate was already registered, so we hit an assert.


I believe the fix here should be fairly simple as I don't think it's intentional that bDeferredRegister should be left to true after UnregisterDebugDrawDelegate is called. By simply adding this line to the end of FDebugDrawDelegateHelper::UnregisterDebugDrawDelegate we were able to resolve our issue:

bDeferredRegister = false;

Have Comments or More Details?

There's no existing public thread on this issue, so head over to Questions & Answers just mention UE-162682 in the post.

Login to Vote

ComponentUE - AI - Debugging
Affects Versions5.0
Target Fix5.5
CreatedAug 31, 2022
UpdatedFeb 29, 2024
View Jira Issue