question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

CallResult not Called on Steam API 15.0.0 and Higher

See original GitHub issue

I tried upgrading my game from Steam API 14.0.0 to 15.0.0 today and noticed that any CallResults I set are not called back.

I tested again, and shipping the game with the Windows-x64 DLLs from the Steamworks.NET-Standalone_14.0.0 folder works great, but things break when shipping with the DLLs from the Steamworks.NET-Standalone_15.0.1 folder.

I then built the game against the latest GitHub source code and everything worked properly in my debug build, but on my release build the CallResults were not called.

I added the following logging (Console.Writeline) into this function in CallbackDispatcher.cs:

internal static void RunFrame(bool isGameServer)
{
	if (!IsInitialized) throw new InvalidOperationException("Callback dispatcher is not initialized.");

	HSteamPipe hSteamPipe = (HSteamPipe)(isGameServer ? NativeMethods.SteamGameServer_GetHSteamPipe() : NativeMethods.SteamAPI_GetHSteamPipe());
	NativeMethods.SteamAPI_ManualDispatch_RunFrame(hSteamPipe);
	var callbacksRegistry = isGameServer ? m_registeredGameServerCallbacks : m_registeredCallbacks;

	Console.WriteLine($"m_registeredCallbacks.Count: {m_registeredCallbacks.Count}");

	while (NativeMethods.SteamAPI_ManualDispatch_GetNextCallback(hSteamPipe, m_pCallbackMsg))
	{
		Console.WriteLine($"m_pCallbackMsg: {m_pCallbackMsg}");
		CallbackMsg_t callbackMsg = (CallbackMsg_t)Marshal.PtrToStructure(m_pCallbackMsg, typeof(CallbackMsg_t));
		try
		{
			// Check for dispatching API call results
			Console.WriteLine($"callbackMsg.m_iCallback: {callbackMsg.m_iCallback}");
			if (callbackMsg.m_iCallback == SteamAPICallCompleted_t.k_iCallback)
			{
				SteamAPICallCompleted_t callCompletedCb = (SteamAPICallCompleted_t)Marshal.PtrToStructure(callbackMsg.m_pubParam, typeof(SteamAPICallCompleted_t));
				IntPtr pTmpCallResult = Marshal.AllocHGlobal((int)callCompletedCb.m_cubParam);
				bool bFailed;

				bool result = NativeMethods.SteamAPI_ManualDispatch_GetAPICallResult(hSteamPipe, callCompletedCb.m_hAsyncCall, pTmpCallResult, (int)callCompletedCb.m_cubParam, callCompletedCb.m_iCallback, out bFailed);

				Console.WriteLine($"result: {result}");

				if (result)
				{
					lock (m_sync)
					{
						List<CallResult> callResults;
						if (m_registeredCallResults.TryGetValue((ulong)callCompletedCb.m_hAsyncCall, out callResults))
						{
							Console.WriteLine($"callCompletedCb.m_hAsyncCall: {(ulong)callCompletedCb.m_hAsyncCall}");
							m_registeredCallResults.Remove((ulong)callCompletedCb.m_hAsyncCall);
							foreach (var cr in callResults)
							{
								Console.WriteLine($"pTmpCallResult: {pTmpCallResult}");
								Console.WriteLine($"bFailed: {bFailed}");
								Console.WriteLine($"callCompletedCb.m_hAsyncCall: {(ulong)callCompletedCb.m_hAsyncCall}");
								cr.OnRunCallResult(pTmpCallResult, bFailed, (ulong)callCompletedCb.m_hAsyncCall);
								cr.SetUnregistered();
							}
						}
						else
							Console.WriteLine($"m_registeredCallResults: false");
					}
				}
				Marshal.FreeHGlobal(pTmpCallResult);
			}
			else
			{
				List<Callback> callbacks;
				if (callbacksRegistry.TryGetValue(callbackMsg.m_iCallback, out callbacks))
				{
					List<Callback> callbacksCopy;
					lock (m_sync)
					{
						callbacksCopy = new List<Callback>(callbacks);
					}

					foreach (var callback in callbacksCopy)
						callback.OnRunCallback(callbackMsg.m_pubParam);
				}
			}
		}
		catch (Exception e)
		{
			ExceptionHandler(e);
		}
		finally
		{
			NativeMethods.SteamAPI_ManualDispatch_FreeLastCallback(hSteamPipe);
		}
	}
}

