Issues with GameInstance in 4.6

Hey Guys,

I had a moment to upgrade my project to 4.6 and after resolving a lot of issues with compiling, I am still running into issues with my custom GameInstance class. I had to make a DebugGame build but I was able to trace it to the creation of the GameInstance class. I noticed if I start my game on one of the levels, that it still has some reference to the GameInstance and will also cause it to crash. I unfortunately cannot get a Standalone, Launched or Published Build to run.

The error is hitting at line 434 in the GameEngine.cpp…
GameInstance = ConstructObject(GameInstanceClass, this);

Thanks guys!

I’m trying to take another look at this today and in the following section of code in the GameEngine.cpp implementation…

// Create game instance.  For GameEngine, this should be the only GameInstance that ever gets created.
	{
		FStringClassReference GameInstanceClassName = GetDefault<UGameMapsSettings>()->GameInstanceClass;
		UClass* GameInstanceClass = (GameInstanceClassName.IsValid() ? LoadObject<UClass>(NULL, *GameInstanceClassName.ToString()) : UGameInstance::StaticClass());
		
		GameInstance = ConstructObject<UGameInstance>(GameInstanceClass, this);

		GameInstance->InitializeStandalone();
	}

The GameInstanceClass variable is coming back NULL.

EDIT: I’m now stepping through and using the Immediate Window and for the name of the asset, I’m getting this which appears correct. I’ve substituted the name of the game with ‘CustomGameInstance’ instead.

FStringAssetReference: {AssetLongPathname=L"/Game/Core/Blueprints/CustomGameInstance.CustomGameInstance_C" }

But following that, the GameInstanceClass comes back NULL and the engine cant unfortunately construct it. The weird part is if I have the GameInstance Class in the Project Settings set to the default, one of my levels has some reference to it from past linker issues and also causes the project to crash upon opening the level. I need to jump on this one quick and I’m building 4.6.0 from source so once a fix is implemented, can you point me to the github commit so I can copy it over to the source on my PC, thanks and let me know if you guys need any more info.

Thanks!

Okay, now I’m in trouble guys. So I’ve tried creating a brand new GameInstance class and just copied everything over. The same error happens. I then tried to use the default engine GameInstance class and Visual Studio is catching an error while the rendering engine is processing Render Target management. That error may be related to something else entirely and only fails in the RHI code since it probably is sitting on another thread. When running the game inside the editor and not as DebugGame or a Published Build, it works fine inside the editor. I’ll be tackling this today and trying to slay this dragon before you guys get to me but let me know your thoughts so I can get past this. Thanks

On a positive note, I was able to get the staging builds to work setting the GameInstance to the default class and found an issue in my Joystick Plugin that needed to be changed due to changes from 4.5.1 to 4.6. After fixing it, I was able to get the staging builds running but I cant use a custom GameInstance class since it’s trying to construct it from a NULL class object. GameInstance unfortunately hasn’t been too stable since release and has been causing me a lot of issue from when it first came out. I’m going to keep my fingers crossed on this one. Thanks!

As a general question, does the engine with every upgrade go through all the Blueprints and re-compile them upon first start? If so or if not, is there a way to force this? I’m going to try and determine why the class is coming back NULL in the meantime today if I can and if I figure something out, I’ll let you guys know. Otherwise keep me posted on your feedback.

Thanks guys!

Hi MC Stryker,

I tried to set up a project to reproduce this and was unable to do so with a custom GameInstance class. Would you be able to provide some additional information?

  • If you are seeing a crash, can you provide the callstack and logs for the crash?
  • Do you see the same issue in a new project created in 4.6, or only in the project that you upgraded to 4.6?
  • Did you upgrade your project from 4.5.1, or from another version?
  • Is this an issue that you were also experiencing in the previous version of your project?

Hey ,

Sorry about the delay and thanks for jumping in. Let me get back to you in the morning and I’ll post up some details for you. Thanks.

Here you can find a zip with the log output…

The issue is appearing in a project that started on version 4.0.1 and has been upgraded throughout the updates to UE4. The last version that I upgraded from was 4.5.1.

And to answer you question about previously seeing this, yes. I reported issues with GameInstance on multiple occasions back when it was released I want to say around 4.3 and I have a feeling it has to do with the fact it has a variable that references a custom Blueprint-defined struct. I’m not sure but I have feeling it’s related to it since my previous versions had that in common and suffered the same. This has been the first time I’ve run DebugGame as the build config from Visual Studio and noticed where it caught the exception but I didn’t build this before and would experience the crashing in the editor so I can’t say for sure, it’s the same thing, but I’m nearly positive since this emulates what I experienced in the past. Quite honestly, I’ve had to re-create this class a couple times since GameInstance was available but it still seems to be very unstable.

Thanks and let me know your thoughts and if there is anything else I can investigate. Take care

I ran some tests with a project upgraded from 4.5.1 to 4.6.0 built in DebugGame configuration, and even though I was able to trigger a breakpoint, it looks like it is something different from what you were seeing (mine is failing in some Internationalization code that I believe I have seen before, just need to remember how to resolve it).

How have you set up your reference to the Blueprint Struct that you are using?

Hi MC Stryker,

We have not heard back from you for a few days. Do you still need assistance with this issue? I will be marking this question as resolved for tracking purposes, but please feel free to re-open this question at any time if you still need help.

Hey ,

Thanks for taking some time to try and replicate this. I seriously apologize about being absent lately. I’m working real hard to get some things worked out but I will revisit this again once I get back to it and maybe it will be resolved by then. If not, I’ll work on this with you to get you the information you need. Thanks again for the continued support and have a great week!

Whenever you find a to dig into this again, please let us know. I will leave this as resolved for now, but I will continue to poke at it periodically. I will also see if I can find out anything about plans to improve stability of the GameInstance class in the future.

Sure thing and I appreciate it. It should be around the time 4.7 drops that I can take a look at it again with you. My situation just got very tight so I’m rushing around trying to get things stable to continue. But likely within the next week or two hopefully I can reach back out. Thanks again

Okay , I’m back bud. I’m going to test this now in 4.6.1 and see if I experience the same thing. I apologize about such a hiatus, I’ve been trying to get my company off the ground for funding but had to unfortunately turn down an unpredictable publishing offer so I’ve had many nights of eating hot pockets and starting to look for work to bootstrap my company UltraStorm to say the least. It’s been rough but thanks for the patience. Let me check this out and let’s team up to get to the core of this issue, I noticed in the release notes for 4.7 that you resolved an issue with GameInstance so I’m wondering if you guys found it. Let me check the build in 4.6.1 right now and I’ll get back to you. BTW, if you want to see an early look on the project I’ve been working on, you can goto http://AngelList.com/UltraStorm to go check it out. Thanks !

Looks good to go! I just ran a couple builds and also produced a staging build and it was able to run fine without crashing so that’s good. I still saw a problem though with GetChildrenComponents returning in an odd order and also ran into this problem… Begin/End overlap issue - Blueprint - Epic Developer Community Forums but the issue with GameInstance seems to be dormant again. If anything changes in 4.7, I’ll let you know. Thanks !

I am glad to hear that this issue seems to have gone away. If you run into it again, please let us know.

Absolutely and thanks again for your assistance. Gotta love when it resolves itself :smiley:

I hope you and the team have a great week and looking forward to the 4.7 release. Take it easy