Game Crash - Runnable thread OnlineAsyncTaskThreadSteam DefaultInstance crashed.

Hello,

I am trying to make a steam callback that will Pause the game when the Steam Game Overlay becomes activated.

So, Far, I have managed to get the Steam Callback working, and it fires an event in Blueprints that pauses the game. However, a few ms after, the game crashes. Here is the Output Log.

[2017.02.27-04.16.14:296][282]LogLoad: Took 0.403313 seconds to LoadMap(/Game/MusicShoot/Maps/TestPianoBP)
[2017.02.27-04.16.14:889][282]LogBlu: Component Initialized
[2017.02.27-04.16.14:889][282]LogBlu: Loading URL: about:blank
[2017.02.27-04.18.56:569][378]LogSteamworks: Overlay is ACTIVE
[2017.02.27-04.18.56:569][378]LogSteamworks: Calling Event OnSteamOverlayIsActive
[2017.02.27-04.18.56:569][378]LogSteamworks: Music Should be paused now
[2017.02.27-04.18.56:569][378]LogSteamworks: Overlay is ACTIVE
[2017.02.27-04.18.56:569][378]LogSteamworks: Calling Event OnSteamOverlayIsActive
[2017.02.27-04.18.56:569][378]LogBlueprintUserMessages: [Default__BP_MusicalRangeInstance_C] Steam Overlay Event Triggertrue
[2017.02.27-04.18.56:569][378]LogScript:Warning: Accessed None trying to read property ShootTrackPlayer
	BP_MusicalRangeInstance_C /Game/MusicShoot/Blueprints/BP_MusicalRangeInstance.Default__BP_MusicalRangeInstance_C
	Function /Game/MusicShoot/Blueprints/BP_MusicalRangeInstance.BP_MusicalRangeInstance_C:ExecuteUbergraph_BP_MusicalRangeInstance:0108
[2017.02.27-04.18.56:569][378]LogSteamworks: Music Should be paused now
[2017.02.27-04.18.56:569][378]LogSteamworks: Overlay is ACTIVE
[2017.02.27-04.18.56:569][378]LogSteamworks: Calling Event OnSteamOverlayIsActive
[2017.02.27-04.18.56:569][378]LogBlueprintUserMessages: [BP_MusicalRangeInstance_C_0] Steam Overlay Event Triggertrue
[2017.02.27-04.18.56:569][378]LogOutputDevice:Warning: 

Script Stack:
BP_ShootTrackPlayer_C.ExecuteUbergraph_BP_ShootTrackPlayer
BP_ShootTrackPlayer_C.PauseSongWav
BP_ShootTrackPlayer_C.ExecuteUbergraph_BP_ShootTrackPlayer
BP_ShootTrackPlayer_C.PauseSong
BP_ShootTrackPlayer_C.ExecuteUbergraph_BP_ShootTrackPlayer
BP_ShootTrackPlayer_C.SteamTriggerPause
BP_MusicalRangeInstance_C.ExecuteUbergraph_BP_MusicalRangeInstance
BP_MusicalRangeInstance_C.OnSteamOverlayIsActive

[2017.02.27-04.18.56:628][378]LogWindows: Windows GetLastError: The operation completed successfully. (0)
[2017.02.27-04.18.58:500][381]LogThreadingWindows:Error: Runnable thread OnlineAsyncTaskThreadSteam DefaultInstance crashed.
[2017.02.27-04.18.58:500][381]LogWindows:Error: === Critical error: ===
[2017.02.27-04.18.58:500][381]LogWindows:Error: 
[2017.02.27-04.18.58:500][381]LogWindows:Error: Assertion failed: IsInGameThread() [File:d:\unrealengine\unrealengine4-14\engine\source\runtime\engine\public\EngineUtils.h] [Line: 176] 
[2017.02.27-04.18.58:500][381]LogWindows:Error: 
[2017.02.27-04.18.58:500][381]LogWindows:Error: 
[2017.02.27-04.18.58:500][381]LogWindows:Error: 
[2017.02.27-04.18.58:500][381]LogWindows:Error: KERNELBASE.dll
[2017.02.27-04.18.58:500][381]LogWindows:Error: MusicalRange.exe
[2017.02.27-04.18.58:500][381]LogWindows:Error: MusicalRange.exe
...
[2017.02.27-04.18.58:520][381]LogWindows:Error: MusicalRange.exe
[2017.02.27-04.18.58:520][381]LogWindows: Windows GetLastError: The operation completed successfully. (0)
[2017.02.27-04.18.58:520][381]LogWindows:Error: alRange.exe
[2017.02.27-04.18.58:520][381]LogWindows:Error: HandleError re-entered.
[2017.02.27-04.18.58:520][381]LogWindows: FPlatformMisc::RequestExit(1)
[2017.02.27-04.18.58:520][381]LogWindows:Error: 
[2017.02.27-04.18.58:531][381]LogThreadingWindows:Error: Runnable thread RenderThread 4 crashed.
[2017.02.27-04.18.58:531][381]LogWindows:Error: HandleError re-entered.
[2017.02.27-04.18.58:531][381]Log file closed, 02/26/17 22:18:58

