Fix client hang after hibernate: D3D9 device recovery and lost device timeout#779
Draft
Fix client hang after hibernate: D3D9 device recovery and lost device timeout#779
Conversation
… device timeout When the D3D device is already lost, skip rendering operations (endScene, Present) and directly check TestCooperativeLevel() for recovery. This follows the standard D3D9 device recovery pattern. Also add a 30-second timeout in the main loop: if the device stays lost without recovery, force disconnect to prevent indefinite hang. Co-authored-by: kaetemi <1581053+kaetemi@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix client hangs after hibernate on Windows 10
Fix client hang after hibernate: D3D9 device recovery and lost device timeout
Feb 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
After Windows hibernate/sleep, the client spins indefinitely in the main loop logging "lost device" and never recovers or disconnects. The D3D9 device stays in
D3DERR_DEVICELOSTstate permanently.D3D driver: proper lost device recovery (
driver_direct3d.cpp)swapBuffers()was callingPresent()on an already-lost device each frame, which cannot properly detect the transition toD3DERR_DEVICENOTRESET. Now when_Lostis true, we skip rendering and directly pollTestCooperativeLevel():This is the standard D3D9 device recovery pattern — avoid all rendering calls on a lost device and wait for the reset-ready state.
Main loop: 30s timeout for unrecoverable device loss (
main_loop.cpp)NetMngr.disconnect()and exits the main loop after 30 secondsOriginal prompt
This section details on the original issue you should resolve
<issue_title>Client hangs after hibernate on Windows 10</issue_title>
<issue_description>```
2020/11/01 15:03:03 DBG 5078 ryzom_client_dev_r.exe network_connection.cpp 2512 CNetworkConnection::decodeHeader : CNET[00007FF7C5631EB0] lost messages server->client [50836; 50836]
2020/11/01 15:03:04 DBG 5078 ryzom_client_dev_r.exe main_loop.cpp 2309 mainLoop : lost device
2020/11/01 15:03:04 DBG 5078 ryzom_client_dev_r.exe main_loop.cpp 2309 mainLoop : lost device
2020/11/01 15:03:04 DBG 5078 ryzom_client_dev_r.exe main_loop.cpp 2309 mainLoop : lost device
2020/11/01 15:03:04 DBG 5078 ryzom_client_dev_r.exe main_loop.cpp 2309 mainLoop : lost device
2020/11/01 15:03:04 DBG 5078 ryzom_client_dev_r.exe main_loop.cpp 2309 mainLoop : lost device
2020/11/01 15:03:04 DBG 5078 ryzom_client_dev_r.exe main_loop.cpp 2309 mainLoop : lost device
2020/11/01 15:03:04 DBG 5078 ryzom_client_dev_r.exe main_loop.cpp 2309 mainLoop : lost device
2020/11/01 15:03:04 DBG 5078 ryzom_client_dev_r.exe main_loop.cpp 2309 mainLoop : lost device
2020/11/01 15:03:04 DBG 5078 ryzom_client_dev_r.exe main_loop.cpp 2309 mainLoop : lost device
2020/11/01 15:03:04 DBG 5078 ryzom_client_dev_r.exe main_loop.cpp 2309 mainLoop : lost device
2020/11/01 15:03:05 DBG 5078 ryzom_client_dev_r.exe main_loop.cpp 2309 mainLoop : lost device
2020/11/01 15:03:05 DBG 5078 ryzom_client_dev_r.exe main_loop.cpp 2309 mainLoop : lost device
2020/11/01 15:03:05 DBG 5078 ryzom_client_dev_r.exe main_loop.cpp 2309 mainLoop : lost device
2020/11/01 15:03:05 DBG 5078 ryzom_client_dev_r.exe main_loop.cpp 2309 mainLoop : lost device
2020/11/01 15:03:05 DBG 5078 ryzom_client_dev_r.exe main_loop.cpp 2309 mainLoop : lost device
2020/11/01 15:03:05 DBG 5078 ryzom_client_dev_r.exe main_loop.cpp 2309 mainLoop : lost device
2020/11/01 15:03:05 DBG 5078 ryzom_client_dev_r.exe main_loop.cpp 2309 mainLoop : lost device
2020/11/01 15:03:05 DBG 5078 ryzom_client_dev_r.exe main_loop.cpp 2309 mainLoop : lost device
2020/11/01 15:03:05 DBG 5078 ryzom_client_dev_r.exe main_loop.cpp 2309 mainLoop : lost device
2020/11/01 15:03:05 DBG 5078 ryzom_client_dev_r.exe main_loop.cpp 2309 mainLoop : lost device
2020/11/01 15:03:05 DBG 5078 ryzom_client_dev_r.exe main_loop.cpp 2309 mainLoop : lost device
2020/11/01 15:03:05 DBG 5078 ryzom_client_dev_r.exe main_loop.cpp 2309 mainLoop : lost device
2020/11/01 15:03:05 DBG 5078 ryzom_client_dev_r.exe main_loop.cpp 2309 mainLoop : lost device
2020/11/01 15:03:05 DBG 5078 ryzom_client_dev_r.exe main_loop.cpp 2309 mainLoop : lost device
2020/11/01 15:03:05 DBG 5078 ryzom_client_dev_r.exe main_loop.cpp 2309 mainLoop : lost device
2020/11/01 15:03:05 DBG 5078 ryzom_client_dev_r.exe main_loop.cpp 2309 mainLoop : lost device
2020/11/01 15:03:05 DBG 5078 ryzom_client_dev_r.exe main_loop.cpp 2309 mainLoop : lost device
2020/11/01 15:03:06 DBG 5078 ryzom_client_dev_r.exe main_loop.cpp 2309 mainLoop : lost device
2020/11/01 15:03:06 DBG 5078 ryzom_client_dev_r.exe main_loop.cpp 2309 mainLoop : lost device
2020/11/01 15:03:06 DBG 5078 ryzom_client_dev_r.exe main_loop.cpp 2309 mainLoop : lost device
2020/11/01 15:03:06 DBG 5078 ryzom_client_dev_r.exe main_loop.cpp 2309 mainLoop : lost device
2020/11/01 15:03:06 DBG 5078 ryzom_client_dev_r.exe main_loop.cpp 2309 mainLoop : lost device
2020/11/01 15:03:06 DBG 5078 ryzom_client_dev_r.exe main_loop.cpp 2309 mainLoop : lost device
2020/11/01 15:03:06 DBG 5078 ryzom_client_dev_r.exe main_loop.cpp 2309 mainLoop : lost device
2020/11/01 15:03:06 DBG 5078 ryzom_client_dev_r.exe main_loop.cpp 2309 mainLoop : lost device
2020/11/01 15:03:06 DBG 5078 ryzom_client_dev_r.exe main_loop.cpp 2309 mainLoop : lost device
2020/11/01 15:03:06 DBG 5078 ryzom_client_dev_r.exe main_loop.cpp 2309 mainLoop : lost device
2020/11/01 15:03:06 DBG 5078 ryzom_client_dev_r.exe main_loop.cpp 2309 mainLoop : lost device
2020/11/01 15:03:06 DBG 5078 ryzom_client_dev_r.exe main_loop.cpp 2309 mainLoop : lost device
2020/11/01 15:03:06 DBG 5078 ryzom_client_dev_r.exe main_loop.cpp 2309 mainLoop : lost device
2020/11/01 15:03:06 DBG 5078 ryzom_client_dev_r.exe main_loop.cpp 2309 mainLoop : lost device
2020/11/01 15:03:06 DBG 5078 ryzom_client_dev_r.exe main_loop.cpp 2309 mainLoop : lost device
2020/11/01 15:03:06 DBG 5078 ryzom_client_dev_r.exe main_loop.cpp 2309 mainLoop : lost device
2020/11/01 15:03:06 DBG 5078 ryzom_client_dev_r.exe main_loop.cpp 2309 mainLoop : lost device
2020/11/01 15:03:06 DBG 5078 ryzom_client_dev_r.exe main_loop.cpp 2309 mainLoop : lost device
2020/11/01 15:03:07 DBG 5078 ryzom_client_dev_r.exe main_loop.cpp 2309 mainLoop : lost device
2020/11/01 15:03:07 DBG 5078 ryzom_client_dev_r.exe main_loop.cpp 2309 mainLoop : lost device
2020/11/01 15:03:07 DBG 5078 ryzom_client_dev_r.exe main_loop.cpp 2309 mainLoop : lost device
2020/11/01 15:03:07 DBG 5078 ryzom_client_dev_r.exe main_loop.cpp 2309 mainLoop : lost d...
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.