waylandsink / gtkwaylandsink: do not use drm dumb pool when importing DMAbuf buffers
Describe your issue
After about a minute, preview or video playback exit itself silently.
After investigations, DMAbuf memory leakage is observed: identfied with command: $> watch "cat /sys/kernel/debug/dma_buf/bufinfo | grep attached " (fd count grows continuously)
A simpler unit test shows that this problem come when waylandsink is fed with DMABuf while configured to setup a DRM Dumb pool (drm-device property): $> gst-launch-1.0 v4l2src io-mode=4 ! waylandsink drm-device=/dev/dri/card0
Expected Behavior
No premature exit and no memory leakage.
Setup
- STM32MP25-EV evaluation board
- GStreamer-1.22 + "Add DRM Dumb allocation support into Wayland Sinks" merge request: !3801 (commits)F0qlMZrDMs3PrcLpsvK618Vf61
Steps to reproduce the bug
$> gst-launch-1.0 v4l2src io-mode=4 ! waylandsink drm-device=/dev/dri/card0 (no premature exit) $> watch "cat /sys/kernel/debug/dma_buf/bufinfo | grep attached " (fd count must be stable)
How reproducible is the bug?
100%
Solutions you have tried
Root cause of issue is not 100% clear but there is no need to use internal DRM dumb pool if buffer to render is already a DMABuf: just import it and render it. A patch has been made consequently that fixes issue:
diff --git a/ext/wayland/gstwaylandsink.c b/ext/wayland/gstwaylandsink.c index 24a7174..99f6f29 100644 --- a/ext/wayland/gstwaylandsink.c +++ b/ext/wayland/gstwaylandsink.c @@ -912,7 +912,7 @@ gst_wayland_sink_show_frame (GstVideoSink * vsink, GstBuffer * buffer) * offloading the compositor from a copy helps maintaining a smoother * desktop. */ - if (!self->skip_dumb_buffer_copy) { + if (!wbuf && !self->skip_dumb_buffer_copy) { GstVideoFrame src, dst; if (!gst_wayland_activate_drm_dumb_pool (self)) {
Related non-duplicate issues
Same issue has been observed on gtkwaylandsink (same duplicated code as waylandsink so same issue).