On my Debug build, this produced the following output:

m_registeredCallbacks.Count: 16
m_pCallbackMsg: 2282113136656
callbackMsg.m_iCallback: 1281
m_pCallbackMsg: 2282113136656
callbackMsg.m_iCallback: 1222
m_pCallbackMsg: 2282113136656
callbackMsg.m_iCallback: 1281
m_pCallbackMsg: 2282113136656
callbackMsg.m_iCallback: 1006
m_pCallbackMsg: 2282113136656
callbackMsg.m_iCallback: 703
result: False
m_pCallbackMsg: 2282113136656
callbackMsg.m_iCallback: 703
result: False
m_pCallbackMsg: 2282113136656
callbackMsg.m_iCallback: 703
result: True
callCompletedCb.m_hAsyncCall: 14108606187866503733
pTmpCallResult: 2282384251984
bFailed: False
callCompletedCb.m_hAsyncCall: 14108606187866503733
OnEncryptedAppTicketResponse called successfully
m_pCallbackMsg: 2282113136656
callbackMsg.m_iCallback: 336
m_pCallbackMsg: 2282113136656
callbackMsg.m_iCallback: 304
m_pCallbackMsg: 2282113136656
callbackMsg.m_iCallback: 711
m_pCallbackMsg: 2282113136656
callbackMsg.m_iCallback: 703
result: True
m_registeredCallResults: false
m_pCallbackMsg: 2282113136656
callbackMsg.m_iCallback: 504
m_pCallbackMsg: 2282113136656
callbackMsg.m_iCallback: 304
m_pCallbackMsg: 2282113136656
callbackMsg.m_iCallback: 715
m_pCallbackMsg: 2282113136656
callbackMsg.m_iCallback: 711
m_pCallbackMsg: 2282113136656
callbackMsg.m_iCallback: 903
m_pCallbackMsg: 2282113136656
callbackMsg.m_iCallback: 501
m_pCallbackMsg: 2282113136656
callbackMsg.m_iCallback: 502
m_pCallbackMsg: 2282113136656
callbackMsg.m_iCallback: 703
result: True
callCompletedCb.m_hAsyncCall: 16172418149805613628
pTmpCallResult: 2282376711072
bFailed: False
callCompletedCb.m_hAsyncCall: 16172418149805613628
[WORKSHOP] CreateQueryUserUGCRequest (8) RESPONSE: False, 10 results
m_pCallbackMsg: 2282113136656
callbackMsg.m_iCallback: 715
m_pCallbackMsg: 2282113136656
callbackMsg.m_iCallback: 703
result: False
m_pCallbackMsg: 2282113136656
callbackMsg.m_iCallback: 304
m_pCallbackMsg: 2282113136656
callbackMsg.m_iCallback: 304
m_pCallbackMsg: 2282113136656
callbackMsg.m_iCallback: 1281
m_pCallbackMsg: 2282113136656
callbackMsg.m_iCallback: 1222
m_registeredCallbacks.Count: 16
m_registeredCallbacks.Count: 16
m_registeredCallbacks.Count: 16
m_registeredCallbacks.Count: 16
m_registeredCallbacks.Count: 16

On my Release build, it produced the following output:

m_registeredCallbacks.Count: 16
m_registeredCallbacks.Count: 16
m_registeredCallbacks.Count: 16
m_registeredCallbacks.Count: 16
m_registeredCallbacks.Count: 16
m_registeredCallbacks.Count: 16

Here is my code for setting up the EncryptedAppTicket CallResult, which I can confirm works on the 14.0.0 build:

public CallResult<EncryptedAppTicketResponse_t> m_EncryptedAppTicketResponse;

