Apply game settings hitch

We’re experiencing a massive hitch when calling GameUserSettings::ApplySettings(). We never used to experience this on previous titles in 4.27 so I had a look.

[Image Removed]

This was added and it didn’t previously exist in 4.27. Upon further inspection it seems to trigger an iteration of every component in the game. What is this for, why was it added and can we do without it?

Thanks,

Brenden

`FGlobalComponentRecreateRenderStateContext::FGlobalComponentRecreateRenderStateContext()
{
if (FApp::CanEverRender())
{
TRACE_CPUPROFILER_EVENT_SCOPE(FGlobalComponentRecreateRenderStateContext::FGlobalComponentRecreateRenderStateContext);

ActiveGlobalRecreateRenderStateContextCount++;

// wait until resources are released
FlushRenderingCommands();

// recreate render state for all components.
for (UActorComponent* Component : TObjectRange())
{
if (Component->IsRegistered() && Component->IsRenderStateCreated())
{
ComponentContexts.Emplace(Component, &ScenesToUpdateAllPrimitiveSceneInfos);
}
}

UpdateAllPrimitiveSceneInfos();
}
}`

Hi there,

I’ve been investigating this issue and identified the following commit as the source of the behaviour change.

This update appears to have been introduced to prevent unnecessary render state recreation and Pipeline State Object (PSO) precaching from being triggered multiple times when console variables change during a call to ApplySettings. However, the logic that actively prevented these repeated calls has been removed in Unreal Engine 5.5, as shown in this subsequent commit.

You may be able to safely remove the FGlobalComponentRecreateRenderStateContext line from your project. This appears to have been introduced to reduce the risk of hitches caused by render states being recreated for all components multiple times when settings are changed. It does not appear to address any specific rendering or stability issues. That said, removing it could potentially lead to rendering artifacts or crashes, particularly if certain graphics settings are altered at runtime.

If you’d prefer not to modify the engine source directly, consider overriding the UGameUserSettings class in your project. You can replicate the ApplySettings method in your subclass and remove the FGlobalComponentRecreateRenderStateContext call there instead.

I’ll continue looking into this behavior and determine whether it warrants being flagged as a regression in later engine versions.

Regards,

Thomas

Hi,

I’ve done some further testing on this issue and found removing FGlobalComponentRecreateRenderStateContext does NOT appear to cause any issues. Console variable changes that require a render state recreation already trigger this on change.

Note that on version 5.4 of the engine you might notice a slightly larger hitch without the FGlobalComponentRecreateRenderStateContext in ApplySettings on the conditional that one of the following console variables changes:

r.Lumen.DuffuseIndirectAllow -> Can change via GlobalIlluminationQuality scalability setting

r.DetailMode -> Can change via EffectsQuality scalability setting

r.MaterialQualityLevel -> Can change via EffectsQuality scalability setting

This is because the recursion guard in FGlobalComponentRecreateRenderStateContext is still present in UE 5.4. However, it has since been removed in 5.5, so the FGlobalComponentRecreateRenderStateContext will only make hitches worse in 5.5 onwards.

Since this seems to be a regression in UE 5.5 forward, I’ve submitted a bug report for this issue.

Public tracker link here:

https://issues.unrealengine.com/issue/UE-296881

Let me know if you have any further queries:

Regards,

Lance