From the logs, I can confirm that the steam callback is calling the event to pause the game

[2017.02.27-04.18.56:569][378]LogSteamworks: Calling Event OnSteamOverlayIsActive

And that the blueprint is firing the Pause Event with the bool variable of True (IsActive)

[2017.02.27-04.18.56:569][378]LogBlueprintUserMessages: [Default__BP_MusicalRangeInstance_C] Steam Overlay Event Triggertrue

But I don’t understand why “Runnable thread OnlineAsyncTaskThreadSteam DefaultInstance crashed.” is crashing just a few milliseconds after.

I have been going at this problem for over a week and a half, and I feel like I am so close now. Just this little issue.
Let me know if you need any more info that I may provide.

Hi Motanum,

The real issue is this line here:

[2017.02.27-04.18.58:500][381]LogWindows:Error: Assertion failed: IsInGameThread() [File:d:\unrealengine\unrealengine4-14\engine\source\runtime\engine\public\EngineUtils.h] [Line: 176] 

Steam callbacks happen on a different thread than the game. Any event that happens needs to be safely forwarded to the Game thread before calling into engine functionality. An easy way to accomplish this is by the ExecuteNextTick function of the base OnlineSubsystem. Here’s an example:

void FOnlineSubsystemSteam::SomeSteamCallback(int SomeValue)
{
    // Copy our values into the game thread
    LiveSubsystem->ExecuteNextTick([SomeValue, this]()
    {
        DoSomethingOnGameThread(SomeValue);
    });
}

Hope that helps!

Thanks for the Reply, I am not sure if I understood correctly, so I am explaining what changes I am making absed on your replay.

For context, I am making my own class to handle SteamCallbacks, so that I understand better how it works without modifying UE4’s classes.

I have a MusicalRangeGameInstance heritance of game Instance, to handle the events to blueprints. And I had to create another non UCLASS called FSteamworksCallbackAsync.

The function where I trigger game pause when the Game overlay is active is (Taking out all UE_LOGs)
void FSteamworksCallbackAsync::OnSteamOverlayActive(GameOverlayActivated_t *CallbackData) {

	bool IsOverlayActive = (CallbackData->m_bActive != 0);
	if (MusicalRangeGameInstance != nullptr)
	{
		MusicalRangeGameInstance->OnSteamOverlayIsActive(IsOverlayActive);
	}
}

I think LiveSubsystem is FOnlineSubsystemSteam *LiveSteamSubsystem

So, in the class definition I have:

FOnlineSubsystemSteam *LiveSteamSubsystem;

The Constructor of FSteamworksCallbackAsync has:

	LiveSteamSubsystem->Init();

The Deconstructor has

 	LiveSteamSubsystem->Shutdown();

The Function OnSteamOverlayActive (Again Taking out the UE_LOGs) is:

void FSteamworksCallbackAsync::OnSteamOverlayActive(GameOverlayActivated_t *CallbackData) {
	LiveSteamSubsystem->ExecuteNextTick([CallbackData, this]() {
		bool IsOverlayActive = (CallbackData->m_bActive != 0);
		if (MusicalRangeGameInstance != nullptr)
		{
			MusicalRangeGameInstance->OnSteamOverlayIsActive(IsOverlayActive);
		}
	});
}

So, is this correct? I am gonna try this next, but it’s gonna take like hour an a half to compile, Package, upload/Download to Steam and test.

Thanks Again!

That looks roughly correct, however you should not store a pointer to Steam callback information; it has a very small lifetime and may not exist outside of the function call. You will need to make a copy of that struct and then copy that copy again into the ExecuteNextTick lamda.

Your example should look something like this:

 void FSteamworksCallbackAsync::OnSteamOverlayActive(GameOverlayActivated_t *CallbackData)
{
     check(CallbackData != nullptr);

     GameOverlayActivated_t DataCopy = *CallbackData;
     LiveSteamSubsystem->ExecuteNextTick([DataCopy, this]() {
         bool IsOverlayActive = (DataCopy.m_bActive != 0);
         if (MusicalRangeGameInstance != nullptr)
         {
             MusicalRangeGameInstance->OnSteamOverlayIsActive(IsOverlayActive);
         }
     });
 }

