TakeWidget crashes 4.21

In UE4 4.21.2 I am having an issue with the game crashing when I call UWidget::TakeWidget from my GameInstance.

Relevant header code

	UPROPERTY(EditAnywhere, BlueprintReadWrite)
	TSubclassOf<class UUserWidget> LoadingScreenWidget;

	UPROPERTY()
	UUserWidget* loadingumg;

	TSharedPtr<class SWidget> widgetptr;

Relevant implementation code (LoadingScreenWidget is set in BP, verified in the debugger that it is set)

loadingumg = CreateWidget<UUserWidget>(this, LoadingScreenWidget);
widgetptr = loadingumg->TakeWidget();

As far as I can see, this should be working based on examples written for older engine versions. If I follow the trace, at widget.cpp:720 the code attempts to access MyWidget, which is null.

UE4Editor_UMG!UWidget::TakeWidget_Private() [d:\build++ue4\sync\engine\source\runtime\umg\private\components\widget.cpp:720]
UE4Editor_UMG!UWidget::TakeWidget() [d:\build++ue4\sync\engine\source\runtime\umg\private\components\widget.cpp:709]
MyCustomGameInstance::BeginLoadingScreen()

UE4Editor_Engine!UEngine::LoadMap() [d:\build++ue4\sync\engine\source\runtime\engine\private\unrealengine.cpp:11810]
UE4Editor_Engine!UEngine::Browse() [d:\build++ue4\sync\engine\source\runtime\engine\private\unrealengine.cpp:11527]
UE4Editor_Engine!UGameInstance::StartGameInstance() [d:\build++ue4\sync\engine\source\runtime\engine\private\gameinstance.cpp:498]

UE4Editor!FEngineLoop::Init() [d:\build++ue4\sync\engine\source\runtime\launch\private\launchengineloop.cpp:3053]

UE4Editor!GuardedMain() [d:\build++ue4\sync\engine\source\runtime\launch\private\launch.cpp:161]

UE4Editor!GuardedMainWrapper() [d:\build++ue4\sync\engine\source\runtime\launch\private\windows\launchwindows.cpp:145]

UE4Editor!WinMain() [d:\build++ue4\sync\engine\source\runtime\launch\private\windows\launchwindows.cpp:276]
UE4Editor!__scrt_common_main_seh() [f:\dd\vctools\crt\vcstartup\src\startup\exe_common.inl:283]

kernel32

ntdll

Hello,

We’ve recently made a switch to a new bug reporting method using a more structured form. Please visit the link below for more details and report the issue using the new Bug Submission Form. Feel free to continue to use this thread for community discussion around the issue.

https://epicsupport.force.com/unrealengine/s/

Thanks