Skip to content

Commit

Permalink
Initialize client networking before graphics
Browse files Browse the repository at this point in the history
Avoid Vulkan crash if the backend is destroyed immediately after being created.

Slightly decreases time of initial black screen before loading menu is rendered.
  • Loading branch information
Robyt3 committed Sep 11, 2024
1 parent 9f27897 commit 128ffd2
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions src/engine/client/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2929,6 +2929,24 @@ void CClient::Run()
g_UuidManager.DebugDump();
}

#ifndef CONF_WEBASM
char aNetworkError[256];
if(!InitNetworkClient(aNetworkError, sizeof(aNetworkError)))
{
log_error("client", "%s", aNetworkError);
ShowMessageBox("Network Error", aNetworkError);
return;
}
#endif

if(!m_Http.Init(std::chrono::seconds{1}))
{
const char *pErrorMessage = "Failed to initialize the HTTP client.";
log_error("client", "%s", pErrorMessage);
ShowMessageBox("HTTP Error", pErrorMessage);
return;
}

// init graphics
m_pGraphics = CreateEngineGraphicsThreaded();
Kernel()->RegisterInterface(m_pGraphics); // IEngineGraphics
Expand All @@ -2952,24 +2970,6 @@ void CClient::Run()
CVideo::Init();
#endif

#ifndef CONF_WEBASM
char aNetworkError[256];
if(!InitNetworkClient(aNetworkError, sizeof(aNetworkError)))
{
log_error("client", "%s", aNetworkError);
ShowMessageBox("Network Error", aNetworkError);
return;
}
#endif

if(!m_Http.Init(std::chrono::seconds{1}))
{
const char *pErrorMessage = "Failed to initialize the HTTP client.";
log_error("client", "%s", pErrorMessage);
ShowMessageBox("HTTP Error", pErrorMessage);
return;
}

// init text render
m_pTextRender = Kernel()->RequestInterface<IEngineTextRender>();
m_pTextRender->Init();
Expand Down

0 comments on commit 128ffd2

Please sign in to comment.