Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support cropping via pipewire #156

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

columbarius
Copy link
Collaborator

@columbarius columbarius commented Jul 2, 2021

Depends: #141

Blockers:

  • Add an region option in the config file to be used with output_name and chooser_type = none
  • Extend the protocol between the chooser and xdpw to support a region.
  • Create a patch for slurp to output coordinates wrt. to the screen (local coordinates)

@columbarius columbarius marked this pull request as draft July 2, 2021 01:10
@columbarius columbarius force-pushed the cropping branch 2 times, most recently from d015d45 to 92c493b Compare July 6, 2021 14:05
@columbarius columbarius mentioned this pull request Jul 6, 2021
@columbarius
Copy link
Collaborator Author

Well... didn't increment the number of params announced to pipewire. Fixed!

@columbarius
Copy link
Collaborator Author

Do we want a xdpw_frame_damage and a xdpw_frame_crop or should we merge them into xdpw_frame_region?

@danshick danshick marked this pull request as ready for review July 7, 2021 02:46
@danshick danshick marked this pull request as draft July 7, 2021 02:47
@danshick
Copy link
Collaborator

danshick commented Jul 7, 2021

Whoops, sorry.

@danshick
Copy link
Collaborator

danshick commented Jul 7, 2021

Do we want a xdpw_frame_damage and a xdpw_frame_crop or should we merge them into xdpw_frame_region?

Maybe a frame_region with a "type" enum?

@columbarius
Copy link
Collaborator Author

Maybe a frame_region with a "type" enum?

I don't think we need a "type" enum, because the variable name should be telling enough like:

struct xdpw_region damage;
struct xdpw_region cropping;

Or am i missing something?

@columbarius
Copy link
Collaborator Author

Since i won't have time to pick this up in the next months I added a checklist with open points on top.
Adding a config option might happen, but for everything else feel free to pick it up.

@columbarius
Copy link
Collaborator Author

@Hubro: Added config option. It only works when no chooser is used. Documented in the manpage.

@columbarius
Copy link
Collaborator Author

rebased onto master

@Hubro
Copy link

Hubro commented Jun 23, 2022

@columbarius I may have run into another edge case with my weird setup 😅

I built xdg-desktop-portal-wlr from the most recent commit in the cropping branch (fea4934a) and set my configuration to:

[screencast]
max_fps=60
chooser_cmd=slurp -f %o -or
chooser_type=none
cropmode=wlroots
region=1280,0:2560x1412

And my screen capture now looks like this:

image

