Skip to content

Fix: Video players are never disposed after a transition out - #151

Merged
rubenberttpingol merged 1 commit into
developfrom
fix/transition_animations_memory_leak
Nov 11, 2026
Merged

rubenberttpingol merged 1 commit into
developfrom
fix/transition_animations_memory_leak

Conversation

@rubenberttpingol

Copy link
Copy Markdown
Contributor

Renderer memory grows while a layout with transitions on its video widgets loops, and stays flat without them. Every playlist cycle leaves its video.js players behind.

Cause

When a video widget has an out transition, VideoMedia.stop() holds the player and leaves disposing it to Region.removeOldMedia() once the transition has finished (#142). removeOldMedia() finds the old media by its class, and only disposes the player when that element's parent is the video-js wrapper. But video.js moves the media's class onto the wrapper itself, so the element found is the wrapper, its parent is the region, and stop(true) never runs. Each player stays in videojs.players, with its tech, <video> element and source.

A heap snapshot on develop showed the retainer path window → Player.players → Player → tech_ → Html5.el_ → <video>. That's 3 players per cycle for a 3-video playlist. Without transitions, stop() disposes the player straight away, which is why the reporter saw flat memory.

Change

removeOldMedia() now treats the element it found as the wrapper when it has the video-js class, and keeps the parent check as a fallback. The held player is then disposed after the out transition, as #142 intended.

Testing

Electron player (4.0.13, develop, Windows) against develop.xibo.co.uk, looping one full-screen layout of 3 muted videos with 1 s fade in/out. The player was restarted before each run, then sampled every 30 s for 14 min, with growth measured after the first 2 min:

per minute develop this PR
all player processes, resident +4.2 MB −0.4 MB (flat)
renderer, resident +2.1 MB +0.2 MB
DOM nodes +952 flat (2,223 at start and end)
event listeners +649 flat
detached <video> elements after the run 21, rising 3 (the cycle just ended)

Videos still play in turn with their fades, and no new errors appear in the log.

On Windows the leaked players cost a few MB a minute. The report (Linux, software video decoding) measured +38 MB/min, because each leaked player there holds much larger decode buffers. The leaked players, which are the cause, are gone either way. Not yet measured on Linux.

relates to xibosignage/electron-player#265

When a video widget has an out transition, VideoMedia holds its player and
leaves disposing it to the region once the transition has finished. The
region looked for the video.js wrapper as the parent of the element it
finds by the media's class, but video.js moves that class onto the wrapper
itself, so the player was never disposed. Each playlist cycle left its
players registered in video.js, with their video elements and sources,
and renderer memory grew for as long as the layout looped.

Treat the element found as the wrapper when it is one, so the held player
is disposed after the transition.

Relates to xibosignage/electron-player#265
@rubenberttpingol
rubenberttpingol merged commit f6e3949 into develop Nov 11, 2026
1 check passed
@rubenberttpingol
rubenberttpingol deleted the fix/transition_animations_memory_leak branch November 11, 2026 10:45
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 11, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants