Skip to content

Guard repeated WndProc setup and ImGui dispatch - #144

Open
kfhammond wants to merge 1 commit into
NVIDIAGameWorks:mainfrom
kfhammond:fix/wndproc-stability
Open

Guard repeated WndProc setup and ImGui dispatch#144
kfhammond wants to merge 1 commit into
NVIDIAGameWorks:mainfrom
kfhammond:fix/wndproc-stability

Conversation

@kfhammond

Copy link
Copy Markdown

Summary

Fix two WndProc stability paths around Remix window hooking and overlay ImGui message forwarding.

Motivation

The bridge window setup path can be called again for the same HWND while RemixWndProc is already installed. Before this PR, that same-window case fell through to the implicit unset() / rehook path, disturbing the active WndProc chain even though the hooked window had not changed.

The overlay window can also receive forwarded mouse or keyboard messages while the ImGui Win32 backend is not in a valid dispatch state, such as during overlay/menu focus handoff or shutdown. Those messages were forwarded directly to ImGui_ImplWin32_WndProcHandler, which assumes the ImGui context and backend platform data are live.

What Changed

Two changes:

  1. bridge/src/client/window.cpp

    If set(HWND) is called for the same window and RemixWndProc is already installed, treat the call as idempotent. The DirectInput forwarding target is refreshed, but the existing WndProc hook is left in place.

  2. src/dxvk/rtx_render/rtx_overlay_window.cpp

    Route all overlay ImGui Win32 dispatches through a small guard that requires both an active ImGui context and Win32 backend platform data before calling ImGui_ImplWin32_WndProcHandler.

This keeps normal input handling unchanged while the backend is live, but ignores stale forwarded messages when the backend is not ready to receive them.

Net diff:

  • bridge/src/client/window.cpp
  • src/dxvk/rtx_render/rtx_overlay_window.cpp
  • src/dxvk/imgui/dxvk_imgui_about.cpp

+37 / -10

Testing

  • git diff --check upstream/main..HEAD
  • Confirmed the branch compares as one commit ahead of current NVIDIAGameWorks/main.
  • Verified locally in a Robots RTX integration by repeatedly moving through game menu / overlay focus handoff paths and returning to gameplay, confirming input continued routing normally and no WndProc / ImGui backend lifetime crash occurred.

Build note: this change was previously built/tested locally before rebasing onto latest upstream main. After rebasing, an incremental _Comp64Release rebuild stops during Meson dependency regeneration because upstream now requires rtx-remix-ngx_sdk_dlfg version 4, which is not present in my local packman cache and requires NVM_GTLAPI_TOKEN to fetch. The rebuild does not reach C++ compilation.

Bridge window setup can be called again for the same HWND while RemixWndProc
is already installed. Treat that path as idempotent instead of unhooking and
rehooking the same window procedure, while still refreshing the DirectInput
forwarding target.

The overlay window can also receive forwarded mouse and keyboard messages
after the ImGui Win32 backend has been torn down or before it is fully
initialized. Guard all direct ImGui Win32 dispatches behind the active ImGui
context and backend platform data so stale window messages are ignored instead
of reaching backend state that is no longer valid.

This avoids WndProc instability during overlay/menu handoff and shutdown paths
without changing normal message handling when the backend is live.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant