Skip to content

Commit

Permalink
fix(game/five): updateBusySpinner thread constraint check
Browse files Browse the repository at this point in the history
This should work as a temporary fix to prevent crashes when for unknown reasons 'updateBusySpinner' gets called from the Render thread instead of the Main thread, which causes an inner function call to return a nullptr. due to failing thread constraint checks.
  • Loading branch information
tens0rfl0w committed Nov 20, 2024
1 parent 8a6a363 commit 73812bd
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,12 @@ static InitFunction initFunction([] ()
{
if (*g_scaleformMgr)
{
if (GetCurrentThreadId() != g_mainThreadId)
{
trace("Error: BusySpinner update called from non-main thread!\n");
return;
}

setupBusySpinner(1);
*spinnerDep = true;
updateBusySpinner();
Expand Down
2 changes: 0 additions & 2 deletions code/components/rage-input-five/src/InputHook.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -411,8 +411,6 @@ static hook::cdecl_stub<bool(wchar_t, int)> ProcessWMChar([]()
static ReverseGameInputState lastInput;
static ReverseGameInputState curInput;

static bool g_mainThreadId;

#include <queue>

extern void DoPatchMouseScrollDelta();
Expand Down
2 changes: 2 additions & 0 deletions code/components/rage-nutsnbolts-five/include/nutsnbolts.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

#define HAS_EARLY_GAME_FRAME

extern NUTSNBOLTS_EXPORT DWORD g_mainThreadId;

extern NUTSNBOLTS_EXPORT fwEvent<> OnLookAliveFrame;
extern NUTSNBOLTS_EXPORT fwEvent<> OnGameFrame;
extern NUTSNBOLTS_EXPORT fwEvent<> OnEarlyGameFrame;
Expand Down
3 changes: 2 additions & 1 deletion code/components/rage-nutsnbolts-five/src/FrameHook.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
#include <ICoreGameInit.h>
#include <CrossBuildRuntime.h>

DWORD g_mainThreadId;

fwEvent<> OnLookAliveFrame;
fwEvent<> OnEarlyGameFrame;
fwEvent<> OnGameFrame;
Expand Down Expand Up @@ -64,7 +66,6 @@ static uint32_t g_lastCriticalFrame;
static std::mutex g_gameFrameMutex;
static std::mutex g_earlyGameFrameMutex;
static std::mutex g_criticalFrameMutex;
static DWORD g_mainThreadId;
static bool g_executedOnMainThread;

// NOTE: depends indirectly on GameProfiling.cpp in gta:core!
Expand Down

0 comments on commit 73812bd

Please sign in to comment.