I’m using enhanced input and usersettings to bind, apply, store and reload key bindings. Everything works except when I quit, I get a crash upon ValidateMappingContexts. I tried using ClearAllMappings for my input at controller/gamemode Endplay, at gameinstance Shutdown, but it didn’t help. Also tried to create my own enhanced input component and override its EndPlay, store/clear bindings, but the same crash.
I thought it was first related to the map transition, but it occurs on my menu/first level too.
From the callstack it seems the world is already destroyed when UE calls that method.
Has anyone had a similar issue?
Thanks, Gabor
Okay, found the problem, it was not related to enhanced input, but maybe its instructive to read.
Our GameInstance Shutdown() was overriding the engine shutdown path but did not call Super::Shutdown(). That matters because the base UGameInstance::Shut
down() removes the LocalPlayer objects and deinitializes GameInstance subsystems in the expected order.
Without that call, the LocalPlayer could survive until a later GC/destruction phase, where Enhanced Input tries to deinitialize from a half-torn-down LocalPlayer / ViewportClient state and crashes there.
I added this at the end of our GameInstance::Shutdown():
Super::Shutdown();
This also explains why Enhanced Input users generally do not hit this: their normal GameInstance shutdown sequence runs, so the Enhanced Input subsystem is torn down while the owning player/world state is still valid enough.