Repository navigation
62dc381
Pre-releasefix(pixelflux): Give no extra frames to a source that outpaces the cadence
The windowed pacer sends a change landing in a window a frame already
took as an extra frame, from a reserve refilled at EXTRA_REFILL a period.
A source drawing faster than the cadence spends every extra the reserve
earns on its own frames, so a 60 Hz source over a 57 fps lock sent
58.80 fps, frames a display at the source's rate mostly cannot paint
(#579). Keystrokes beside a source at the cadence need those extras
(#585), and both fill every window, so the source's own spacing tells
them apart.
Each window a damage frame takes moves a count toward OUTPACED_MAX
where it came sooner than 1 - EXTRA_REFILL of a period after the damage
frame that took the window before, and toward zero otherwise; the screen
outpaces the cadence while the count stands above half. A keystroke now
and then shortens one spacing and lengthens the next, so it moves the
count nowhere, and a source at the cadence with a millisecond of jitter
either side, or one a hair faster, keeps its extras. With the screen
outpaced no extra is open (pull_at, merge_until and the spend in
window_tick agree through extra_open), and a source frame landing in a
taken window is held for the source's next frame (merge_until), whose
deadline is then at least a period after the hold starts: the held
change is the source's own frame, and a hold ending sooner sent it into
the next window ahead of the source's next frame, which then waited in
its turn. Damage frames are the X11 captures' and a Wayland client's
commits. Host capture is left as it was: its frames are not
held, as holding them, live with the encoder saturated (labwc at 55 Hz
under a 50 fps lock), sent 45.7 fps where main sent 47.3; and without
the hold a host frame that takes the next window leaves the windows a
period apart, which the count could not tell from a source at the
cadence, so host capture keeps the extras.
In the virtual-time harness (pace_report: three phases, 60 s each),
main against this change:
- 60 Hz over a 57 fps lock: 58.80 -> 57.01 fps, peak 5 s 59.00 ->
57.20; source wait p50/p90 0.03/0.10 -> 0.03/0.07 ms. - The same with 1 ms of jitter either side: 58.80 -> 57.03 fps.
- With a keystroke about every 0.7 s over the 57 fps lock: 58.80 ->
57.01 fps, keystroke wait p50/p90 0.70/13.68 -> 0.70/14.65 ms, as the
keystrokes now wait for the source's next frame. - A 60 Hz animation at 60 fps with a keystroke every 0.7 s or 0.15 s,
at a fixed phase or any, 60.06 Hz drift, a 60.06 Hz source with 1 ms
of jitter and keystrokes (every phase against the windows), and
keystrokes on a still screen: unchanged.
The harness's display, which shows the last frame before each vblank,
paints 57.01 fps over the lock against 58.62 on main; #579 measured
Chrome painting 55 of 58.8 received, and headless Chromium presents
every frame it receives, so what a browser paints on a 60 Hz display is
still to be measured with a headed one.
Live in an X11 slot (Xvfb's shared framebuffer, x264) over WebRTC to
headless Chromium, a scene drawing at 60 Hz, three rounds interleaved:
60 Hz over a 57 fps lock received 58.75 -> 57.02 fps and painted 58.73
-> 57.00, its frames as old when shown (p50 6.56 -> 6.61 ms), server
CPU 43.2 -> 42.4 %. A 60 Hz animation at 60 fps with typing, keystrokes
typed over the faster source, and a still screen with typing are
unchanged within their run-to-run spread. A trace of the count over
seven such runs at the cadence, under added CPU load too, never had it
above 3 of 16.
A source at least twice the cadence takes each window a period after
the last and is not seen to outpace it; its rate stays within the
refill, as before (60 Hz over 30 fps: 30.97).