(Auto) asset import breaks after opening an asynchronously loaded level

We have encountered a problem where asset importing stopped working in certain situations. This happens with both automatic and manual reimporting.

It can be reproduced was as follows:

  • Open a big level through the Content Browser. (I think the reason that it should be a big level is that the level is loaded asynchronously when opened)
  • Navigate to a texture in the content browser that is referenced by one of the Actors in the level that was just opened.
  • Right-click on that texture and choose “Reimport”
  • Observe that a file selection window opens instead of the expected behaviour where the import is started.

A debug session showed that the SourceData variable in UAssetImportData for the broken assets wasn’t set. This value is supposed to be set in the UAssetImportData::Serialize function. However, this function is not always being called.

Some more investigation showed that the reason Serialize is not called is that the RF_NeedLoad flag is is not set on the UAssetImportData object.

It was observed that the AssetImportData was loaded properly when it was used in a small level. The reason for the different behaviour is a branch in FLinkerLoad::CreateExport. Somewhere in the middle of the function there is the following piece of code:


if(FPlatformProperties::RequiresCookedData() 
	|| IsAsyncLoading()
	|| Export.bForcedExport
	|| LinkerRoot->ShouldFindExportsInMemoryFirst()
	)

Here we see a branch that is entered when AsyncLoading is enabled.
In this branch the RF_NeedLoad flag is only being set under certain conditions:


if (!Export.Object->HasAnyFlags(RF_LoadCompleted) &&
(Export.Object->HasAnyFlags(RF_DefaultSubObject) || (ThisParent && ThisParent->HasAnyFlags(RF_ClassDefaultObject))))
{
	Export.Object->SetFlags(RF_NeedLoad | RF_NeedPostLoad | RF_NeedPostLoadSubobjects | RF_WasLoaded);
}

At this point the only flag set on the UAssetImportData object is RF_Async.

In UTexture::PostInitProperties it can indeed be observed that the UAssetImportData is constructed without any flags.

At this point I am not sure how to properly solve the problem. I am pretty certain the RF_NeedLoad flag needs to be set on the UAssetImportData objects somehow. But I don’t understand the system well enough to decide how that should be achieved.

So, my question would be if someone is familiar with this system and can help me fix it, tell me if I’m looking in the right direction, or is this maybe a known issue that is already being worked on?

Hi MrDean -

I am looking into this issue now and will respond back here if I have any questions or can provide you with an answer.

Thank You

Eric Ketchum

Nice to hear, thanks!

Hello -

I have been trying a few different internal maps including the kite demo and I am not able to get the results that you are describing above unless the source location is no longer valid for the texture asset. Do you have a sample project which demonstrates this issue that I could test? You can attach it here or link it to me via the following private message system:

https://forums.unrealengine.com/private.php?do=newpm&u=4892

Thank You

Eric Ketchum

I sent you a message.

Hi Mr.Dean -

Thank You for your help, I was able to reproduce the issue and entered the report as UE-24505. As we continue to investigate a solution I will keep you informed here.

Eric Ketchum