Nemirtingas / ingame_overlay

GNU General Public License v3.0
14 stars 4 forks source link

[Windows] Race condition in ImGui event code #24

Open Nemirtingas opened 1 month ago

Nemirtingas commented 1 month ago

When a game uses multiple threads for rendering and event, a race condition will occur in ImGui between: static ImGuiInputEvent* FindLatestInputEvent(ImGuiContext* ctx, ImGuiInputEventType type, int arg = -1) and void ImGui::UpdateInputEvents(bool trickle_fast_inputs)

g.InputEventsQueue is updated in both functions.

Nemirtingas commented 1 month ago

A fix could be to store ImGui events in the WindowsHook (and eventually X11Hook and NSViewHook) and send the events to ImGui before the call to ImGui_ImplWin32_NewFrame.

Nemirtingas commented 1 month ago

https://github.com/Nemirtingas/ingame_overlay/tree/feature/store-window-events