public void InitialiseSteam()
{
    steamManager = new SteamManager(this);

    if (steamManager.Initialized)
    {
        var name = SteamFriends.GetPersonaName();
        Console.Writeline($"Received persona name: {name}");

        m_EncryptedAppTicketResponse = CallResult<EncryptedAppTicketResponse_t>.Create(OnEncryptedAppTicketResponse);

        var data = Encoding.UTF8.GetBytes(name);
        var hAPICall = SteamUser.RequestEncryptedAppTicket(data, data.Length);

        m_EncryptedAppTicketResponse.Set(hAPICall);
    }
}

public void OnEncryptedAppTicketResponse(EncryptedAppTicketResponse_t pCallback, bool failure)
{
    ClientLog.Log($"OnEncryptedAppTicketResponse called successfully");
    SteamUser.GetEncryptedAppTicket(EAC.authBytesEncrypted, 1024, out uint pcbTicket);
    // Do stuff with pcbTicket here...
}

I don’t believe this is caused by a DLL mismatch as the Steamworks.NET.dll and steam_api64.dll files I ship with the game are always copied straight from the Windows-x64 folder in the Steamworks.NET standalone folder.

Any help with this would be greatly appreciated.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
xibzcommented, Sep 8, 2021

This is affecting us too. Has there been any movement on this? If not, I may downgrade to 14

0reactions
RajOOIcommented, Jan 6, 2022

Hello, I’m unable to run my game at all having just tried upgrading the Steam SDK to 152 (also tried 153a) and installing Steamworks.Net 20.0.0 via package, I have downloaded the full code but I also see the same code. Problem stems from CallbackDispatcher.Initialise(); call from SteamAPI.Init().

SteamManager.Instance is called which creates the gameobject and component, but during Awake on line 134 it calls SteamAPI.Init(). It bombs out with error EntryPointNotFound on line 59 of CallbackDispatcher.cs on this call: NativeMethods.SteamAPI_ManualDispatch_Init();

Our game is live and I actually need to upgrade the SDK to 153a in order to use the FloatingKeyboard for new Steam Deck functionality, and those functions are new, I see that they are exposed in Steamworks 20.0.0 and even updated it says to works with 153a.

Unsure how anybody else is able to run thier games when it’s bombing out with error at such an early stage as creating SteamManager.cs

I see this issue seem to be open and says to use 14.0.0, but that does not work for me as I need to get hold of the new functions. I have also tried grabbing from master instead of the package. I replaced the steam_api.dlls with the ones from Plugins along with all the Steamworks code, as suggested here: https://github.com/Facepunch/Facepunch.Steamworks/issues/382 but get the same error

Any help appreciated, if I have a dodgy set up in some way, that would be great, but I’ve simply replaced the actual steam sdk, deleted the old SteamWorks code and used the package manager

Here is my Callstack: EntryPointNotFoundException: SteamAPI_ManualDispatch_Init Steamworks.CallbackDispatcher.Initialize () (at Assets/Plugins/Steamworks.NET/CallbackDispatcher.cs:59) Steamworks.SteamAPI.Init () (at Assets/Plugins/Steamworks.NET/Steam.cs:42) SteamManager.Awake () (at Assets/1_WinterAssets/3_Scripts/Features/Steam/SteamManager.cs:134) UnityEngine.GameObject:AddComponent() SteamManager:get_Instance() (at Assets/1_WinterAssets/3_Scripts/Features/Steam/SteamManager.cs:35) SteamManager:get_Initialized() (at Assets/1_WinterAssets/3_Scripts/Features/Steam/SteamManager.cs:49))

Cheers

Read more comments on GitHub >

github_iconTop Results From Across the Web

CallResult not Called on Steam API 15.0.0 and Higher
I tried upgrading my game from Steam API 14.0.0 to 15.0.0 today and noticed that any CallResults I set are not called back....
Read more >
Steamworks.NET
I tried upgrading my game from Steam API 14.0.0 to 15.0.0 today and noticed that any CallResults I set are not called back....
Read more >
Steamworks API Overview
The Steamworks API will not initialize if it does not know the App ID of your ... You can identify a function that...
Read more >
Cannot make calls to steam api site from my own ...
No, that is the reason for the proxy, your page can't make requests to api.steampowered.com because it was loaded via www.example.com or ...
Read more >
ISteamUtils Interface
The Steam API Call handle to check the failure for. Used to get the failure reason of a call result. The primary usage...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found