truong-bui / AsyncLoadingScreen

Async Loading Screen is a free and open-source plugin for Unreal Engine. Async Loading Screen allows you to easily configure a Loading Screen System in the project settings, and automatically add a Loading Screen whenever you open a new level, without Level Streaming.
https://www.unrealengine.com/marketplace/en-US/product/async-loading-screen
MIT License
799 stars 99 forks source link

First frame flicker. Loading widget scale is wrong in the first frame #88

Open dantreble opened 8 months ago

dantreble commented 8 months ago

This https://github.com/truong-bui/AsyncLoadingScreen/blob/b37686c0ad074b9ecda1b87bb262caa5a0604ce5/Source/AsyncLoadingScreen/Private/SLoadingScreenLayout.cpp#L22 returns zero for the first frame which causes a flicker.

I tried to do it based on GEngine->GameViewport->Viewport->GetSizeXY(), it mostly worked, but the scaling was off in certain circumstances (console at 4k).

truong-bui commented 8 months ago

Hi @dantreble, Yes, maybe the data from gettickspacegeometry() doesn't exist in the first frame. image

However, I don't know how to fix this issue because I cannot reproduce this bug on my side. It would be very helpful if you could provide the project link or screenshot/video of the issue. I will investigate the bug.

Note that the plugin depends on the MoviePlayer plugin. Many of the issues here are either related to MoviePlayer or the engine itself, which is beyond my ability to fix.

Best Regards, Truong

dantreble commented 8 months ago

If this video attaches and you can skip frame by frame, you can see the layout is different first frame https://github.com/truong-bui/AsyncLoadingScreen/assets/3644118/39fe890c-bd43-40d3-afda-0caffe974162

I was able to get a breakpoint in a standalone game and see it 0,0 on the first frame. I also logged it with UE_LOG :-)

truong-bui commented 8 months ago

Oh, I see. The loading widget scale is wrong in the first frame. Interesting!

image

I will take a look at this issue. Tbh, if the player doesn't have OCD, they may not notice it :). Anyway, thanks for the update.

truong-bui commented 8 months ago

Just updated the DPI scale from the viewport size instead: https://github.com/truong-bui/AsyncLoadingScreen/commit/8acaab11926794c6bfad44ff60c1cc6d99bac1a5

Hopefully this will solve your issue.

dantreble commented 8 months ago

Thank you!

I did the same, although I clamped it at 1.0, because on PS5 the dpi scale went to 2.0 at 4k. While with the original code it stayed at 1.0

PS5 GetTickSpaceGeometry().ToPaintGeometry().GetLocalSize() 1920,1080 Scale 1.000000 GEngine->GameViewport->Viewport->GetSizeXY() 3840,2160 Scale 2.000000

(the elements look VERY large at 2.0, which is almost the inverse to what you want!)

Some PC scenarios for comparison GetTickSpaceGeometry().ToPaintGeometry().GetLocalSize() 2752,1152 Scale 1.066667 GEngine->GameViewport->Viewport->GetSizeXY() 3440,1440 Scale 1.333333

GetTickSpaceGeometry().ToPaintGeometry().GetLocalSize() 1536,864 Scale 0.799600 GEngine->GameViewport->Viewport->GetSizeXY() 1920,1080 Scale 1.000000

GetTickSpaceGeometry().ToPaintGeometry().GetLocalSize() 1024,576 Scale 0.532800 GEngine->GameViewport->Viewport->GetSizeXY() 1280,720 Scale 0.666000

truong-bui commented 8 months ago

Thanks for the info. I will keep the issue open for reference, in case someone may encounter the same problem.