From e7790ab52c41afb5c0b7d52a4971d20866811daa Mon Sep 17 00:00:00 2001 From: jp9000 Date: Mon, 5 Jan 2015 01:10:19 -0800 Subject: [PATCH] win-capture: Wait before auto-fullscreen hooking If using the auto-fullscreen feature to hook in to a fullscreen, I found that if you don't wait a few seconds before initializing the hook that you can catch the process when it's just starting up and loading important libraries (especially things such as steam/uplay/etc), which can cause a little bit of interference with the process and on rare occasions cause it to crash. To help prevent the likelihood of that happening, this just makes it so that the hook waits at least 3 seconds before even attempting to inject the hook when using auto-fullscreen mode. After some extensive testing I haven't had any issues since. --- plugins/win-capture/game-capture.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/plugins/win-capture/game-capture.c b/plugins/win-capture/game-capture.c index fb6f4d7ff..81dbbd308 100644 --- a/plugins/win-capture/game-capture.c +++ b/plugins/win-capture/game-capture.c @@ -78,6 +78,7 @@ struct game_capture { float retry_time; float fps_reset_time; float retry_interval; + bool wait_for_target_startup : 1; bool active : 1; bool capturing : 1; bool activate_hook : 1; @@ -196,6 +197,7 @@ static void stop_capture(struct game_capture *gc) } gc->copy_texture = NULL; + gc->wait_for_target_startup = false; gc->active = false; gc->capturing = false; } @@ -691,7 +693,20 @@ static void get_fullscreen_window(struct game_capture *gc) rect.right == mi.rcMonitor.right && rect.bottom == mi.rcMonitor.bottom && rect.top == mi.rcMonitor.top) { - gc->next_window = window; + + /* always wait a bit for the target process to start up before + * starting the hook process; sometimes they have important + * modules to load first or other hooks (such as steam) need a + * little bit of time to load. ultimately this helps prevent + * crashes */ + if (gc->wait_for_target_startup) { + gc->retry_interval = 3.0f; + gc->wait_for_target_startup = false; + } else { + gc->next_window = window; + } + } else { + gc->wait_for_target_startup = true; } }