Page 1 of 1

Textures sometimes fail to load in Unreal

Posted: 28 Sep 2023, 17:01
by David Jefferies
In Unreal we've moved the loading of the Xaml files from disk to be asynchronous. This is because we want to be able to load/unload them during gameplay - the motivation here is that unloading the Xaml means its textures get unloaded as well.

We initiate the async load like this:
StreamableManager.RequestAsyncLoad(XamlObject.ToSoftObjectPath(),	FStreamableDelegate::CreateRaw(this, &FViewLoader::OnXamlLoaded),
									FStreamableManager::AsyncLoadHighPriority, false, false, "ViewLoader");

Then when its loaded we call LoadXaml on it
void FViewLoader::OnXamlLoaded()
{
	UNoesisXaml* XamlFile = XamlObject.Get();
	const Ptr<BaseComponent> Component = XamlFile->LoadXaml();
	..
}
The issue we're having is sometimes the textures for the Xaml fail to load with the error message:
LogNoesis: Warning: Error loading '/Game;component/MyGame/Images/image_8.png', using fallback texture
Stepping through the code we can see that CreateTexture is failing because InTexture->GetResource() returns nullptr
Noesis::Ptr<Noesis::Texture> FNoesisRenderDevice::CreateTexture(UTexture* InTexture)
{
	if (!InTexture || !InTexture->GetResource())
		return nullptr;
..
}
The issue only occurs in a standalone build - never in editor - and seems to be timing related, sometimes it works fine sometimes it fails.

It looks like the textures haven't finished loading when CreateTexture tries to access them - the UTexture object exists but texture data doesn't yet

Any ideas what we can do to resolve it?

Re: Textures sometimes fail to load in Unreal

Posted: 29 Sep 2023, 14:49
by hcpizzi
Hi David,

I've created a ticket to keep track of this issue. Here's a link: https://www.noesisengine.com/bugs/view.php?id=2705

Please, monitor the ticket, and I will post there as soon as I figure out how to resolve this.

Thanks

Re: Textures sometimes fail to load in Unreal

Posted: 29 Sep 2023, 16:16
by David Jefferies
Great - thanks :)

One point that may be relevant is that the textures that are being loaded when it fails are quite large - 2560 x 1440 x 24bit

Re: Textures sometimes fail to load in Unreal

Posted: 10 Oct 2023, 16:38
by David Jefferies
I'd like to query the severity as 'minor' because the issue means we can't load Xamls asynchronously.

This is a problem because textures are only unloaded when all the references to the UNoesisXaml object are released. So to unload the textures we need to unload the Xaml file but then if we want to show the element again we're forced to load it synchronously, causing hitches.

We either need to be able to load the Xamls asynchronously, or be able to release the textures without unloading the Xaml

Re: Textures sometimes fail to load in Unreal

Posted: 10 Oct 2023, 19:11
by jsantos
Thanks, severity changed to "major"

Re: Textures sometimes fail to load in Unreal

Posted: 18 Oct 2023, 13:12
by hcpizzi
Hi David,

I've added a comment to the ticket (to keep the conversation in a single place). Could you please take a look?

Thanks!