Or, even better, if you only care about that bool, it’s much more efficient to copy only that value, like this:

 void FSteamworksCallbackAsync::OnSteamOverlayActive(GameOverlayActivated_t *CallbackData)
{
     check(CallbackData != nullptr);

     const bool IsOverlayActive = (CallbackData->m_bActive != 0);
     LiveSteamSubsystem->ExecuteNextTick([IsOverlayActive, this]() {
         
         if (MusicalRangeGameInstance != nullptr)
         {
             MusicalRangeGameInstance->OnSteamOverlayIsActive(IsOverlayActive);
         }
     });
 }

Thanks again! I have typed your changes.
TESTING

WELL. IGNORE BELLOW. IT COMPILED!

However I haven’t been able to compile since my last post. I can’t seem to add:

#include "OnlineSubsystemSteam.h"

Which has the class FOnlineSubsystemSteam. I get the error " Cannot open include file: ‘OnlineSubsystemSteam.h’ ".

I have tried to look at this thread

But I am being unlucky. The OnlineSubsystemSteam.h path is UE4/Plugins/Online/OnlineSubsystemSteam/Source/Public/onlineSubsystemSteam.h

Would you mind helping with that?

This is what my build.cs file looks like. It’s a Frankenstein and I barely have a clue of what I am doing.

public class MusicalRange : ModuleRules
{
	public MusicalRange(TargetInfo Target)
	{
		PublicDependencyModuleNames.AddRange(new string[] { "Core", 
            "CoreUObject",
            "Engine",
            "InputCore",
			"OnlineSubsystem", //From https://wiki.unrealengine.com/Steam_workshop
            "OnlineSubsystemUtils",
            "Steamworks",            //*/
            "OnlineSubsystemSteam"
        });

		PrivateDependencyModuleNames.AddRange(new string[] {  });

		// Uncomment if you are using Slate UI
		// PrivateDependencyModuleNames.AddRange(new string[] { "Slate", "SlateCore" });
		
		//Uncomment if you are using online features
		PrivateDependencyModuleNames.Add("OnlineSubsystem");

		// To include OnlineSubsystemSteam, add it to the plugins section in your uproject file with the Enabled attribute set to true
		
		PublicIncludePaths.AddRange(new string[] {"Plugins/Online/OnlineSubsystemSteam/Public", "Plugins/Online/OnlineSubsystemSteam/Classes" });
	}
}

Huge Thanks again!

Hey, After fiddling a lot to get LiveSteamSubsystem->ExecuteNextTick() work, the game still crashes when I activate the game Overlay in my game. This time before ExecuteNextTick function fires, as I don’t see any of the log messages.

[2017.02.28-02.15.26:952][282]LogGameState: Match State Changed from WaitingToStart to InProgress
[2017.02.28-02.15.26:957][282]LogLoad: Took 0.415599 seconds to LoadMap(/Game/MusicShoot/Maps/TestPianoBP)
[2017.02.28-02.15.27:511][282]LogBlu: Component Initialized
[2017.02.28-02.15.27:511][282]LogBlu: Loading URL: about:blank
[2017.02.28-02.15.48:174][863]LogWindows: InterlockedExchangePointer requires Dest pointer to be aligned to 8 bytes
[2017.02.28-02.15.48:176][863]LogWindows: Windows GetLastError: The operation completed successfully. (0)
[2017.02.28-02.15.49:199][870]LogThreadingWindows:Error: Runnable thread OnlineAsyncTaskThreadSteam DefaultInstance crashed.
[2017.02.28-02.15.49:199][870]LogWindows:Error: === Critical error: ===
[2017.02.28-02.15.49:199][870]LogWindows:Error: 
[2017.02.28-02.15.49:199][870]LogWindows:Error: Assertion failed: 0 [File:D:\UnrealEngine\UnrealEngine4-14\Engine\Source\Runtime\Core\Private\Windows\WindowsPlatformAtomics.cpp] [Line: 16] 

[2017.02.28-02.15.49:199][870]LogWindows:Error: 
[2017.02.28-02.15.49:199][870]LogWindows:Error: KERNELBASE.dll
[2017.02.28-02.15.49:199][870]LogWindows:Error: MusicalRange.exe

The Header FIle

The CPP file

I dunno what’s going on with the “Runnable thread OnlineAsyncTaskThreadSteam DefaultInstance crashed.”

So, the game still crashes. I think this is an issue due to the secondary Online subsystem functionality that I used for the Leaderboards. But I cannot confirm anything without Epic’s help I think, as I don’t really understand how they did things in OnlineAsyncTaskThreadSteam DefaultInstance. I would really appreciate some help on this issue, I am closer now than I have been, and this problem has be frustrating me for almost 2 weeks now.

The Full Log File

The Header File

The CPP file

Thanks

Still an unresolved problem :frowning:

Solved!

The issue was the game not being in the game thread. I have to make sue of the function AsyncTask() before trying to fire anything from MyGameInstance.

I wrote a guide to help out anyone with a similar issue.

the link to your article is not working, can you renew it , i have the same issue

1 Like