[BP Compilation Manager] WorldContextObject is null in BP function library

It’s annoying issue we’ve encountered just after updating to 4.17.
We use BP function library to call methods like GetGameInstance(), GetPlayerController(). They require WorldContextObject which should automatically retrieved by method call placed in custom library’s function. Sadly functions like GetGameInstance() are provided with WorldContextObject = null.
It does happen in 4.17 with BP Compilation Manager turned on.
We didn’t notice any problems outside of function library.

Repro

  1. Create a blueprint function library.
  2. Add function which simply returns game instance by calling GetGameInstance(), GetPlayerController() or similar. Probably using every function with WorldContextObject will reproduce a bug.
  3. Call this function in any actor or level BP.
  4. Restart editor. It seems crucial - at some point I though I fixed issue by renaming function library file (there were no errors). But errors came back after reopening project.
  5. Play game - make sure you call method from point 2.
  6. Stop game. You should get message “There were errors in game” and list of errors in Messages window.

There are two workarounds for this issue.
A) Turn off Blueprint Compilation Manager in Project Settings.
B) Pass WorldContextObject from object calling this library’s function. It’s nasty and makes function library not that convenient…

Hello kjustynski,

I was unable to reproduce this issue on our end with the information provided. I have provided a screen shot of the function in the function library that I used. This setup appears to work without error on my end. Could give this a try and let me know if it works for you?

Example:

3 days after releasing there’re already a lot of reports on this particular issue. This should be a new and critical bug of 4.17. Print string works fine. However GetAllActorsOfClass inside a function library doesn’t work, not all of the time. It’s fairly unpredictable. Sometimes it works without changing anything. All were fine in 4.16 and I didn’t touch anything.

I’m listing a few similar reports below. They’re all 4.17 and posted within days. With all due respect please invest more resource in resolving this. A tracker link or “unable to reproduce this” doesn’t help. This bug is hell because I’ve done a lot of work in 4.17 before it going rogue. Thank you.

I have to admit it was difficult to find a stable repro with fresh functions.
So… I created a stripped down project with just few scripts necessary to lure out this bug.

It’s should be easy to catch it now. Just open a project and hit Play button :slight_smile:
https://drive.google.com/open?id=0B8f7otnD-QKBUEZkR2lWVFVkMHc

To be perfectly clear on this: recompiling or renaming script calling library’s function can “temporarily” fix the issue. It’s coming back after restarting the project.

For those who may need an emergent solution. You can make a C++ AActor and put it in the level as a world context ‘anchor’, which could later be referenced by blueprint function library. Declare:

static UObject* WorldContextAnchor;

Put the actor in your level. Add this in the constructor:

WorldContextAnchor = this;

Then make a UBlueprintFunctionLibrary class which reads this static variable and pass it to BP function library as an effective world context (anything in a world can be used as world context). A bit dirty but at least my project is not completely dead now.

Wow… how can they miss that?

That’s a lot of efforts. Personally, I prefer to stay with the previous release until this bug is fixed.

The compilation manager can be disabled via the project settings menu. I’m taking a look at this issue now, but don’t let it block you from using other 4.17 features!

Hello kjustynski,

EDIT:

Was able to reproduce issue the issue using project provided.

Sorry for the confusion - this has been logged as UE-48464 (thanks kjustynski for the project!). Here is the fix. I will update this answer when I know what binary release this is a part of - but it should be 4.17.2.

Link fix - 404.

If the link appears as a 404 make sure you’re logged in to a github account that is associated with your Epic Games account.

Is there a way to disable the compilation manager from outside the project?

I am unable to launch my project since migrating to 4.17.2. I’m thinking this is the culprit.

Yes
Edit DefaultEditor.ini

[/Script/UnrealEd.BlueprintEditorProjectSettings]

bUseCompilationManager=False

This is a CRAPPY issue. What I have done was, reference all my World objects from getting a function.
That made it.

UWorld* USomeClass::GetMyWorld() {
	if ( ensure( ValidActor) && ensure( ValidActor->GetWorld() ) )
		return ValidActor->GetWorld();

	return nullptr;
}