We are experiencing a frequent but highly-conditional crash in our project after upgrading to UE5.6.
If FTextureCompilationManager::PostCompilation executes while we have queued tasks in Task Graph that are executing on the GameThread, and those tasks deal with UTextures in anyway (in our case, applying them as brushes to a UImage - the engine will crash due to the recently added bIsRoutingPostCompilation check in FTextureCompilationManager::FinishCompilation.
Ultimately this starts becase a call to UTexture->UpdateResource() is made, invoking FlushRenderingCommands(), which then forces all EGameThread tasks to complete. This causes our User Interface code (which makes heavy of task graph via a third-party plugin), to invoke UImage::SetBrushFromTexture(), which internally calls FTextureCompilationManager::FinishCompilation
This seems extremely fragile, any task graph task that works with texture assets specfically would not be able to execute on the game thread, and would have to schedule a completion callback to run from somewhere inside the LevelTick. This hasn’t been an issue for us in prior releases as far as I’m aware - is there some new feature we can disable to avoid this check being hit?
Unfortunately, the renderer needs to execute some tasks on the GT while waiting on FlushRenderingCommands, that’s why we end up processing gamethread tasks while we wait. It always been this way, not sure why you’re seeing this as a new issue in 5.6.
To avoid this behavior, you can schedule your gamethread only tasks inside a tick instead using ExecuteOnGameThread available in Ticker.h, it will avoid having your gamethread tasks run inside waits like these and should resolve your issue.
Alternatively, you could make UCommonLazyImage async aware by looking at the Texture IsCompiling() function before doing the assignment and registering on the asset compilation manager to know when the texture is done and create it at that time. This way you will avoid hitches on the game thread and improve the responsiveness of the application by showing things only when they are ready.