EDIT: cropmode=pipewire does not have the same issue
EDIT: Just checked if I could still screen-share in Chromium based browsers with cropmode=pipewire, and I can't 😞 They all immediately crash, just as if I hadn't cropped at all. (They can't handle 5120x1440 streaming for some reason.) The only way for me to screen share is to crop down to 2560x1440 or smaller using wlroots cropping.

@columbarius
Copy link
Collaborator Author

@Hubro Could you please add the option
force_mod_linear=1
to your config file and test obs again? If this doesn't improve things, please send a 'DEBUG' log.

@columbarius
Copy link
Collaborator Author

@Hubro Can you please explain what you did to produce the log. I see 4 finished negotiations, with the first one producing a lot of out of buffer events, which looks like the stream was stalled.

@Hubro
Copy link

Hubro commented Jun 26, 2022

@columbarius I started xdg-desktop-portal-wlr with -l DEBUG and piped the output to a log file, then I started OBS, exited OBS and stopped xdg-desktop-portal-wlr. However, in hindsight, I did use tee to pipe the output, so I guess logs from several attempts may have ended up in the same file.

I've produced a new debug log file now, from this command:

./build/xdg-desktop-portal-wlr -l DEBUG > ~/Desktop/xdg-desktop-portal-wlr-debug.log 2>&1

Result: https://gist.githubusercontent.com/Hubro/8cf609df0c7b10654b40179258f7c39c/raw/7b6da667e5ee25dff7ecca32300edb32db95e299/xdg-desktop-portal-wlr-debug.log

All I did now was:

  1. Run the command
  2. Launch OBS
  3. Wait a few seconds
  4. Close OBS
  5. Stop the command

@columbarius
Copy link
Collaborator Author

@Hubro please see #223

@Hubro
Copy link

Hubro commented Jun 30, 2022

@Hubro please see #223

Just left for a 2 week vacation away from my glorious monitor... 💔

I will take a look as soon as I get home!

@columbarius columbarius mentioned this pull request Jul 14, 2022
@betaboon
Copy link

is there any way we can help to move this forward ?

@bhcopeland
Copy link

Is there anyway we can push this? I'd love to screen select record on Meet, it would be a awesome feature.

Happy to put some money into a bounty!

@columbarius columbarius changed the title Support reporting damage and cropping via pipewire Support cropping via pipewire Feb 20, 2023
@columbarius
Copy link
Collaborator Author

Damage tracking was merged via #203

Updated this to current master

@oneingan
Copy link

oneingan commented Jun 24, 2023

Using this commit, with or without enabling crop, core dump me. While 0.7.0 release with same build steps and closure works ok.


Jun 24 15:31:03 x2100 systemd-coredump[39343]: [🡕] Process 39057 (.xdg-desktop-po) of user 1000 dumped core.
                                               
                                               Module libXdmcp.so.6 without build-id.
                                               Module libXau.so.6 without build-id.
                                               Module libxcb.so.1 without build-id.
                                               Module libxml2.so.2 without build-id.
                                               Module libncursesw.so.6 without build-id.
                                               Module libgcc_s.so.1 without build-id.
                                               Module libstdc++.so.6 without build-id.
                                               Module libxcb-dri3.so.0 without build-id.
                                               Module libdrm_nouveau.so.2 without build-id.
                                               Module libdrm_amdgpu.so.1 without build-id.
                                               Module libelf.so.0 without build-id.
                                               Module libdrm_radeon.so.1 without build-id.
                                               Module libz.so.1 without build-id.
                                               Module libpipewire-module-session-manager.so without build-id.
                                               Module libpipewire-module-metadata.so without build-id.
                                               Module libpipewire-module-adapter.so without build-id.
                                               Module libpipewire-module-client-device.so without build-id.
                                               Module libpipewire-module-client-node.so without build-id.
                                               Module libpipewire-module-protocol-native.so without build-id.
                                               Module libdbus-1.so.3 without build-id.
                                               Module libspa-dbus.so without build-id.
                                               Module libspa-journal.so without build-id.
                                               Module libspa-support.so without build-id.
                                               Module libgpg-error.so.0 without build-id.
                                               Module libexpat.so.1 without build-id.
                                               Module liblz4.so.1 without build-id.
                                               Module libzstd.so.1 without build-id.
                                               Module liblzma.so.5 without build-id.
                                               Module libgcrypt.so.20 without build-id.
                                               Module libcap.so.2 without build-id.
                                               Module libffi.so.8 without build-id.
                                               Module libdrm.so.2 without build-id.
                                               Module libinih.so.0 without build-id.
                                               Module libpipewire-0.3.so.0 without build-id.
                                               Module libsystemd.so.0 without build-id.
                                               Module .xdg-desktop-portal-wlr-wrapped without build-id.
                                               Stack trace of thread 39057:
                                               #0  0x00007f630a1eb062 update_params (libpipewire-0.3.so.0 + 0xa0062)
                                               #1  0x00007f630a1f73d6 pw_stream_update_params (libpipewire-0.3.so.0 + 0xac3d6)
                                               #2  0x00000000004103db pwr_handle_stream_param_changed (.xdg-desktop-portal-wlr-wrapped + 0x103db)
                                               #3  0x00007f630a1ec48d impl_port_set_param (libpipewire-0.3.so.0 + 0xa148d)
                                               #4  0x00007f630a1dfdab pw_impl_port_set_param (libpipewire-0.3.so.0 + 0x94dab)
                                               #5  0x00007f6309a2b4b7 client_node_port_set_param (libpipewire-module-client-node.so + 0x154b7)
                                               #6  0x00007f6309a37f0f client_node_demarshal_port_set_param (libpipewire-module-client-node.so + 0x21f0f)
                                               #7  0x00007f6309a867c4 process_remote (libpipewire-module-protocol-native.so + 0x177c4)
                                               #8  0x00007f6309a86e38 on_remote_data (libpipewire-module-protocol-native.so + 0x17e38)
                                               #9  0x00007f6309b31e56 loop_iterate (libspa-support.so + 0x9e56)
                                               #10 0x0000000000404e30 main (.xdg-desktop-portal-wlr-wrapped + 0x4e30)
                                               #11 0x00007f6309f59ace __libc_start_call_main (libc.so.6 + 0x23ace)
                                               #12 0x00007f6309f59b89 __libc_start_main@@GLIBC_2.34 (libc.so.6 + 0x23b89)
                                               #13 0x0000000000405075 _start (.xdg-desktop-portal-wlr-wrapped + 

DEBUG output is:

$> /nix/store/5vixb5vld63yjxj3562cr5n11nidrk2n-xdg-desktop-portal-wlr-0.7.0/libexec/xdg-desktop-portal-wlr --config=/nix/store/gns41xkid70v1nc3accnsjwgj3zyxin6-xdg-desktop-portal-wlr.ini -l DEBUG
2023/06/24 15:34:58 [DEBUG] - config: outputname:  (null)
2023/06/24 15:34:58 [DEBUG] - config: max_fps:  0.000000
2023/06/24 15:34:58 [DEBUG] - config: exec_before:  (null)
2023/06/24 15:34:58 [DEBUG] - config: exec_after:  (null)
2023/06/24 15:34:58 [DEBUG] - config: chooser_cmd: (null)
2023/06/24 15:34:58 [DEBUG] - config: chooser_type: default
2023/06/24 15:34:58 [DEBUG] - config: force_mod_linear: 0
2023/06/24 15:34:58 [DEBUG] - config: cropmode: none
2023/06/24 15:34:58 [DEBUG] - config: cropping_region x: 0
2023/06/24 15:34:58 [DEBUG] - config: cropping_region y: 0
2023/06/24 15:34:58 [DEBUG] - config: cropping_region width: 0
2023/06/24 15:34:58 [DEBUG] - config: cropping_region height: 0
2023/06/24 15:34:58 [DEBUG] - dbus: connected
2023/06/24 15:34:58 [DEBUG] - wlroots: wl_display connected
2023/06/24 15:34:58 [DEBUG] - pipewire: pw_loop created
2023/06/24 15:34:58 [DEBUG] - pipewire: establishing connection to core
2023/06/24 15:34:58 [DEBUG] - wlroots: interface to register wl_shm  (Version: 1)
2023/06/24 15:34:58 [DEBUG] - wlroots: |-- registered to interface wl_shm (Version 1)
2023/06/24 15:34:58 [DEBUG] - wlroots: interface to register wl_drm  (Version: 2)
2023/06/24 15:34:58 [DEBUG] - wlroots: interface to register zwp_linux_dmabuf_v1  (Version: 4)
2023/06/24 15:34:58 [DEBUG] - wlroots: |-- registered to interface zwp_linux_dmabuf_v1 (Version 4)
2023/06/24 15:34:58 [DEBUG] - wlroots: interface to register wl_compositor  (Version: 5)
2023/06/24 15:34:58 [DEBUG] - wlroots: interface to register wl_subcompositor  (Version: 1)
2023/06/24 15:34:58 [DEBUG] - wlroots: interface to register xdg_wm_base  (Version: 2)
2023/06/24 15:34:58 [DEBUG] - wlroots: interface to register zwlr_layer_shell_v1  (Version: 4)
2023/06/24 15:34:58 [DEBUG] - wlroots: interface to register zwlr_foreign_toplevel_manager_v1  (Version: 3)
2023/06/24 15:34:58 [DEBUG] - wlroots: interface to register xdg_activation_v1  (Version: 1)
2023/06/24 15:34:58 [DEBUG] - wlroots: interface to register zwp_primary_selection_device_manager_v1  (Version: 1)
2023/06/24 15:34:58 [DEBUG] - wlroots: interface to register zxdg_decoration_manager_v1  (Version: 1)
2023/06/24 15:34:58 [DEBUG] - wlroots: interface to register zxdg_output_manager_v1  (Version: 3)
2023/06/24 15:34:58 [DEBUG] - wlroots: interface to register zwlr_output_manager_v1  (Version: 4)
2023/06/24 15:34:58 [DEBUG] - wlroots: interface to register zwlr_output_power_manager_v1  (Version: 1)
2023/06/24 15:34:58 [DEBUG] - wlroots: interface to register ext_idle_notifier_v1  (Version: 1)
2023/06/24 15:34:58 [DEBUG] - wlroots: interface to register zwp_pointer_constraints_v1  (Version: 1)
2023/06/24 15:34:58 [DEBUG] - wlroots: interface to register zwp_relative_pointer_manager_v1  (Version: 1)
2023/06/24 15:34:58 [DEBUG] - wlroots: interface to register zwlr_virtual_pointer_manager_v1  (Version: 2)
2023/06/24 15:34:58 [DEBUG] - wlroots: interface to register zwp_virtual_keyboard_manager_v1  (Version: 1)
2023/06/24 15:34:58 [DEBUG] - wlroots: interface to register wl_seat  (Version: 8)
2023/06/24 15:34:58 [DEBUG] - wlroots: interface to register zwp_pointer_gestures_v1  (Version: 3)
2023/06/24 15:34:58 [DEBUG] - wlroots: interface to register zriver_control_v1  (Version: 1)
2023/06/24 15:34:58 [DEBUG] - wlroots: interface to register zriver_status_manager_v1  (Version: 4)
2023/06/24 15:34:58 [DEBUG] - wlroots: interface to register river_layout_manager_v3  (Version: 2)
2023/06/24 15:34:58 [DEBUG] - wlroots: interface to register zwp_idle_inhibit_manager_v1  (Version: 1)
2023/06/24 15:34:58 [DEBUG] - wlroots: interface to register ext_session_lock_manager_v1  (Version: 1)
2023/06/24 15:34:58 [DEBUG] - wlroots: interface to register wl_data_device_manager  (Version: 3)
2023/06/24 15:34:58 [DEBUG] - wlroots: interface to register zwlr_data_control_manager_v1  (Version: 2)
2023/06/24 15:34:58 [DEBUG] - wlroots: interface to register zwlr_export_dmabuf_manager_v1  (Version: 1)
2023/06/24 15:34:58 [DEBUG] - wlroots: interface to register zwlr_gamma_control_manager_v1  (Version: 1)
2023/06/24 15:34:58 [DEBUG] - wlroots: interface to register zwlr_screencopy_manager_v1  (Version: 3)
2023/06/24 15:34:58 [DEBUG] - wlroots: |-- registered to interface zwlr_screencopy_manager_v1 (Version 3)
2023/06/24 15:34:58 [DEBUG] - wlroots: interface to register wp_single_pixel_buffer_manager_v1  (Version: 1)
2023/06/24 15:34:58 [DEBUG] - wlroots: interface to register wp_viewporter  (Version: 1)
2023/06/24 15:34:58 [DEBUG] - wlroots: interface to register wl_output  (Version: 4)
2023/06/24 15:34:58 [DEBUG] - wlroots: |-- registered to interface wl_output (Version 4)
2023/06/24 15:34:58 [DEBUG] - wayland: registry listeners run
2023/06/24 15:34:58 [DEBUG] - wlroots: linux_dmabuf_feedback_handle_main_device called
2023/06/24 15:34:58 [INFO] - xdpw: Using render node /dev/dri/renderD128
2023/06/24 15:34:58 [DEBUG] - wlroots: linux_dmabuf_feedback_format_table called
2023/06/24 15:34:58 [DEBUG] - wlroots: linux_dmabuf_feedback_tranche_target_devices called
2023/06/24 15:34:58 [DEBUG] - wlroots: linux_dmabuf_feedback_tranche_flags called
2023/06/24 15:34:58 [DEBUG] - wlroots: linux_dmabuf_feedback_tranche_formats called
2023/06/24 15:34:58 [DEBUG] - wlroots: linux_dmabuf_feedback_tranche_done called
2023/06/24 15:34:58 [DEBUG] - wlroots: linux_dmabuf_feedback_handle_done called
2023/06/24 15:34:58 [DEBUG] - wayland: dmabuf_feedback listeners run
2023/06/24 15:35:14 [INFO] - dbus: create session method invoked
2023/06/24 15:35:14 [INFO] - dbus: request_handle: /org/freedesktop/portal/desktop/request/1_18/webrtc_700658314
2023/06/24 15:35:14 [INFO] - dbus: session_handle: /org/freedesktop/portal/desktop/session/1_18/webrtc_session847366510
2023/06/24 15:35:14 [INFO] - dbus: app_id: 
2023/06/24 15:35:14 [INFO] - dbus: select sources method invoked
2023/06/24 15:35:14 [INFO] - dbus: request_handle: /org/freedesktop/portal/desktop/request/1_18/webrtc1110809563
2023/06/24 15:35:14 [INFO] - dbus: session_handle: /org/freedesktop/portal/desktop/session/1_18/webrtc_session847366510
2023/06/24 15:35:14 [INFO] - dbus: app_id: 
2023/06/24 15:35:14 [DEBUG] - dbus: select sources: found matching session /org/freedesktop/portal/desktop/session/1_18/webrtc_session847366510
2023/06/24 15:35:14 [INFO] - dbus: option types:3
2023/06/24 15:35:14 [INFO] - dbus: option multiple: 0
2023/06/24 15:35:14 [INFO] - dbus: option persist_mode:1
2023/06/24 15:35:14 [INFO] - wlroots: capturable output: LG Display model: 0x0582: id: 34 name: eDP-1
2023/06/24 15:35:14 [DEBUG] - wlroots: output chooser called
2023/06/24 15:35:14 [DEBUG] - wlroots: output chooser called
2023/06/24 15:35:14 [DEBUG] - wlroots: output chooser selects eDP-1
2023/06/24 15:35:14 [INFO] - xdpw: screencast instance 0x162da00 has 1 references
2023/06/24 15:35:14 [INFO] - xdpw: 1 active screencast instances
2023/06/24 15:35:14 [INFO] - wlroots: output: eDP-1
2023/06/24 15:35:14 [INFO] - dbus: start method invoked
2023/06/24 15:35:14 [INFO] - dbus: request_handle: /org/freedesktop/portal/desktop/request/1_18/webrtc1866088784
2023/06/24 15:35:14 [INFO] - dbus: session_handle: /org/freedesktop/portal/desktop/session/1_18/webrtc_session847366510
2023/06/24 15:35:14 [INFO] - dbus: app_id: 
2023/06/24 15:35:14 [INFO] - dbus: parent_window: 
2023/06/24 15:35:14 [DEBUG] - dbus: start: found matching session /org/freedesktop/portal/desktop/session/1_18/webrtc_session847366510
2023/06/24 15:35:14 [INFO] - wlroots: num_modififiers 5
2023/06/24 15:35:14 [INFO] - pipewire: stream state changed to "connecting"
2023/06/24 15:35:14 [INFO] - pipewire: node id is -1
2023/06/24 15:35:14 [INFO] - pipewire: stream state changed to "paused"
2023/06/24 15:35:14 [INFO] - pipewire: node id is 57
2023/06/24 15:35:14 [DEBUG] - dbus: start: returning node 57
2023/06/24 15:35:14 [INFO] - wlroots: num_modififiers 5
2023/06/24 15:35:14 [DEBUG] - pipewire: Format negotiated:
2023/06/24 15:35:14 [DEBUG] - pipewire: buffer_type: 1 (8)
2023/06/24 15:35:14 [DEBUG] - pipewire: format: 8
2023/06/24 15:35:14 [DEBUG] - pipewire: modifier: 72057594037927940
2023/06/24 15:35:14 [DEBUG] - pipewire: size: (3000, 2000)
2023/06/24 15:35:14 [DEBUG] - pipewire: max_framerate: (59 / 1)
fish: Job 1, '/nix/store/5vixb5vld63yjxj3562c…' terminated by signal SIGSEGV (Address boundary error)

@oneingan
Copy link

solved: columbarius#2

@bhcopeland
Copy link

Apologise, what is left to do for this?

Also, is it in working state, now? Would it be possible for someone to share the .config?

@columbarius
Copy link
Collaborator Author

solved: columbarius#2

Thanks fixed that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants