Page MenuHomeFeedback Tracker

Trying to draw UI2Texture inside another UI2Texture fails with "Cannot load mipmap" error
Closed, ResolvedPublic

Description

When you draw UI2Texture procedural texture inside another UI2Texture procedural texture, engine produces "Cannot load mipmap" error and texture fails to load.

Details

Severity
Minor
Resolution
Open
Reproducibility
Always
Operating System
Windows 10 x64
Category
Scripting
Steps To Reproduce

  1. Run attached ui2textureception.VR mission
  2. Use "Set texture" action and observe the error
  3. Use "Open display and set texture" to observe the hackfix

Event Timeline

SaMatra created this task.Mar 3 2023, 2:11 PM

Temporary workaround without need to draw inner display anywhere on UI:

Frame 1: Set outer display texture onto object texture
Frame 2: Set inner display texture to RscPicture, do displayUpdate to outer display
Frame 3: Do displayUpdate to outer display again

SaMatra added a comment.EditedMar 5 2023, 10:00 AM

This error also happens if you try displaying .paa pictures without mipmaps inside inner ui2texture display.

dedmen set Ref Ticket to AIII-55591.Mar 16 2023, 10:29 AM
dedmen added a subscriber: dedmen.Mar 29 2023, 10:30 AM

Y can I not run mission in Eden 😢
works fine if i remove all the waitUntils and eden check. But need to run set texture twice to trigger that error.
I have already seen this error before.. it tries REALLY hard to load the second mipmap, even when there is only one. And it.. obviously fails.

SaMatra added a comment.EditedMar 29 2023, 10:54 AM

Y can I not run mission in Eden 😢
works fine if i remove all the waitUntils and eden check. But need to run set texture twice to trigger that error.
I have already seen this error before.. it tries REALLY hard to load the second mipmap, even when there is only one. And it.. obviously fails.

is3DEN should have prevented init.sqf from running outside of 3DEN preview. As for getClientStateNumber, I didn't know it returns 0 in SP, I tested the repro in MP environment, the point of it was to skip briefing by force pressing the "Continue" button.

Here is init.sqf to have the repro work in SP.

	waitUntil {player == player};

	laptop = createVehicle ["Land_Laptop_unfolded_F", player modelToWorld [0,2,1], [], 0, "CAN_COLLIDE"];
	laptop setDir (laptop getDir player);
	laptop enableSimulation false;
	settexture = {
		somenumber = random 1e6 toFixed 0;
		_this setObjectTexture [0, format["#(rgb,1024,1024,1)ui('DisplayTextureOuter','outer%1')", somenumber]];
	};
	settexturehack = {
		somenumber = random 1e6 toFixed 0;
		createDialog "DisplayTextureOuter";
		_this setObjectTexture [0, format["#(rgb,1024,1024,1)ui('DisplayTextureOuter','outer%1')", somenumber]];
	};
	//laptop call settexture;

	player addAction ["Set texture", {laptop call settexture}];
	player addAction ["Open display and set texture", {laptop call settexturehack}];

I always get the error on first run of "Set texture" action on Stable:

So one issue, its trying to use the texture before its loaded (because loading is async), so when the display is created, you set the texture, it will only load next frame, but right after creating display it tries to render.
Easy to check for that and skip rendering the texture.

Next issue, you have to manually re-render till its done loading, and there is no way for you to know when its done, it might take multiple frames.

So fix for that, after creation it will automatically trigger re-rendering while there is a non-ready texture inside the display OR there is a UIToTexture inside it that is scheduled for re-render.
That will recursively wait till all sub-textures are loaded.

But this will only happen at creation, if you add a sub texture some time later, you need to take care of that updating yourself.

SaMatra added a comment.EditedMar 30 2023, 1:21 PM

So one issue, its trying to use the texture before its loaded (because loading is async), so when the display is created, you set the texture, it will only load next frame, but right after creating display it tries to render.
Easy to check for that and skip rendering the texture.

Next issue, you have to manually re-render till its done loading, and there is no way for you to know when its done, it might take multiple frames.

So fix for that, after creation it will automatically trigger re-rendering while there is a non-ready texture inside the display OR there is a UIToTexture inside it that is scheduled for re-render.
That will recursively wait till all sub-textures are loaded.

But this will only happen at creation, if you add a sub texture some time later, you need to take care of that updating yourself.

Can we have a scripting command to check that? Something like BOOL = isTextureLoaded STRING, maybe also BOOL = isTextureLoading STRING to know if its been queued.

This comment was removed by SaMatra.

Refined idea once more, it all can be crammed into single command:
BOOL = preloadTexture STRING
Will return true as soon as texture is loaded.

dedmen changed the task status from New to Feedback.EditedMar 30 2023, 1:40 PM

Fix next dev and profiling (today)

Can we have a scripting command to check that?

No.

BOOL = preloadTexture STRING

Yes. Separate ticket. And its low priority. Texture cache mess will be fun

Can we have a scripting command to check that?

No.

BOOL = preloadTexture STRING

Yes. Separate ticket. And its low priority. Texture cache mess will be fun

Fun allowed then. "Can we have a scripting command to check that" was about having such texture preloading scripting command, sorry for hasty confusing replies, really happy to see this addressed.

I think my ticket (https://feedback.bistudio.com/T171035) is related to the behavior mentioned here. In my case it's not a nested UI but only a static image. I tested the latest profiling build 2.12.150430 but unfortunately this does not solve my variant of the problem.

Wulf added a subscriber: Wulf.Jun 27 2023, 11:14 AM

@SaMatra can you please confirm, if the issue is still present on your end?

Thank you.

Wulf closed this task as Resolved.Dec 21 2023, 1:17 PM
Wulf claimed this task.

Closing this as resolved.