emersion / xdg-desktop-portal-wlr

xdg-desktop-portal backend for wlroots
MIT License
590 stars 57 forks source link

Crash when screen casting #214

Closed zsolt-donca closed 2 years ago

zsolt-donca commented 2 years ago

I have trouble setting up xdpw on my new Arch Linux system using Sway, with Intel Alder Lake CPU and integrated GPU.

xdpw crashes when trying to do screen casting; I've included debug logs, coredump, and the sway logs: https://gist.github.com/zsolt-donca/7eda442053e0cfd3a848088fb0bdc361

Something that stood out for me in the logs was:

2022/06/04 07:28:56 [INFO] - wlroots: no modifiers available for format 0
2022/06/04 07:28:56 [ERROR] - xdg-desktop-portal-wlr: failed to convert drm format 0x00000000 to spa_video_format

Reproduced using a local xdpw build, and using xdp-screen-cast.py.

I am on an up-to-date Arch Linux, using the latest git versions of wlroots, sway.

The environment variables XDG_CURRENT_DESKTOP, WAYLAND_DISPLAY should be properly set.

columbarius commented 2 years ago

Please provide a log of xdpw with logleven TRACE

zsolt-donca commented 2 years ago

Here are the trace logs: https://gist.github.com/zsolt-donca/74c6e441ece55b7418b25c78829da98b

zsolt-donca commented 2 years ago

Did some further testing. Turns out that xdpw works just fine with the latest released versions of wlroots+sway, it the latest master builds that it crashes with. Any idea how to investigate this? Should I raise an issue with sway as well?

columbarius commented 2 years ago

You could create a log with the env var WAYLAND_DEBUG=1. This should print every wayland interaction. If you could bisect sway/wlroots, that would be great to find the faulty commit.

The issue is that the screencopy request just fails and as such we don't get any valid format.

2022/06/04 08:18:49 [TRACE] - wlroots: callbacks registered
2022/06/04 08:18:49 [TRACE] - wlroots: failed event handler

@emersion wasn't there a change recently how outputs are referenced? Could that be not applied to screencopy?

columbarius commented 2 years ago

it the latest master builds that it crashes with

I build it with the current git head and couldn't reproduce the issue. Did you update the wlroots subproject? Got one sway commit since the last time I build sway, but a lot of wlroot commits.

zsolt-donca commented 2 years ago

Did you update the wlroots subproject?

Yes, I did, as I am not building it manually but instead using the AUR builds, such as wlroots-git, sway-git. I know to build and install wlroots-git first, and only build sway-git afterwards, as sway depends on some header files that wlroots provides, and the two projects must be (binary?) compatible.

I build it with the current git head and couldn't reproduce the issue.

I just tried once again with the latest builds, and it once again makes xdpw crash. Version numbers, including the git revisions, the latest commits at the moment:

pacman -Q wlroots-git sway-git xdg-desktop-portal-wlr-git
wlroots-git 0.16.0.r5567.c2952411-1
sway-git r6935.e5728052-1
xdg-desktop-portal-wlr-git v0.5.0.r68.g0bbbd652-1

The bug itself is probably related to something specific to my configuration. I will do the bisection and get back with the results.

emersion commented 2 years ago

Probably due to https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3440

Nonetheless, xdpw should not crash when wlroots sends a failed event.

zsolt-donca commented 2 years ago

You could create a log with the env var WAYLAND_DEBUG=1. This should print every wayland interaction.

You can find it here: https://gist.github.com/zsolt-donca/894331799cc7dd18019122f849ece7a7 I hope it is useful.

zsolt-donca commented 2 years ago

Probably due to https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3440

You are right. I indeed have some similar logs (see sway log in here):

00:00:59.877 [ERROR] [wlr] [render/swapchain.c:97] No free output buffer slot 00:00:59.877 [ERROR] [wlr] [types/wlr_screencopy_v1.c:544] Failed to capture output: no read format supported by renderer

And the commit 93ee4c76 referenced in the above bug report does indeed work for me.

columbarius commented 2 years ago

Nonetheless, xdpw should not crash when wlroots sends a failed event.

Better idea then doing sth. like this? https://github.com/columbarius/xdg-desktop-portal-wlr/tree/drm-format-invalid Maybe with a retry loop?

emersion commented 2 years ago

Crash should be fixed in master, and Sway got fixed too.