[Networking] Why am I crashing when I have multiple client play in editor windows?

When I launch a game with multiple windows to test multiplayer functionality, the editor will crash when loading the map for the client. This happened in both 4.0.1 and 4.0.2. As a standalone-development build, it is fine so it is definitely editor related.

The crash happens here at line 9821 of UnrealEngine.cpp (V4.0.2):

NewWorld = UWorld::DuplicateWorldForPIE(SourceWorldPackage, NULL);

WorldPackage = CastChecked(NewWorld->GetOuter());

It crashes when DuplicateWorldForPIE returns null and NewWorld->GetOuter causes the access violation.

Stepping through the code, DuplicateWorldForPIE returns null on line 1868 of World.cpp (V4.0.2):

UPackage* EditorLevelPackage = FindObjectFast( NULL, FName(*PackageName)); if( !EditorLevelPackage ) return NULL;

The value of SourceWorldPackage is L"/Game/Maps/Oakleigh".

Hi ZachGriffin,

Would you mind posting your dxdiag and your logs so we can get a look at what may be causing your crash? Thank you!

Thanks Adam! Attached.

Log

DxDiag

Hi Zach,

I was unable to reproduce the issues you described. Here is what I did to reproduce it:

  1. Open ShooterGame
  2. Go to the play dropdown menu
  3. Go to network settings > Number of clients
  4. Set it to 10.
  5. click Play in editor.

If you follow my steps as listed above in shootergame, do you get the same crash or is this limited to your project?

Thank you!

Hi Zach, I believe there is just a missing NULL check in DuplicateWorldForPIE. This bug was introduced right before 4.0.2 was available on github. I am not sure why it was crashing for you in 4.0.1.

The code in that function now looks like this:

	if ( OwningWorld )
	{
		const FString PlayWorldMapName = ConvertToPIEPackageName(OwningWorld->GetOutermost()->GetName(), WorldContext.PIEInstance);

		PackageNamesBeingDuplicatedForPIE.Add(PlayWorldMapName);
		for (auto LevelIt = OwningWorld->StreamingLevels.CreateConstIterator(); LevelIt; ++LevelIt)
		{
			ULevelStreaming* StreamingLevel = *LevelIt;
			if (StreamingLevel)
			{
				const FString StreamingLevelPIEName = UWorld::ConvertToPIEPackageName(StreamingLevel->PackageName.ToString(), WorldContext.PIEInstance);
				PackageNamesBeingDuplicatedForPIE.Add(StreamingLevelPIEName);
			}
		}
	}

Thanks Dave. What line of World.cpp should that snippet start? I noticed the container PackageNamesBeingDuplicatedForPIE is undefined and couldn’t find a reference to this snippet in the trunk.

Hey Zach, sorry I think I got my wires crossed. The bug I was thinking of never made it to github. I stepped through the code a little more closely and see your problem is different.

The question is why does your FindObjectFast call return NULL. Looking at your logs and SourceWorldPackage - I don’t see what is wrong. Your map is named /Game/Maps/Oakleigh according to the logs yet FindObjectFast doesn’t find it.

Could you try doing:

obj list class=Package name=/Game/Maps/Oakleigh

In the editor console before you hit PIE? Look at the output log and see what it finds. My only guesses right now are that something is corrupt/mangled in your URL or something crazy like your (editor) map is getting garbage collected somewhere int the PIE startup sequence.

Not a problem Dave. Here’s the output:

Cmd: obj list class=Package name=/Game/Maps/Oakleigh Obj List: class=Package name=/Game/Maps/Oakleigh Objects: 0 Objects (0.000M / 0.000M / 0.000M / 0.000M)

I have a feeling this is also the reason why the game won’t load the Oakleigh map in a standalone shipping build. It works fine in Debug though. I’ll do some more digging.

Hi Adam,

It’s definitely limited to my project. Shootergame works fine and loads all windows. I suspect the problem has to do with a corrupt URL, and is linked with the issue I’m experiencing in a standalone shipping build, where the game fails to load the ‘Oakleigh’ map but doesn’t crash. I’ll keep looking to see what could cause it. The project is also up on GitHub, so I can add you and Dave to the repo if needed/helpful.

Thanks!

Hi Dave,

I’ve continued searching for the cause of this, but to no avail. It appears as though the URL is incorrect based on the crash data, though it looks fine based on the log output. Do I need to define any other references to the level or are there any special characters that I should be aware of?

What does the URL look like? My original thought was that something in that string was being corrupted and you weren’t actually trying to load /Game/Maps/Oakleigh. You could break in the debugger in DuplicateWorldForPIE and carefully inspect the PackageName string.

FWIW, there is nothing special you should have to do, but you may be exposing something (not sure what) that we’ve never seen or tried before. If the URL/PackageName doesn’t turn up anything I think you would need to start isolating the problem more by doing things like - save Oakleigh to a different name. Make a new map in the same project; if that empty map works in multi PIE, then start adding stuff from until it breaks, etc.

Hi Adam,

I’ve now managed to reproduce the bug in the Shooter example and isolate it to playing the game from the menu rather than one of the levels. To reproduce it:

  1. Open ShooterGame
  2. Open ShooterEntry level
  3. Set number of clients to 2.
  4. click Play in editor.

It’s the same in my project. If I launch from the menu, it won’t find the level. If I launch directly from a level, it works as expected.

Hi Dave,

I just updated my post to Adam above. I was able to reproduce the bug in the Shooter example if I launch the game from the menu, rather than one of the game levels. To reproduce it:

  1. Open ShooterGame
  2. Open ShooterEntry level
  3. Set number of clients to 2.
  4. click Play in editor.

It’s the same in my project. If I launch from the menu, it won’t find the level. If I launch directly from a level, it works as expected.

Hi ZachGriffin,

I was able to reproduce the crash based on the steps you provided. I am attaching this to the bug report for the developers to assess. Thank you and have a great day!

Hey Zach - just to confirm, this only happens when you are launching from the menu? This is true for both the shooter game repro and your case? (Or is your case giving this error when launching directly into the level)?

Hi Dave,

Yes it only happens when launching from the menu. It happens in both the shooter game repro and my project which uses snippets of the shooter menu code. Adam Davis has now added this to the bug tracker.