Closed kisunji closed 1 year ago
This has been reported issue before and also specifically for Valorant, but are you able to confirm whether or not this occurs for other games?
Please feel free to upload the logs here as they may assist in debugging this issue. You can retrieve the logs from Settings > Help.
I've pushed some potential fixes towards this issue, but I am unsure if it will actually solve this particular situation. This issue has been troublesome lately because I have been unable to replicate this and other issues related to recording stopping early #122 (the dreaded, "but it works on my machine!...").
Please continue to attach the logs if the issues are still not resolved so that I can better debug the issue.
Here are some logs from me testing v1.2.23 with Path of Exile (keeps recording when I alt-tab) then Valorant (stops recording when I alt-tab) with the following steps
Here's v1.2.1 logs for Valorant:
At a glance in v1.2.23 it looks like the hwnd
for WindowCreation and WindowDeletion events are different:
[6/24/2023 9:34:49 AM][DetectionService.cs(81)]: WindowCreation: [28896][1343951184][C:\Riot Games\VALORANT\live\ShooterGame\Binaries\Win64\VALORANT-Win64-Shipping.exe]
[6/24/2023 9:35:07 AM][DetectionService.cs(91)]: WindowDeletion: [28896][58135038][C:\Riot Games\VALORANT\live\ShooterGame\Binaries\Win64\VALORANT-Win64-Shipping.exe]
I think the fact that you match on PID OR HWND here might cause the premature stops: https://github.com/lulzsun/RePlays/blob/21357eae94a9e1722b4c8a94db588bac329d9d1c/Classes/Services/DetectionService.cs#L90
Maybe the check should match both? I'd imagine most games would have a 1:1 relationship.
My hypothesis is that Valorant does some weird stuff with windows when players switch windows. I've noticed that video captures of the game are replaced with a black screen when streamers alt-tab so maybe the game process spawns multiple window handles that come and go?
On another note, I think your latest commit causes Replays to not stop recording Valorant when I exit the game (I tested with Path of Exile as well and Replays stops recording correctly on exit).
Maybe the check should match both? I'd imagine most games would have a 1:1 relationship.
... so maybe the game process spawns multiple window handles that come and go?
The reason why we aren't checking both is because some game processes recreate the window and therefore create a new window handle id that no longer matches the currentSession.
With the latest commits, I am checking to see if the process has exited or no longer exists upon a window deletion event. However it seems like it is unreliable when it comes to Valorant?
In stable release 1.2.1, I used WMI to log all processes open/close events instead of relying on window event triggers. I think I will be reverting back to using that method as it seems more reliable than what we have right now...
The reason why we aren't checking both is because some game processes recreate the window and therefore create a new window handle id that no longer matches the currentSession.
In the case of Valorant there is the "first" game window which when closed you can confirm the game has terminated. So the window handle pseudo-tracks the lifetime of the game process (process can outlive the window, but for recording purposes you can stop when the window is killed).
Are there games where the "first" window is outlived by a new window?
Wouldn't an event be emitted when the first window is destroyed? That would stop the recording prematurely regardless of matching just PID or both PID and HWND.
Correct me if I'm misunderstanding anything; I'm not a Windows developer 😅
I guess to put it more clearly:
If we check both PID and HWND before stopping recording, we would record for as long as currentSession.WindowHandle
is alive.
If process is killed, I assume there we would see an event for destroying currentSession.WindowHandle
and we would stop recording.
If process creates more window handles, we don't care as long as currentSession.WindowHandle
is alive.
If currentSession.WindowHandle
is outlived by a new "main game window", we would see an event for destroying currentSession.WindowHandle
and stop recording regardless of || or && (so it would be a bug with existing code)
In stable release 1.2.1, I used WMI to log all processes open/close events instead of relying on window event triggers. I think I will be reverting back to using that method as it seems more reliable than what we have right now...
Totally up to you! I appreciate all the work you put in. Hope to contribute more directly to the project in the future (when I get more familiar with dotnet and win32)
Forgot to reference this issue in commit message, but https://github.com/lulzsun/RePlays/commit/0d8eddf1f2957705a889031f7ecc7b753b6f50db has re-implemented the previous process close eventlistener (WMI event query). Hopefully that should make it more reliable in stopping recordings where the process no longer exists.
I initially switched away from using WMI as I figured it would be more taxing than just capturing window events. Maybe it doesn't matter that much and I was just preemptively doing performance improvements for no good reason.
It does not seem reliable to only capture window events as it appears that sometimes
Will be researching more reliable solutions in tracking lifetimes of window handles and processes in the future.
Awesome, thanks for the context.
I had
Use Display Capture As Backup
turned off but tested that it occurs with it on as well. I did not have such issues in v1.2.1 stable so this might be a regression. Otherwise all settings are default values.I am trying to record exclusive fullscreen Valorant. On startup I hear the recording sound effect, but I noticed that when I alt-tab out the recording immediately stops. A session clip is created.
Alt-tabbing back to Valorant does not restart the recording.