Open Level by Reference failing when called from a level opened during PIE

I seem to have accidentally placed this on the wrong category and product version.

It should be on the “Bug Reports” section and on the 4.26 version.

Using the “Open Level by Reference” Blueprint Node (or calling the equivalent function, UGameplayStatics::OpenLevelBySoftObjectPtr) results in a failure to load package if it’s attempted from a map opened during the PIE session (e.g. running an “open level” node during a play session and then attempting to run “open level by reference” from the newly loaded level).

This only happens in PIE and is not present in Standalone or Packaged.

The error itself is printed on line 12873 of UnrealEngine.cpp, found in this section of code:

 // See if the level is already in memory
    		WorldPackage = FindPackage(nullptr, *URL.Map);
    
    		bool bPackageAlreadyLoaded = (WorldPackage != nullptr);
    
    		// If the level isn't already in memory, load level from disk
    		if (WorldPackage == nullptr)
    		{
    			WorldPackage = LoadPackage(nullptr, *URL.Map, (WorldContext.WorldType == EWorldType::PIE ? LOAD_PackageForPIE : LOAD_None));
    		}
    
    		// Clean up the world type list now that PostLoad has occurred
    		UWorld::WorldTypePreLoadMap.Remove( URLMapFName );
    
    		if (WorldPackage == nullptr)
    		{
    			// it is now the responsibility of the caller to deal with a NULL return value and alert the user if necessary
    			Error = FString::Printf(TEXT("Failed to load package '%s'"), *URL.Map);
    			return false;
    		}

This might be related to how levels are cloned during PIE sessions.

Repro Steps:

  1. Create a new project (in my case, I used the third person template)
  2. Add some method to travel back and forth between two levels using both nodes: “Open Level by Reference” and “Open Level by Name” (I created two actors with a collider. When touched, they run the appropriate node).
  3. Play in PIE and try moving back and forth between the levels using the “Open Level by Name” node. It should work as intended.
  4. Play in PIE and try moving back and forth between the levels using the “Open Level by Reference” node. It will fail from the 2nd attempt onwards.
2 Likes

Hello,

We’ve 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.

Thanks

I’m seeing this same issue. Was a bug for this issue ever opened? Issue is present in both UE 4 and UE 5.

Seeing the same issue, as described by @NitroRobotto UE 5.0.3

1 Like

I also have the same problem. I tried to load the level via an instance. But also the same problem. Hope for the new update or that the plugins follow to test.

Small addendum. Found a solution. However, not very nice. I have an instance where I have created a function. Here I remove all widgets and build in a delay of 3. I load via Open Level by Object instead of Name. Important here. I do not load the level directly but an empty level. This has again a delay of 3 and then loads the level.

This thread is two years old and still this bug persists.

Ran into this issue atm and this thread helped.

To be clear, this is UE5. Using UGameplayStatics::OpenLevel failed for all calls after the first, but using UGameplayStatics::OpenLevelBySoftObjectPtr works perfectly fine.

I’m having the same issue but can not perform that little trick of yours. Any chance you can show me the graph of that function ?