Skip to content

osc.lua: don’t re-render for time and cache updates while hidden - #18914

Open
paulmenzel wants to merge 1 commit into
mpv-player:masterfrom
paulmenzel:osc-skip-hidden-ticks
Open

paulmenzel wants to merge 1 commit into
mpv-player:masterfrom
paulmenzel:osc-skip-hidden-ticks

Conversation

@paulmenzel

Copy link
Copy Markdown

While hidden, the OSC still re-rendered about 30 times per second, because playback-time and demuxer-cache-state requested a tick on every change. Now these two request a tick only while the OSC or the window controls are visible or animating. Showing the OSC requests a tick itself, so the shown values are current.

Tested with the patched osc.lua loaded via --script into mpv 0.42.0 (Debian sid, GNOME Wayland): render calls while hidden drop from 31/s to 2.5/s and are unchanged while visible; mpv’s own cycles drop 3.5 % with --hwdec=auto-safe. luacheck is clean.

playback-time changes on every video frame and demuxer-cache-state on
nearly every packet. Both requested a tick, so the OSC ran render()
about 30 times per second (rate-limited by tick_delay) even when none of
it was on screen: it fetched the mouse position, reset the mouse areas
and built an empty ASS string.

Now these two properties only request a tick while the OSC or the window
controls are visible or animating. Showing the OSC requests a tick on
its own, and render_elements() reads the current values then. The other
observed properties still request ticks unconditionally.

render() calls (msg.trace "rendering"), Big Buck Bunny 1080p30 H.264,
fullscreen, osc-visibility switched over IPC:

                        before   after
    hidden (auto)       31.0/s    2.5/s
    visible (always)    33.9/s   33.7/s

Cycles over 40 s of playback, mean of 3 interleaved runs, Dell XPS 13
9310 (i7-1165G7), Debian sid, GNOME Wayland, mpv 0.42.0, FFmpeg 9.0.2,
libplacebo 7.387, --hwdec=auto-safe, both variants loaded with
--no-osc --script=osc.lua:

                        before    after
    mpv process         5.39 G    5.20 G   (-3.5 %)
@paulmenzel

Copy link
Copy Markdown
Author

Assisted-by: claude-opus-5.5

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.

1 participant