StateTree Debugging a Standalone Game

Could you tell if it’s possible to live-debug a StateTree running in a standalone game? Especially when it comes to a global StateTree attached to a UObject. For example, I’m testing a multiplayer game from the editor, one of the clients is a separate editor process and I want to debug its global StateTree. What is the expected debugging flow? The built-in “legacy” StateTree Debugger doesn’t show the standalone session in the dropdown. The RewindDebugger doesn’t let me attach to another session when a PIE is already running (and it doesn’t seem to show non-component StateTrees). Maybe it’s possible to see the state transitions in Unreal Insights somehow?

You should be able to launch the standalone session with the argument “-messaging” to allow Rewind Debugger to find that environment. The argument can be added in the Editor Settings under Level Editor - Play. You then need to start the RWD in the standalone which allows the RWD in the editor to see the session.

Other ways to debug is to use Visual Logger and Gameplay Debugger. Visual Logger logs everything for StateTree when it ticks to include conditions, parameters, transitions, etc. It is the same log data that is shown in the RWD. Gameplay Debugger allows for real-time debugging showing current active tasks and state hierarchy. It is all real-time so you can only look at what is currently happening at that moment.

-James

Thank you for your response, James. To be precise, I’m looking to debug a global StateTree, attached to a GameInstance.

Indeed, I can attach RWD to a standalone game when I start it via the “RewindDebugger.StartRecording” console command. But it doesn’t show the GameInstance in the list of recorded objects.

Using the GameplayDebugger would be great, but I think it relies on the “debug actor” concept and doesn’t allow me to see a global state tree in the “Behaviour Tree” panel.

Is it possible to make the VisualLogger connect to an external trace from the standalone game? I couldn’t find an option for this.

The only debug window that I managed to record my PIE state transitions with is the “legacy” StateTree Debugger. When I start RWD recording in the standalone, the ST Debugger seems to add an entry in the list of sessions, but alas, when I select it, I see nothing inside.

Does the GameInstance StateTree show up in the RWD if you utilize the standard PIE instead of launching the standalone? It should have the same info regardless of being PIE or standalone, but we may not capture GameInstance in RWD.

As for launching VisualLogger for the standalone, you can run the command VisLog in the console to open the visual logger window for the standalone game. You will then need to start the VisLog recording, but it will gather all of the visual logger information from the standalone session. It should allow you to save it as well to be loaded in at a later time. Visual Logger does not use the trace system like RWD or Insights, instead it has its own file type (vlog).

-James

Sorry for a delayed response - I’ve switched to other tasks. But I will come back to my StateTree at some point!

No, that GameInstance StateTree doesn’t show up in the RWD no matter where I use it. I was only able to see my state tree in the legacy StateTree Debugger when running via PIE. The VisualLogger doesn’t show it either, but I haven’t investigated it deeply enough.

If you run the standalone game with the -messaging command line argument, can you see the standalone environment in the StateTree Debugger panel in the StateTree editor? You should be able to select the instance of the StateTree asset that is running and cause it to load in the RWD even though it is not normally included. I am checking with our debug tool owner for StateTree if they have other ideas for how to do this as well.

-James

Thank you James. Yes, when I run a standalone game with the -messaging argument, an entry is added to the StateTree Debugger session drop-down. But when I select it, nothing happens - as if no data is coming in. Toggling “Start Tracing” in Unreal Insights Frontend for these standalone sessions doesn’t have an effect. I’m on UE 5.7.1.

About the VisualLogger track - I can in fact see the GameInstance StateTree of the PIE session in there. But it’s not nearly as convenient to use as the legacy StateTree Debugger. And as you said, it’s not able to connect to a running standalone instance - so I won’t call it an equivalent alternative :slight_smile:

I believe the issue is that the GameInstance does not call to be traced when it starts. You could try adding TRACE_OBJECT_LIFETIME_BEGIN(this) to your custom GameInstance Init method and then in the Shutdown method add TRACE_OBJECT_LIFETIME_END(this). You might also want to start an explicit trace for the StateTree owned by the game instance with TRACE_OBJECT_LIFETIME_BEGIN_WITH_OUTER. I believe this should allow the data to be traced and able for the RWD to collect the relevant data. I am curious if you will need to type the name of the GameInstance to find it as the picker tool looks for actors in the level by default.

I do understand that VisLog is not the ideal tool for this. With the move to Rewind Debugger, it is largely actor centric and some use cases like yours were not included in our tests. I know we are working on adding more to RWD, so it is possible that we cover your particular use case in some of the currently planned work.

-James

I will bring this up with our dev who has been working on RWD to see if he has other ideas for how to get this working. It seems like there may be a couple issues at play preventing everything. The dev is currently out of the office, but they are also the one who would be best placed to answer this. They worked on the ST debugger and then began work on integrating it into RWD while extending the RWD.

-James

Thanks James, FYI I’m using a GameInstance Subsystem as a StateTree runner, not the GameInstance itself. I’ve added the suggested trace calls to the subsystem’s Initialize() and Deinitialize(), but this didn’t seem to have any effect. The Rewind Debugger still doesn’t show the state tree. TRACE_OBJECT_LIFETIME_BEGIN_WITH_OUTER doesn’t seem to exist in the 5.7.1 engine, so I’ve used a regular TRACE_OBJECT_LIFETIME_BEGIN on the StateTree asset - without any effect, unfortunately.

I’ve also realized that RWD wasn’t working at all for me because I play the game as a listen server (due to https://issues.unrealengine.com/issue/UE\-208850\). This is definitely a blocker for us, because we are working on a multiplayer game and the statetree is actually managing the connection states. But even when running as Standalone, the gameinstance state tree doesn’t show up in the RWD’s list.