Cancelling Async Loads on a Forced Engine Exit produces a Fatal Error

We’re experiencing a crash as the engine is exiting with the following message:

Requesting async load of "<ASSET_NAME>" when async loading is not allowed (after shutdown). Please fix higher level code.This happens when a user forcibly closes the engine when transitioning to a level that has another level listed as “Always Loaded”. When the engine exits it sets a flag that makes sure that async loading gets disabled. After it does this it flushes async loading requests, by doing this the “Always Loaded” level tries to load asynchronously and a crash happens. It appears there’s an engine.ini variable that will supposedly cancel async loading tasks instead of flush them out `s.FlushStreamingOnExit`. But this calls into a cancel function that hasn’t been implemented yet.

void FAsyncLoadingThread2::CancelLoading() { check(false); // TODO }Is there any suggestions on how we can avoid this crash, whilst also keeping that “Always Loaded” level with that setting on?

Thanks!

Steps to Reproduce

  1. Marking a level as always loaded.
  2. Transition to a level that has the always loaded level listed as a sublevel.
  3. While the transition happens, forcibly close the program (Alt + F4)
  4. Witness Fatal Crash on exit.

Hi,

It is a known issue and I’m currently working on it.

It can generally be fixed by adding a FlushAsyncLoading before PreExit() in LaunchEngineLoop.cpp

`FlushAsyncLoading();

if ( GEngine != nullptr )
{
#if WITH_EDITOR
if (GIsEditor)
{
FEditorDelegates::OnEditorPreExit.Broadcast();
}
#endif // WITH_EDITOR

GEngine->PreExit();
}

if (GEngine != nullptr)
{
GEngine->ReleaseAudioDeviceManager();
}`CancelAsyncLoading is not supported and will be deprecated in the future. So also please make sure that s.FlushStreamingOnExit is true in your ini files (should be the default anyway).

Thanks

Danny