Bug 502891 - Spectacle fails to save a screencast of a window that's moved and resized while using H.264 encoding
Summary: Spectacle fails to save a screencast of a window that's moved and resized whi...
Status: CONFIRMED
Alias: None
Product: Spectacle
Classification: Applications
Component: General (other bugs)
Version First Reported In: 6.3.4
Platform: Fedora RPMs Linux
: NOR major
Target Milestone: ---
Assignee: Noah Davis
URL:
Keywords: drkonqi
Depends on:
Blocks:
 
Reported: 2025-04-16 17:45 UTC by Roke Julian Lockhart Beedell
Modified: 2025-08-16 12:03 UTC (History)
4 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report: https://crash-reports.kde.org/organizations/kde/issues/164090/events/6fd7e6f1f6e444ae96dd9884fcbe1767/


Attachments
New crash information added by DrKonqi (188.74 KB, text/plain)
2025-04-16 17:45 UTC, Roke Julian Lockhart Beedell
Details
A Screencast Reproducing What I Recorded When the ANR Occurred (59.23 KB, video/webm)
2025-04-16 17:47 UTC, Roke Julian Lockhart Beedell
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Roke Julian Lockhart Beedell 2025-04-16 17:45:49 UTC
Application: spectacle (6.3.4)

ApplicationNotResponding [ANR]: true
Qt Version: 6.8.2
Frameworks Version: 6.13.0
Operating System: Linux 6.14.2-300.fc42.x86_64 x86_64
Windowing System: Wayland
Distribution: "Fedora Linux 42 (KDE Plasma Desktop Edition)"
DrKonqi: 6.3.4 [CoredumpBackend]

-- Information about the crash:
Via spectacle-6.3.4-1.fc42.x86_64, I initiated a window-specific screencast of the KDE implementation of the FreeDesktop file Picker, invoked by the Gittyup Flatpak (from Flathub):

