CreateRenderState_Concurrent crash

If the editor starting map contains a component that equeues a clear render target (or a canvas draw) in the CreateRenderState_Concurrent, the engine crashes since FSceneRenderTargets::CurrentShadingPath is not initialized (it is equal to 2, so ShadingPath::Num, so the GetSceneColorForCurrentShadingPath’s check fails).

Is there any documentation about actor/component calls, or engine flow, that covers at least OnRegister, CreateRenderState_Concurrent?

Thanks.

Marco,

I’m not sure there are any documents outlining the information you’re looking for. Further, the paths for getting from loading / creating a world to initializing components can be quite divergent depending on how / when you’re doing this (e.g. just launching the game from command line may be slightly different than doing PIE).

Can you provide a little more context on when this happens? Is it when the editor first loads, when you PIE, if you launch into the game with command line args? Does this happen in packaged or game builds?

Here’s a page describing Actor Lifecycle.

There are another key points to this in regards to your question (but not on that page):

UActorComponent::RegisterComponentWithWorld is called, it will call ExecuteRegisterEvents (and also will conditionally call RegisterComponentWithWorld on child components).

UActorComponent::ExecuteRegisterEvents is called, it will call OnRegister first, and then CreateRenderState_Concurrent.

However, when RegisterComponentWithWorld is called is a little less straight forward.

UActorComponent has a bAutoRegister member (which is true by default). When this is set, the component will automatically register as soon as the Actor is registered. However, when it’s false, it’s typically up to the owning Actor to manage registration. However, RegisterComponentWithWorld is public because Components can be created dynamically at runtime in a way that is not manager by the Actor.

All of that aside, what you’re running into is likely is a callstack that looks something like this:

AActor::IncrementalRegisterComponents
ULevel::IncrementalUpdateComponents
ULevel::UpdateLevelComponents
UWorld::UpdateWorldComponents
UWorld::InitializeNewWorld
UWorld::CreateWorld

It’s also important to realize that UpdateWorldComponents will be called when InitializeActorsForPlay is called (and you can see where that fits in in the Actor Lifecycle docs).

Something you could try to avoid these issues is to disable bAutoRegister on the components with these calls, and defer them until later (see the Actor Lifecycle docs for potential injection points).

Thanks,
Jon N.

This happens while the editor is launching as editor in Development_editor configuration: the dialog displays “Loading… 95%”.

The callstack is the following:

UE4Editor-Renderer.dll!FSceneRenderTargets::GetSceneColorForCurrentShadingPath() Line 658 C++

UE4Editor-Renderer.dll!FSceneTextureShaderParameters::Set::SetSharedState(FRHIC

UE4Editor-Renderer.dll!FDrawTranslucentMeshAction::Process(FRHICom

UE4Editor-Renderer.dll!ProcessBasePassMesh(FRHICommandList &

UE4Editor-Renderer.dll!FTranslucencyDrawingPolicyFactory::DrawMesh(FRHICommandList & RHIC

UE4Editor-Renderer.dll!FTranslucencyDrawingPolicyFactory::DrawDynamicMesh(FRHICommandList

UE4Editor-Renderer.dll!FRendererModule::DrawTileMesh(FRHICommandListImmediate & RHICmdLis

UE4Editor-Engine.dll!FTileRenderer::DrawTile(FRHICommandListImmediate & RHICmdList, const FSc

UE4Editor-Engine.dll!FCanvasTileRendererItem::Render_GameThread'::2’::EURCMacro_DrawTileCommand::DoTask(ENamedT

UE4Editor-Engine.dll!TGraphTask<FCanvasTileRendererItem::Render_GameThread'::2’::EURCMacro_DrawTileCommand>::ExecuteTask(TArray & NewTasks, ENamedThreads::Type CurrentThread) Line 868 C++

UE4Editor-Core.dll!FNamedTaskThread::ProcessTasksNamedThread(int QueueIndex, bool bAllowStall) Line 932 C++

UE4Editor-Core.dll!FNamedTaskThread::ProcessTasksUntilQuit(int QueueIndex) Line 679 C++

UE4Editor-RenderCore.dll!RenderingThreadMain(FEvent * TaskGraphBoundSyncEvent) Line 319 C++

UE4Editor-RenderCore.dll!FRenderingThread::Run() Line 457 C++

UE4Editor-Core.dll!FRunnableThreadWin::Run() Line 74 C++

UE4Editor-Core.dll!FRunnableThreadWin::GuardedRun() Line 23 C++

Marco,

Does this happen if you launch your project as a game, or only when launching in editor?

I think the problem really is that you’re just not supposed to be making those sorts of calls in CreateRenderState_Concurrent. The name alone suggests that you should be creating state, not running commands.

You should probably just remove those calls and perform them elsewhere.

Thanks,
Jon N.