Gamescope: frame counter starts at the game's first frame, not the desktop's
Description
On the Gamescope display server the frame counter took every frame the display daemon reported, including the few frames of Wine's desktop published before the game draws. So session_length, total_frames and avg_fps started on the desktop instead of on the game, and a session where the game never drew still reported a handful of frames with an fps of 0. On X11 the counter starts at the first game window's content.
Changes:
- Frames reach the counter only once the session shows game content (the existing 60-frame signal). The unbroken run of frames that reached the signal is counted from its first frame, so no game frame is lost.
- New
display_framesproperty ongame_exitedfor Gamescope sessions: every frame the display server reported. A session where the game never drew reads asdisplay_frames> 0 withtotal_frames0. - All counted frames are attributed to the game's window entry, so
main_window_framesmatchestotal_frames.
Tested on an Odin 3 (Gamescope, 120 Hz panel):
| Run | session_length | total_frames | avg_fps | display_frames |
|---|---|---|---|---|
| Blazing Chrome, before (60 cap, then 30) | 329.9 | 7718 | 38.7 | - |
| Blazing Chrome, after (30 cap) | 167.0 | 2888 | 29.4 | 2891 |
| A game that stays on a black screen, after | 0 | 0 | 0 | 5 |
The HUD read 30.0 at the 30 cap and 60.0 at the 60 cap.
Recording
None: the change is in recorded session values, not in anything on screen.
Type of Change
- Bug fix
- Performance / stability improvement
- Compatibility improvements
- Other (requires prior approval)
Checklist
- If I have access to
#code-changes, I have discussed this change there and it has been green-lighted. If I do not have access, I have still provided clear context in this PR. If I skip both, I accept that this change may face delays in review, may not be reviewed at all, or may be closed. - This change aligns with the current project scope (core functionality, stability, or performance). If not, it has been explicitly approved beforehand.
- I have attached a recording of the change.
- I have read and agree to the contribution guidelines in
CONTRIBUTING.md.
Summary by cubic
Fixes the Gamescope frame counter so sessions start at the game's first frame instead of Wine's desktop, matching X11 behavior where counting starts at the first game window.
- Frames only reach the counter once the session shows game content (the existing 60-frame signal); the unbroken run that reached the signal is counted from its first frame, and a gap over 250 ms breaks the run so catch-up frames (e.g. after suspension) don't leak in.
game_exitednow reportsdisplay_frameson Gamescope: every frame the display server showed, so a session where the game never drew reads asdisplay_frames> 0 withtotal_frames0.- All counted frames are attributed to the game's window entry, so
main_window_framesmatchestotal_frames, and the content signal handler no longer reads the rating itself.
Summary by CodeRabbit
- New Features
- Game sessions now track the number of frames displayed, making frame totals available when tracking is active.
- Session reports now include the display-frame total when available.
- Improvements
- Frame tracking is more resilient to pauses between frames, helping maintain accurate counts during gameplay.