[Bug report] PCG runtime gen scheduler incorrectly detects editor viewport, leading to a crash when Play Credentials are set

PCGRuntimeGenScheduler.cpp attempts to detect the editor viewport like so:

#if WITH_EDITOR
	// If we're in an editor world, stop updating preview if the editor window/viewport is not active (follows
	// same behaviour as other things).
	if (!World->IsGameWorld())
	{
		FViewport* Viewport = GEditor ? GEditor->GetActiveViewport() : nullptr;
		FEditorViewportClient* ViewportClient = Viewport ? static_cast<FEditorViewportClient*>(Viewport->GetClient()) : nullptr;

		if (!ViewportClient || !ViewportClient->IsVisible())
		{
			return false;
		}
	}
#endif

When the editor is signing into the OSS, and before the PIE window is actually created, calling GetClient on the viewport returns a client of type `CommonGameViewportClient` and not `EditorViewportClient`; the static cast is invalid. When the code then calls `IsVisible()`, it crashes because the underlying memory isn’t actually an `FEditorViewportClient`.

[Attachment Removed]

Steps to Reproduce

  • Set up a project with an online subsystem, and set up Play Credentials in editor preferences so that the editor will sign into the OSS before starting the PIE windows.
  • Add an actor with a PCG component to the level - using the default PCG graph is fine.
  • Observe a crash on line 370 of PCGRuntimeGenScheduler.cpp
    [Attachment Removed]

Hi June,

Thanks for reaching out. We weren’t aware of this and will have a look!

Cheers,

Julien

[Attachment Removed]

Hi June!

We fixed it, and it will be in the next release (5.8). I’ll give you the change key when it’s available!

Cheers,

Julien

[Attachment Removed]