Commit c9ff08a
committed
fix(win): pace the capture loop to a deadline instead of sleeping a full period
The video writer ended each iteration with `sleep_for(1/fps)`, after the
frame had already been captured, converted and submitted to the sink
writer. The real period was therefore `work + 1/fps`, never `1/fps`: at
1080p the work is ~11 ms, so a 30 fps recording ran at 22.
Keep a `nextFrameDue` deadline and `sleep_until` it. When a frame runs
long the deadline is resynced to now rather than carried forward, so a
stall costs the frames it costs instead of being repaid as a burst of
catch-up frames -- the same rule the webcam cadence a few lines above
already follows.
Measured on a Ryzen 5 7520U / Radeon iGPU, 15 s display capture at
1080p with 30 fps requested:
before 317 frames / 14.672 s = 21.6 fps
after 440 frames / 14.675 s = 30.0 fps
The frame count comes from the new `[pacing]` line on stderr because
the recording cannot answer this question: the sink writer re-times its
output to nominal CFR, so `nb_frames / duration` reads exactly 30.000
whatever the loop actually did -- it stayed at 30 even with a 300 ms
stall injected through OPENSCREEN_WGC_TEST_STALL_READBACK_MS. The line
sits next to the existing [stop-timing] instrumentation and is picked
up by the diagnostic tool's stderr capture.
macOS and Linux do not share the pattern: ScreenCaptureKit paces the
callbacks itself via `minimumFrameInterval`, and the pipewire helper
derives its output frame index from the wall clock.1 parent 09bc7d2 commit c9ff08a
1 file changed
Lines changed: 19 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
734 | 734 | | |
735 | 735 | | |
736 | 736 | | |
| 737 | + | |
737 | 738 | | |
738 | 739 | | |
739 | 740 | | |
| |||
890 | 891 | | |
891 | 892 | | |
892 | 893 | | |
893 | | - | |
| 894 | + | |
| 895 | + | |
| 896 | + | |
| 897 | + | |
| 898 | + | |
| 899 | + | |
| 900 | + | |
| 901 | + | |
| 902 | + | |
| 903 | + | |
| 904 | + | |
| 905 | + | |
| 906 | + | |
894 | 907 | | |
| 908 | + | |
| 909 | + | |
| 910 | + | |
| 911 | + | |
| 912 | + | |
895 | 913 | | |
896 | 914 | | |
897 | 915 | | |
| |||
0 commit comments