Skip to content

Resolve 60 fps lock issue for WGC capture by setting the MinUpdateInterval property of the WGC capture session.#785

Merged
ClassicOldSong merged 2 commits intoClassicOldSong:masterfrom
danielmartina:wgc-framerate-fix
Jun 7, 2025
Merged

Resolve 60 fps lock issue for WGC capture by setting the MinUpdateInterval property of the WGC capture session.#785
ClassicOldSong merged 2 commits intoClassicOldSong:masterfrom
danielmartina:wgc-framerate-fix

Conversation

@danielmartina
Copy link
Copy Markdown
Contributor

@danielmartina danielmartina commented May 30, 2025

Resolve 60 fps lock issue for WGC capture by setting the MinUpdateInterval property of the WGC capture session.

Fixes: #676 and partially #620

Resolves 60 fps lock issue for WGC capture
@ClassicOldSong
Copy link
Copy Markdown
Owner

Thanks for the patch!

One question, does this min interval needs to be synced to the requested framerate or setting to 10000 won't result in unnecessary captures?

@danielmartina
Copy link
Copy Markdown
Contributor Author

For me it did not make any noticable difference, but it would make sense to verify this.

@danielmartina
Copy link
Copy Markdown
Contributor Author

danielmartina commented May 30, 2025

You are right, it seems that it can cause unnecessary captures, and although I dont see any performance degradation, it makes sense to limit, so I will update the branch.

@danielmartina
Copy link
Copy Markdown
Contributor Author

danielmartina commented May 30, 2025

I have tested with the MinUpdateInterval set to the frametimes corresponding to 30, 60, 75, 100 and 120 Hz.

With this calculation:
int64_t interval_100ns = 10000000LL / config.framerate;
capture_session.MinUpdateInterval(winrt::TimeSpan{ interval_100ns });

And strangely it works for 120, 75, 60 and 30, but for 100Hz it records only 50 pfs and for 90 it records only around 80.

This is a really strange behavior that I cannot explain.

The documentation from Microsoft is also isn't exactly helpful: https://learn.microsoft.com/en-us/uwp/api/windows.graphics.capture.graphicscapturesession.minupdateinterval?view=winrt-26100

@ClassicOldSong
Copy link
Copy Markdown
Owner

microsoft/cppwinrt#140

According to this issue it seems your implementation is correct, but it's really weird.

How much wasted frames are there when just set it to 10000? Is there frame pacing issues?

@danielmartina
Copy link
Copy Markdown
Contributor Author

I do not see any frame pacing issues when looking at TestUfo for example. On the topic of wasted frames, it is hard to say as I do not see into the inner workings of the WGC API.

10000 corresponds to a framerate of 1000 Hz, which is a lot.

@ClassicOldSong
Copy link
Copy Markdown
Owner

auto frame_timestamp = std::chrono::steady_clock::now() - qpc_time_difference(qpc_counter(), frame_qpc);

Can you check the time difference? A rough implemtation is enough, set a static variable here and diff it each time when snapshot is called

@ClassicOldSong
Copy link
Copy Markdown
Owner

Tried on my computer, but with or without this patch WGC never goes over 24fps and IDK why...

@ClassicOldSong
Copy link
Copy Markdown
Owner

It's AppleMusic... Something strange happens if I have AppleMusic running and then connect the virtual display, it stutters like hell.

Close it and then open it within the virtual display, it's normal again. But then I disconnects the virtual display, AppleMusic stutters on the physical monitor......

How weird it is.

@ClassicOldSong
Copy link
Copy Markdown
Owner

Tested working fine on my machine, even with the weird refresh rates.

Thanks for the contribution!

@ClassicOldSong ClassicOldSong merged commit a09c18c into ClassicOldSong:master Jun 7, 2025
Skajdrowski added a commit to Skajdrowski/obs-studio that referenced this pull request Oct 7, 2025
Skajdrowski added a commit to Skajdrowski/obs-studio that referenced this pull request Oct 7, 2025
Skajdrowski added a commit to Skajdrowski/obs-studio that referenced this pull request Oct 24, 2025
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.

Windows graphics capture 60 fps limit?

2 participants