>           ID: com.github.Murmele.Gittyup  
>          Ref: app/com.github.Murmele.Gittyup/x86_64/stable  
>         Arch: x86_64  
>       Branch: stable  
>      Version: v1.4.0  
>      License: MIT  
>       Origin: flathub  
>   Collection: org.flathub.Stable  
> Installation: system  
>    Installed: 72.4 MB  
>      Runtime: org.kde.Platform/x86_64/5.15-23.08  
>          Sdk: org.kde.Sdk/x86_64/5.15-23.08  
>   
>       Commit: adfe463ee26a63bdaaa0af13f71e26bf9a925d37f43b4527c7b14625ab5a08a7  
>       Parent: 7e1c9370a1a462478b7fac34aac11882cb62768886aa23fe4fd36fb23c17e19b  
>      Subject: update to release 1.4.0 (#44) (21f22a60)  
>         Date: 2024-05-15 22:15:19 +0000

During the screencast, I resized its QDockWidget in order to demonstrate a bug, then resized the window via the right-hand side handles that the Breeze decorations expose.

When I attempted to save the recording by primary-clicking the System Tray icon, Spectacle indefinitely hung. After approximately 1.5 minutes, I accepted Plasma's suggestion (delivered via modal window) to terminate Spectacle, whereupon Dr. Konqi appeared.

The crash does not seem to be reproducible.

-- Backtrace (Reduced):
#5  __syscall_cancel_arch () at ../sysdeps/unix/sysv/linux/x86_64/syscall_cancel.S:52
#6  0x00007f178727aaba in __internal_syscall_cancel (a1=<optimized out>, a2=<optimized out>, a3=<optimized out>, a4=<optimized out>, a5=a5@entry=0, a6=a6@entry=4294967295, nr=202) at cancellation.c:49
#7  0x00007f178727b12c in __futex_abstimed_wait_common64 (private=0, futex_word=0x5624821cd698, expected=<optimized out>, op=<optimized out>, abstime=0x0, cancel=true) at futex-internal.c:57
#8  __futex_abstimed_wait_common (futex_word=futex_word@entry=0x5624821cd698, expected=<optimized out>, clockid=clockid@entry=0, abstime=abstime@entry=0x0, private=private@entry=0, cancel=cancel@entry=true) at futex-internal.c:87
#9  0x00007f178727b18f in __GI___futex_abstimed_wait_cancelable64 (futex_word=futex_word@entry=0x5624821cd698, expected=<optimized out>, clockid=clockid@entry=0, abstime=abstime@entry=0x0, private=private@entry=0) at futex-internal.c:139


Reported using DrKonqi
Comment 1 Roke Julian Lockhart Beedell 2025-04-16 17:45:50 UTC
Created attachment 180320 [details]
New crash information added by DrKonqi

DrKonqi auto-attaching complete backtrace.
Comment 2 Roke Julian Lockhart Beedell 2025-04-16 17:47:32 UTC
Created attachment 180321 [details]
A Screencast Reproducing What I Recorded When the ANR Occurred

This is ultimately for a separate bug that I'm yet to file.
Comment 3 Nate Graham 2025-04-17 15:18:50 UTC
Can reproduce this issue. It's more severe than Bug 473369, which was another similar issue with modifying the geometry of a window while being recorded.

Conceptually, the problem here is that recording a window makes assumptions about that window's position and geometry remaining static that can't be guaranteed.

Perhaps we should re-architect this feature to actually take a rectangle recording of the region where the window is, and then if the user later resizes or moves the window, they have to live with clipping.
Comment 4 Nate Graham 2025-04-21 10:56:32 UTC
Does this only happen when recording using the H.264 format?

With git master, I can reproduce it only with H.264, and not VP9.
Comment 5 Roke Julian Lockhart Beedell 2025-04-21 18:19:14 UTC
Likewise. Can reproduce with the H.264 MPEG-4, but not the VP9 WebM.
Comment 6 Roke Julian Lockhart Beedell 2025-04-22 14:38:40 UTC
(In reply to Roke Julian Lockhart Beedell from comment #2)  

> This is ultimately for a separate bug that I'm yet to file.

Mentioned at https://discuss.kde.org/t/can-anyone-else-resize-the-panel-of-the-directory-picker-portal/33180?u=rokejulianlockhart.
Comment 7 Noah Davis 2025-06-03 00:24:08 UTC
Seems like resizing an h264 video causes a lot of these console messages:

> [mp4 @ 0x7f43d4058f40] Application provided invalid, non monotonically increasing dts to muxer in stream 0: 131940 >= 131940

> kpipewire_record_logging: Error while writing output packet: Invalid argument

> [in @ 0x7f43d4055780] filter context - w: 1132 h: 800 fmt: 179, incoming frame - w: 1142 h: 800 fmt: 179 pts_time: 1.716

> [in @ 0x7f43d4055780] Changing video frame properties on the fly is not supported by all filters.

> [AVHWFramesContext @ 0x7f43d4213240] Failed to create surface from DRM object: 18 (invalid parameter).

> [Parsed_hwmap_0 @ 0x7f43d4056180] Failed to map frame: -5.

> kpipewire_record_logging: Failed receiving filtered frame: Input/output error

Interestingly, this only happens with the VAAPI h264 encoder. You can force x264 software encoding with `KPIPEWIRE_FORCE_ENCODER=libx264 spectacle`.
Comment 8 DeKay 2025-08-02 14:09:53 UTC
For me, the bug is more severe than this. Spectacle doesn't save mp4 files for me whether I resize anything or not when recording a rectangular region of the screen. VP9 works fine.

> [dk@ryzen ~]$ spectacle
> kpipewire_vaapi_logging: VAAPI: Mesa Gallium driver 25.1.6-arch1.1 for AMD Radeon RX 560 Series (radeonsi, polaris11, ACO, DRM 3.63, 6.15.8-arch1-1) in use for device "/dev/dri/renderD128"
> (record rectangular region of screen, stop recording)
> Segmentation fault         (core dumped) spectacle

The `KPIPEWIRE_FORCE_ENCODER=libx264 spectacle` workaround mentioned above *does work* though.

[dk@ryzen ~]$ kinfo
Operating System: Arch Linux 
KDE Plasma Version: 6.4.3
KDE Frameworks Version: 6.16.0
Qt Version: 6.9.1
Kernel Version: 6.15.8-arch1-1 (64-bit)
Graphics Platform: Wayland