** Description changed:

- [Impact]
- 
- GNOME Snapshot crashes immediately with a segmentation fault (SIGSEGV)
- when users attempt to use their webcam on Ubuntu 24.04 LTS (Noble). This
- makes the camera application completely unusable for all Noble users
- with PipeWire-based camera systems, which is the default configuration.
- 
- Technical Details:
- The crash occurs because PipeWire passes MemPtr (SPA_DATA_MemPtr) memory 
buffers to GStreamer's pipewiresrc element. These buffers wrap raw memory 
pointers that cannot be safely shared across threads. When GStreamer's 
videoconvert or videofilter elements in complex pipelines (with multiqueue 
threading) attempt to process these buffers, they fail due to use-after-free 
when the parent buffer is recycled by PipeWire, resulting in SIGSEGV.
- 
- How the fix works:
- The fix adds the "always-copy=true" property to pipewiresrc, which forces 
PipeWire to copy buffers into standard system memory instead of sharing MemPtr 
buffers. This ensures all GStreamer elements can safely process the video 
frames. The property check ensures compatibility with other camera source types 
(v4l2src) which don't have this property.
- 
- Upstream Status:
- Upstream fixed similar buffer handling issues in version 49.0+ by filtering 
sysmem caps after decoding (commit 024ef98 by Robert Mader from Collabora). 
However, that fix targets hardware JPEG decoders and requires the newer 
decodebin3 architecture. Noble ships version 46.2 which uses the older 
camerabin architecture. Our always-copy approach fixes the issue at the source 
level and is appropriate for the 46.2 codebase.
- 
- [Test Plan]
- 
- Prerequisites:
- - Ubuntu 24.04 Noble system with working webcam
- - PipeWire installed (default on Noble)
- - Camera device accessible at /dev/video0
- 
- Reproduction Steps (without fix):
- 1. Install current gnome-snapshot: sudo apt install gnome-snapshot
- 2. Launch the application: gnome-snapshot
- 3. Observe: Application crashes immediately with exit code 139 (SIGSEGV)
- 4. Check logs: journalctl -b | grep snapshot shows segmentation fault
- 
- Regression Testing:
- - Test with v4l2 camera sources (non-PipeWire) - should continue to work
- - Test on systems without PipeWire (should still work)
- - Verify no performance degradation during normal camera operations
- - Test picture and video quality remains unchanged
- 
- [Where problems could occur]
- 
- Performance Impact:
- The always-copy property disables MemPtr buffer sharing optimization, which 
means video frames will be copied instead of shared. This introduces a small 
performance overhead (additional memory copy operation for each frame). Users 
with high-resolution cameras (4K) or systems with limited memory bandwidth 
might notice slightly higher CPU usage during camera preview. However, the 
trade-off is necessary for application stability.
- 
- Memory Usage:
- With always-copy enabled, system memory usage will increase because frames 
are copied into system RAM instead of being shared. Systems with low available 
RAM might experience slightly higher memory pressure during camera operations. 
For typical use cases (single camera preview at 720p or 1080p), this increase 
should be minimal (typically 10-30MB additional RAM).
- 
- Compatibility Issues:
- If future versions of PipeWire or GStreamer change the behavior of the 
"always-copy" property, this could affect functionality. However, this is 
unlikely because:
- - The property is explicitly designed for this purpose
- - We check for property existence before setting it
- - The property is well-established in pipewiresrc
- 
- Non-PipeWire Systems:
- On systems using v4l2src directly (non-PipeWire camera stack), the property 
check will fail gracefully because v4l2src doesn't have the "always-copy" 
property. The has_property() check prevents any error or warning.
- 
- Hardware Decoder Interaction:
- On systems with hardware video decoders that rely on zero-copy optimization, 
forcing system memory copy might reduce efficiency of hardware acceleration. 
However, gnome-snapshot 46.2 uses camerabin which doesn't typically use 
hardware decoders for camera preview, so this risk is minimal.
- 
- [Other Info]
- 
- Why not use upstream's fix:
- Upstream's fix (commit 024ef98) filters sysmem caps after the decoder in the 
GStreamer pipeline. This approach requires the decodebin3 architecture 
introduced in 49.0+. Noble ships 46.2 which uses camerabin (high-level 
GStreamer element). The architectural difference makes upstream's fix 
incompatible with 46.2 for backporting.
- 
- Why always-copy is appropriate for 46.2:
- - Simple, well-tested property specifically designed for this use case
- - Minimal code change (2 lines of code)
- - Compatible with 46.2's camerabin architecture
- - Has property check ensures safety with different source types
- - Trade-off: Small performance cost for application stability
- 
- Future Upstream Improvements:
- Note that this is the appropriate fix for GNOME Snapshot 46.2, but upstream 
could improve this by fixing the root cause in PipeWire's GStreamer 
integration. Specifically, PipeWire's gstpipewirepool.c could mark GstBuffers 
appropriately when the underlying MemPtr memory cannot be safely shared across 
threads, allowing GStreamer elements to handle them correctly. However, such 
changes are beyond the scope of this Noble LTS fix, and the always-copy 
approach provides the stability needed for long-term support.
- 
- Security Considerations:
- This fix addresses a crash (denial of service) that prevents the application 
from functioning. While not a security vulnerability per se, it makes the 
camera application completely unusable.
- 
- Testing Coverage:
- Extensive testing performed across multiple Ubuntu releases:
- - Noble 24.04 (without fix): Confirmed crash with exit code 139
- - Noble 24.04 (with fix): Confirmed working, no crash
- - Questing 25.10: Already fixed upstream (49~alpha-0ubuntu2)
- - Resolute 26.04: Already fixed upstream (49.0-1ubuntu1)
- 
- Debian Coordination:
- This is an Ubuntu-specific patch because:
- - Debian Unstable/Testing already have newer versions (49.0+) with upstream's 
fix
- - The patch targets Noble LTS which needs long-term stability
- - Marked as "Forwarded: no" because upstream solved it differently in newer 
versions
+ Currently mipi camera failed to work on snapshot app on Ubuntu 24.04,
+ hope this issue can be fixed.

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/2076315

Title:
  Snapshot failed to work with v4l2-relayd/v4l2loopback devices

To manage notifications about this bug go to:
https://bugs.launchpad.net/oem-priority/+bug/2076315/+subscriptions


-- 
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to