Nemirtingas / ingame_overlay

GNU General Public License v3.0
17 stars 8 forks source link

[Windows] Race condition in ImGui event code #24

Closed Nemirtingas closed 3 weeks ago

Nemirtingas commented 5 months 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 5 months 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 5 months ago

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