Hey, figured it is easier if I just provide the code for the two methods. This shows the workaround we currently have in place:
`void USDLoadingScreenManager::ShowLoadingScreen()
{
if (bCurrentlyShowingLoadingScreen)
{
UpdateWidgetDisplay();
return;
}
TimeLoadingScreenShown = FPlatformTime::Seconds();
bCurrentlyShowingLoadingScreen = true;
CSV_EVENT(SDLoadingScreen, TEXT(“Show”));
UE_LOG(LogSDLoadingScreen, Log, TEXT(“%s”), *DebugReasonForShowingOrHidingLoadingScreen);
// Eat input while the loading screen is displayed
StartBlockingInput();
LoadingScreenVisibilityChanged.Broadcast(/bIsVisible=/ true);
UpdateWidgetDisplay();
ChangePerformanceSettings(/bEnableLoadingScreen=/ true);
}
void USDLoadingScreenManager::UpdateWidgetDisplay()
{
UGameInstance* const LocalGameInstance = GetGameInstance();
const USDLoadingScreenSettings* const Settings = GetDefault();
if (!LoadingScreenWidget.IsValid())
{
TSharedPtr UserWidget = OnLoadingScreenCreateWidget.IsBound() ? OnLoadingScreenCreateWidget.Execute() : TSharedPtr();
if (UserWidget.IsValid())
{
LoadingScreenWidget = UserWidget;
}
else
{
UE_LOG(LogSDLoadingScreen, Error, TEXT(“No custom loading screen widget was provided, falling back to placeholder.”));
LoadingScreenWidget = SNew(SThrobber);
}
}
IGameMoviePlayer* const MoviePlayer = IsMoviePlayerEnabled() ? GetMoviePlayer() : nullptr;
const bool bIsGameThreadBlocked = bCurrentlyInLoadMap || bCurrentlyPausedForStreaming;
const EWidgetMode NewWidgetMode = (bIsGameThreadBlocked && MoviePlayer != nullptr)
? EWidgetMode::MoviePlayer
: EWidgetMode::Viewport;
if (NewWidgetMode == WidgetMode)
{
return;
}
RemoveWidgetFromViewport();
WidgetMode = NewWidgetMode;
if (WidgetMode == EWidgetMode::MoviePlayer)
{
const auto DPIScaler = SNew(SDPIScaler)
.DPIScale_UObject(this, &ThisClass::CalcDPIScale)
[
LoadingScreenWidget.ToSharedRef()
];
const auto Overlay = SNew(SOverlay)
- SOverlay::Slot()
.HAlign(HAlign_Fill)
.VAlign(VAlign_Fill)
[
DPIScaler
];
FLoadingScreenAttributes LoadingScreenAttributes;
LoadingScreenAttributes.WidgetLoadingScreen = Overlay;
MoviePlayer->SetupLoadingScreen(MoveTemp(LoadingScreenAttributes));
MoviePlayer->PlayMovie();
}
else
{
// Add to the viewport at a high ZOrder to make sure it is on top of most things
UGameViewportClient* const GameViewportClient = LocalGameInstance
? LocalGameInstance->GetGameViewportClient()
: nullptr;
if (GameViewportClient)
{
GameViewportClient->AddViewportWidgetContent(LoadingScreenWidget.ToSharedRef(), Settings->LoadingScreenZOrder);
}
if (!GIsEditor || Settings->ForceTickLoadingScreenEvenInEditor)
{
// Workaround for deadlock caused by the slate loading thread, when showing a loading
// movie, obtaining the resource critical section before the slate tick
// see [Content removed]
FSlateRenderer* MainSlateRenderer = FSlateApplication::Get().GetRenderer();
FScopeLock ScopeLock(MainSlateRenderer->GetResourceCriticalSection());
// Tick Slate to make sure the loading screen is displayed immediately
FSlateApplication::Get().Tick();
}
}
}`