Skip to content

Conversation

@emersion
Copy link
Owner

@emersion emersion commented Jul 19, 2025

  • Resizing doesn't work yet (but that's orthogonal to capture sources)
  • wlroots doesn't support capturing toplevel cursors yet
  • Sway doesn't include child toplevels in the parent toplevel capture

Some work has been stolen from #329

@emersion emersion mentioned this pull request Jul 19, 2025
2 tasks
@pmkap
Copy link

pmkap commented Jul 20, 2025

I'm getting a segfault

(gdb) bt
#0  0x0000000000000000 in ?? ()
#1  0x00006392783a23d0 in xdpw_buffer_destroy (buffer=0x63928faee9d0)
    at ../src/screencast/screencast_common.c:209
#2  0x00006392783ac94f in pwr_handle_stream_remove_buffer (data=0x63928f9e6c20, 
    buffer=0x63928faab888) at ../src/screencast/pipewire_screencast.c:559
#3  0x00007067fe5d5d0b in clear_buffers (stream=stream@entry=0x63928faab440)
    at ../pipewire/src/pipewire/stream.c:832
#4  0x00007067fe5d61a8 in impl_port_set_param (object=0x63928faab440, 
    direction=<optimized out>, port_id=<optimized out>, id=4, 
    flags=<optimized out>, param=<optimized out>)
    at ../pipewire/src/pipewire/stream.c:915
#5  0x00007067fe5cd48f in spa_node_port_set_param (object=<optimized out>, 
    direction=<optimized out>, port_id=<optimized out>, id=4, flags=0, 
    param=0x63928f9d7900) at ../pipewire/spa/include/spa/node/node.h:718
#6  pw_impl_port_set_param (port=port@entry=0x63928fab4f20, id=id@entry=4, 
    flags=flags@entry=0, param=param@entry=0x63928f9d7900)
    at ../pipewire/src/pipewire/impl-port.c:1827
#7  0x00007067fd0a7fd8 in client_node_port_set_param (_data=0x63928fa768f8, 
    direction=SPA_DIRECTION_OUTPUT, port_id=0, id=4, flags=0, param=0x63928f9d7900)
    at ../pipewire/src/modules/module-client-node/remote-node.c:564
#8  0x00007067fd0bb740 in client_node_demarshal_port_set_param (
    data=<optimized out>, msg=<optimized out>)
    at ../pipewire/src/modules/module-client-node/protocol-native.c:496
#9  0x00007067fd0d662e in process_remote (impl=impl@entry=0x63928f9cd680)
    at ../pipewire/src/modules/module-protocol-native.c:1095
#10 0x00007067fd0d6cd8 in on_remote_data (data=0x63928f9cd680, fd=16, mask=5)
    at ../pipewire/src/modules/module-protocol-native.c:1129
#11 0x00007067fe759d46 in loop_iterate (object=<optimized out>, 
--Type <RET> for more, q to quit, c to continue without paging--
    timeout=<optimized out>) at ../pipewire/spa/plugins/support/loop.c:726
#12 0x000063927839badf in spa_loop_control_iterate_fast (object=0x63928f9a8300, 
    timeout=0) at /usr/include/spa-0.2/spa/support/loop.h:312
#13 0x000063927839bb48 in pw_loop_iterate (object=0x63928f9a8190, timeout=0)
    at /usr/include/pipewire-0.3/pipewire/loop.h:89
#14 0x000063927839c4e7 in main (argc=1, argv=0x7ffe30d43aa8)
    at ../src/core/main.c:262
(gdb) frame 1
#1  0x00006392783a23d0 in xdpw_buffer_destroy (buffer=0x63928faee9d0)
    at ../src/screencast/screencast_common.c:209
209			gbm_bo_destroy(buffer->bo);
(gdb) p buffer->bo
$4 = (struct gbm_bo *) 0x63928fa92d60

buffer->bo is not NULL

I'm trying to reproduce and find out more.

My compositor implementation that I'm testing: https://codeberg.org/pkap/river/src/branch/toplevel-capture

@emersion
Copy link
Owner Author

I'm getting a segfault

How do you trigger the segfault? It sounds unrelated to toplevel capture (ie, I think it would affect output capture as well).

@pmkap
Copy link

pmkap commented Jul 21, 2025

@emersion

How do you trigger the segfault? It sounds unrelated to toplevel capture (ie, I think it would affect output capture as well).

It happens when I resize the shared toplevel. When I build with meson setup build -Db_sanitize=address && ninja -C build, this crash does not occur and everything works perfectly, even the resizing. (just some [ERROR] - ext: frame capture failed: buffer constraint mismatch, but it works)

edit: here's more stacktrace

#0  0x00007ed79943c1e1 in dri2_destroy_image () at ../mesa-25.1.5/src/gallium/frontends/dri/dri_helpers.c:332
#1  0x00007ed79bf1754c in gbm_dri_bo_destroy () at ../mesa-25.1.5/src/gbm/backends/dri/gbm_dri.c:633
#2  0x00005a6390cad43b in xdpw_buffer_destroy (buffer=0x5a63b497a180) at ../src/screencast/screencast_common.c:209
#3  0x00005a6390cb79ba in pwr_handle_stream_remove_buffer (data=0x5a63b48d12b0, buffer=0x5a63b4995cb8)
    at ../src/screencast/pipewire_screencast.c:559

@Molytho
Copy link

Molytho commented Jul 21, 2025

What is the expected behavior when a streamed window is closed. I quickly dipped into the portal spec and could not find anything.
In my opinion the screencast session should probably be closed (sending the closed signal) which is not done at the moment as far as I can tell.

@emersion
Copy link
Owner Author

emersion commented Jul 24, 2025

Updated to fix the crash on resize and send the Closed signal.

Copy link
Collaborator

@kennylevinsen kennylevinsen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One small cleanup nit (which is inherited from my original PR I believe), but otherwise LGTM!

Copy link
Collaborator

@kennylevinsen kennylevinsen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. :)

@kennylevinsen kennylevinsen merged commit e471c3d into master Jul 31, 2025
3 checks passed
@kennylevinsen kennylevinsen deleted the toplevel-capture branch July 31, 2025 13:43
@emersion
Copy link
Owner Author

Thank you!

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.

5 participants