GameNetworkingSockets icon indicating copy to clipboard operation
GameNetworkingSockets copied to clipboard

ISteamNetworkingMessages.ReceiveMessagesOnChannel blocks forever sometimes

Open winterSteve25 opened this issue 1 year ago • 2 comments

Hey, I am working on a little cpp project using steam networking and ISteamNetworkingMessages.ReceiveMessagesOnChannel call sometimes blocks forever.

I have class NetworkManager and in the constructor uses malloc to allocate a buffer for message pointers, and every update frame I am calling ReceiveMessagesOnChannel and sometimes this call blocks forever causing the application to freeze up, I was wondering if there is something I am doing wrong or missing

This is on windows x64

Thank you very much for your time!

winterSteve25 avatar Aug 06 '24 19:08 winterSteve25

Is this using the steamworks code or the opensource code here? Can you give me a call stack, or capture a minidump, of this happening?

zpostfacto avatar Aug 31 '24 01:08 zpostfacto

I'm using the steamworks sdk with their headers and precompiled dll, this is the callstack when the call to ISteamNetworkingMessages.ReceiveMessagesOnChannel occurs.

image

This is the function:

void NetworkManager::HandleMessages()
{
    int msgCount = SteamNetworkingMessages()->ReceiveMessagesOnChannel(0, m_messageBuffer, message_buffer_size);
    if (msgCount <= 0) return;

    for (int i = 0; i < msgCount; i++)
    {
        SteamNetworkingMessage_t* msg = m_messageBuffer[i];
        HandleMessage(msg);
        msg->Release();
    }
}

m_messageBuffer is type of SteamNetworkingMessage_t** initialized like so in the constructor static_cast<SteamNetworkingMessage_t**>(malloc(message_buffer_size * sizeof(SteamNetworkingMessage_t*)))

and message_buffer_size is a constexpr of 64

winterSteve25 avatar Sep 01 '24 17:09 winterSteve25