Drain texture cache while capture is stopped (#26) - #27
Open
aldoborrero wants to merge 1 commit into
Open
Conversation
The calloop render tick early-outs while `!is_capturing` without finishing a Frame, so Smithay never drains its deferred texture-destruction queue. Buffers imported from nested clients that keep rendering (protocol-driven, via DmabufHandler::dmabuf_imported) accumulate and are only released on the next start_capture(). On an integrated GPU these are system RAM, so an idle session grows RSS until OOM. Call Renderer::cleanup_texture_cache() in the idle early-out so the deferred queue is drained every tick while capture is stopped. Fixes linuxserver#26.
Member
|
thanks for this PR, just so you are aware the next release of pixelflux will be here https://github.com/selkies-project/pixelflux. This transition is expected to occur in the next couple weeks and upstream selkies will be taking over all aspects of the project. Until then stuff on this side is kind of frozen in time. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
While capture is stopped, GPU memory imported from nested clients grows without bound and is only released on the next
start_capture(). This fixes it by draining Smithay's deferred texture-destruction queue on each idle render tick.Fixes #26.
Root cause
As diagnosed by @lonk42 in #26:
src/lib.rswhile!state.is_capturing && state.pending_screenshot.is_none(), so noFrameis ever finished.DmabufHandler::dmabuf_importedkeeps importing client buffers while stopped — it is protocol-driven, not tick-driven.glDeleteTextures/eglDestroyImageKHRfromGlesRenderer::cleanup(), whose callers are finishing aFrameandRenderer::cleanup_texture_cache(). The latter was never called while capture was stopped, so the deferred-destruction queue was never drained.The result: for as long as nested clients keep creating/destroying buffers with capture stopped, imported GPU memory accumulates. On NVIDIA it shows up as
type Gdevice memory (the reporter's climb: 167 → 5747 MiB); on an integrated GPU the buffers are system RAM, so it surfaces as RSS growth and eventual OOM.Fix
Call
Renderer::cleanup_texture_cache()on the renderer inside the idle early-out, so the deferred queue is drained every tick (~16 ms) while capture is stopped:This matches the behaviour the reporter observed with the
screenshotaction, which forces a single render tick and drops memory back to baseline —cleanup_texture_cache()is that same drain, run unconditionally while idle. TheRenderertrait is added to the existingsmithay::backend::rendererimport to bring the method into scope.Validation
Built from source against the pinned
smithayrev (ca932e04…) — compiles clean — and packaged/deployed in a selkies-based Wayland capture setup on an AMD 780M iGPU (h264_vaapi,PIXELFLUX_WAYLAND=true), where the pre-built wheel had been growing RSS until OOM. Capture start/stop is driven by browser clients connecting/disconnecting, exactly as in #26.Disclosure: this patch was prepared with AI assistance. The diagnosis, reproduction, and the pointer to
cleanup_texture_cache()are @lonk42's from #26.