Skip to content

Conversation

@abmantis
Copy link
Contributor

@abmantis abmantis commented Jul 27, 2025

This implements cursor metadata for pipewire window and output screencasts.

Fixes #115.

Copy link
Owner

@YaLTeR YaLTeR left a comment

Choose a reason for hiding this comment

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

Please rebase onto main, it has the necessary spa_buffer access.

src/pw_utils.rs Outdated
Comment on lines 1015 to 1023
// TODO: Can the bitmap be initialized previously in start_cast?
// Alternativelly, initialize on first pass. For this, bitmap_offset must be 0 on
Copy link
Owner

Choose a reason for hiding this comment

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

Since the cursor changes at runtime, it should be tracked separately with its own OutputDamageTracker, sent as a spa_meta_bitmap whenever it changes, and otherwise don't send a new bitmap.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For some reason (pipewire acting up?) if I do that sometimes it does not update the cursor when it changes on the screencast, despite it being sent. For now I'll leave that optimization out and try to look into it later.

@abmantis
Copy link
Contributor Author

abmantis commented Aug 7, 2025

Please rebase onto main, it has the necessary spa_buffer access.

I did rebase to main yesterday, but it now seems to have some issue with the cursor bitmap buffer which I haven't figured out yet. Probably some bad pointer offset calculation. I should take a look at it back later today.

@abmantis
Copy link
Contributor Author

abmantis commented Aug 8, 2025

For some reason, without 15b4acc#diff-a517890ab4c703e485977a1943ceb154a6bcb3cc4d83135097a2841d569e7326L930-L931 the cast just stops after a second:

I've printed the stride and offset from the dmabuf and the current ones on the chunks, and for some reason the chunk ones overflow:

2025-08-08T14:18:18.137093Z DEBUG niri::pw_utils: pw stream: moving to ready state
2025-08-08T14:18:18.139977Z DEBUG niri::pw_utils: pw stream: state changed: Paused -> Streaming
2025-08-08T14:18:18.140313Z DEBUG niri::pw_utils: pw buffer: fd = 183, stride = 7168, offset = 0
2025-08-08T14:18:18.140324Z DEBUG niri::pw_utils: pw buffer: chunk stride = 7168, chunk offset = 0
2025-08-08T14:18:18.140329Z DEBUG niri::pw_utils: pw buffer: fd = 184, stride = 2048, offset = 10092544
2025-08-08T14:18:18.140333Z DEBUG niri::pw_utils: pw buffer: chunk stride = 2048, chunk offset = 10092544
2025-08-08T14:18:18.152639Z DEBUG niri::pw_utils: pw buffer: fd = 185, stride = 7168, offset = 0
2025-08-08T14:18:18.152673Z DEBUG niri::pw_utils: pw buffer: chunk stride = 7168, chunk offset = 0
2025-08-08T14:18:18.152681Z DEBUG niri::pw_utils: pw buffer: fd = 186, stride = 2048, offset = 10092544
2025-08-08T14:18:18.152688Z DEBUG niri::pw_utils: pw buffer: chunk stride = 2048, chunk offset = 10092544
2025-08-08T14:18:18.742885Z DEBUG niri::pw_utils: pw buffer: fd = 187, stride = 7168, offset = 0
2025-08-08T14:18:18.742918Z DEBUG niri::pw_utils: pw buffer: chunk stride = -1426063361, chunk offset = 2868903935
2025-08-08T14:18:18.742921Z DEBUG niri::pw_utils: pw buffer: fd = 188, stride = 2048, offset = 10092544
2025-08-08T14:18:18.742924Z DEBUG niri::pw_utils: pw buffer: chunk stride = -1442840576, chunk offset = 2852126720
2025-08-08T14:18:18.745123Z DEBUG niri::pw_utils: pw stream: state changed: Streaming -> Paused

They only overflow when I write to the bitmap array. I don't see anything wrong with the bitmap, so maybe something is failing to take the extra bitmap size into account?

@YaLTeR
Copy link
Owner

YaLTeR commented Aug 9, 2025

Hmm, idk, I looked through this PR's diff and the code in mutter and couldn't see a problem off the bat. Try filling the bitmap with sentinel values (like 0x01, 0x02, 0x03 and so on) to see where it overwrites subsequent data? Maybe check with gdb?

@abmantis abmantis force-pushed the window_cast_pointer_meta_on_pw_explicit_sync branch from ad73a89 to 1e654e0 Compare August 13, 2025 22:51
@abmantis abmantis changed the base branch from pw-explicit-sync to main August 13, 2025 22:57
@abmantis
Copy link
Contributor Author

Hmm, idk, I looked through this PR's diff and the code in mutter and couldn't see a problem off the bat. Try filling the bitmap with sentinel values (like 0x01, 0x02, 0x03 and so on) to see where it overwrites subsequent data? Maybe check with gdb?

I'm struggling to find the cause of this. The cursor_meta pointer is slightly different on every frame, which makes it so that I can't just watch that memory space for changes.
I'll keep trying, but I've pushed the code here in case some one wants to try it too. This is now based on main, but contains a revert of 15b4acc

@abmantis
Copy link
Contributor Author

abmantis commented Aug 21, 2025

@YaLTeR looking at https://docs.pipewire.org/video-src_8c-example.html#a57 the example sets the stride/offset on every frame. Are you sure that is not required?
Also, I noticed that the chunk address changes on every frame, so how can it have the stride set only at start?

@abmantis
Copy link
Contributor Author

abmantis commented Aug 22, 2025

I'm logging the bitmap_data address and bitmap_data.add(MAX_CURSOR_BITMAP_SIZE as usize), and also the address on the spa_data chunk:
image

Notice that the address pairs pointed by the green (frame 1) and blue (frame 2) arrows match, which means that the bitmap_data is in the proper memory space since the data chunk comes right after.
Also notice that the address pointed by the red arrow (frame 2) is in the middle of the address range of bitmap_data of frame 1. That is why it gets a corrupted value when I write the bitmap vs. when I don't.

@YaLTeR
Copy link
Owner

YaLTeR commented Aug 22, 2025

From Matrix:

well on main there are only dmabufs, and for them stride and offset are data about the dmabuf itself, not about pipewire structures
since dmabufs are allocated once and then don't change, there's no need to change their stride and offset
(dmabuf is like a handle to GPU memory)
That said, at least Mutter sets them every frame, like niri before that commit. It's not impossible that pipewire itself has some issue where it automatically changes those values even for dmabufs and nobody has noticed so far. (This is just speculation)
The screencast codepaths there don't get a lot of various testing
Have you tried debugging with gdb and watching the memory location corresponding to the stride field and seeing what changes it?

I'm open to changing it back to set stride/offset every frame, but if it's indeed a bug in PW, it'd be good to get it found and fixed

@YaLTeR
Copy link
Owner

YaLTeR commented Aug 22, 2025

Non-dmabuf stride and offset do not fall under what I described above of course

@abmantis
Copy link
Contributor Author

abmantis commented Sep 7, 2025

Opened an issue on pipewire: https://gitlab.freedesktop.org/pipewire/pipewire/-/issues/4884

@YaLTeR
Copy link
Owner

YaLTeR commented Sep 8, 2025

Thanks, subscribed

@abmantis
Copy link
Contributor Author

I was able to confirm that the PR linked to that issue fixes the problem! 🥳
I can finally get back to implementing this.

@YaLTeR
Copy link
Owner

YaLTeR commented Sep 10, 2025

Awesome! I guess you should add a runtime check for pipewire version with the fix though.

);
}

let fd = (*(*spa_buffer).datas).fd;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

we should now be able to also optimize the screencast code to not render a new frame when there is no damage to it, and send only cursor metadata. But that appears to require some extra refactoring, so I suggest leaving it for a follow-up PR instead.

@abmantis abmantis marked this pull request as ready for review October 13, 2025 00:20
@abmantis abmantis requested a review from YaLTeR October 13, 2025 00:20
@YaLTeR YaLTeR added this to the next release milestone Oct 14, 2025
@ASong5
Copy link

ASong5 commented Nov 23, 2025

Is there more work that needs to be done on this for cursor data to be sent for screencasting? I have built with these changes locally but the cursor still does not appear in screencasts. Would love an update on this. Thanks.

@YaLTeR
Copy link
Owner

YaLTeR commented Nov 23, 2025

fwiw I haven't had a chance to look at this again yet; I'll try to before the next release if I find time. Testing is very welcome

@abmantis
Copy link
Contributor Author

Is there more work that needs to be done on this for cursor data to be sent for screencasting? I have built with these changes locally but the cursor still does not appear in screencasts. Would love an update on this. Thanks.

No, it should be done. What version of pipewire do you have installed?

@ASong5
Copy link

ASong5 commented Nov 24, 2025

Is there more work that needs to be done on this for cursor data to be sent for screencasting? I have built with these changes locally but the cursor still does not appear in screencasts. Would love an update on this. Thanks.

No, it should be done. What version of pipewire do you have installed?

I am on 1.2.7 which is what comes with Ubuntu 25.04. Will I need to build pipewire from source?

@abmantis
Copy link
Contributor Author

abmantis commented Nov 24, 2025

Is there more work that needs to be done on this for cursor data to be sent for screencasting? I have built with these changes locally but the cursor still does not appear in screencasts. Would love an update on this. Thanks.

No, it should be done. What version of pipewire do you have installed?

I am on 1.2.7 which is what comes with Ubuntu 25.04. Will I need to build pipewire from source?

Yeah, you need 1.2.8 at least. The previous versions had a buffer memory bug.
EDIT: meant 1.4.8.

@ASong5
Copy link

ASong5 commented Nov 24, 2025

Is there more work that needs to be done on this for cursor data to be sent for screencasting? I have built with these changes locally but the cursor still does not appear in screencasts. Would love an update on this. Thanks.

No, it should be done. What version of pipewire do you have installed?

I am on 1.2.7 which is what comes with Ubuntu 25.04. Will I need to build pipewire from source?

Yeah, you need 1.2.8 at least. The previous versions had a buffer memory bug.

Updated to pipewire 1.4.7 and the cursor still does not appear in screencasts. In the journal it says that WARN niri::pw_utils: cursor metadata mode requires PipeWire >= 1.4.8. I'm guessing you meant 1.4.8 not 1.2.8.

@ASong5
Copy link

ASong5 commented Nov 24, 2025

After compiling pipewire 1.5.8 from source, I get the following in journal:

WARN niri::pw_utils: error rendering cursor, using default bitmap

How do I further troubleshoot this? Have you tested on later version of pipewire or only 1.4.8?

@abmantis
Copy link
Contributor Author

After compiling pipewire 1.5.8 from source, I get the following in journal:

WARN niri::pw_utils: error rendering cursor, using default bitmap

How do I further troubleshoot this? Have you tested on later version of pipewire or only 1.4.8?

That log message is a bit misleading since there is no default bitmap. I've just updated.

Anyway, can you enable debug logs and see if something else pops up? I don't know why the rendering of the cursor elements is failing.

@ASong5
Copy link

ASong5 commented Nov 25, 2025

After compiling pipewire 1.5.8 from source, I get the following in journal:
WARN niri::pw_utils: error rendering cursor, using default bitmap
How do I further troubleshoot this? Have you tested on later version of pipewire or only 1.4.8?

That log message is a bit misleading since there is no default bitmap. I've just updated.

Anyway, can you enable debug logs and see if something else pops up? I don't know why the rendering of the cursor elements is failing.

Nov 24 22:13:29 pundrew-desktop niri[3200758]: 2025-11-25T03:13:29.065236Z ERROR niri::pw_utils: error rendering cursor
Nov 24 22:13:29 pundrew-desktop niri[3200758]: 2025-11-25T03:13:29.235871Z ERROR niri::pw_utils: error rendering cursor
Nov 24 22:13:29 pundrew-desktop niri[3200758]: 2025-11-25T03:13:29.732085Z ERROR niri::pw_utils: error rendering cursor
Nov 24 22:13:29 pundrew-desktop niri[3200758]: 2025-11-25T03:13:29.943374Z ERROR niri::pw_utils: error rendering cursor
Nov 24 22:13:39 pundrew-desktop niri[3200758]: 2025-11-25T03:13:39.099299Z DEBUG niri::pw_utils: pw stream: state changed: Streaming -> Paused stream_id=1
Nov 24 22:13:39 pundrew-desktop niri[3200758]: 2025-11-25T03:13:39.105405Z DEBUG niri::dbus::mutter_screen_cast: stop
Nov 24 22:13:39 pundrew-desktop niri[3200758]: 2025-11-25T03:13:39.105442Z DEBUG niri::niri: StopCast session_id=1
Nov 24 22:13:39 pundrew-desktop niri[3200758]: 2025-11-25T03:13:39.105472Z DEBUG niri::pw_utils: pw stream: state changed: Paused -> Unconnected stream_id=1
Nov 24 22:13:46 pundrew-desktop xdg-desktop-portal-gnome[3201079]: Failed to associate portal window with parent window 
Nov 24 22:13:46 pundrew-desktop xdg-desktop-portal-gnome[3201079]: vkAcquireNextImageKHR(): A swapchain no longer matches the surface properties exactly, but can still be used to present to the surface successfully. (VK_SUBOPTIMAL_KHR) (1000001003)
Nov 24 22:13:48 pundrew-desktop niri[3200758]: 2025-11-25T03:13:48.281916Z DEBUG niri::dbus::mutter_screen_cast: record_monitor connector="DP-1" properties=RecordMonitorProperties { cursor_mode: Some(Metadata), _is_recording: None }
Nov 24 22:13:48 pundrew-desktop niri[3200758]: 2025-11-25T03:13:48.282368Z DEBUG niri::dbus::mutter_screen_cast: start
Nov 24 22:13:48 pundrew-desktop niri[3200758]: 2025-11-25T03:13:48.282385Z DEBUG niri::niri: StartCast session_id=4 stream_id=4
Nov 24 22:13:48 pundrew-desktop niri[3200758]: 2025-11-25T03:13:48.282415Z DEBUG niri::pw_utils: pw stream: state changed: Unconnected -> Connecting stream_id=4
Nov 24 22:13:48 pundrew-desktop niri[3200758]: 2025-11-25T03:13:48.284338Z DEBUG niri::pw_utils: pw stream: state changed: Connecting -> Paused stream_id=4
Nov 24 22:13:48 pundrew-desktop niri[3200758]: 2025-11-25T03:13:48.284347Z DEBUG niri::pw_utils: pw stream: sending signal with 68 stream_id=4
Nov 24 22:13:48 pundrew-desktop niri[3200758]: 2025-11-25T03:13:48.319507Z DEBUG niri::pw_utils: pw stream: got format = VideoInfoRaw { format: VideoFormat::BGRx, flags: VideoFlags(0xc), modifier: 0, size: spa_rectangle { width: 2560, height: 1440 }, framerate: spa_fraction { num: 0, denom: 1 }, max_framerate: spa_fraction { num: 165080, denom: 1000 }, views: 0, interlace_mode: 0, pixel_aspect_ratio: spa_fraction { num: 0, denom: 0 }, multiview_mode: 0, multiview_flags: 0, chroma_site: 0, color_range: 0, color_matrix: 0, transfer_function: 0, color_primaries: 0 } stream_id=4
Nov 24 22:13:48 pundrew-desktop niri[3200758]: 2025-11-25T03:13:48.319521Z DEBUG niri::pw_utils: pw stream: fixating the modifier stream_id=4
Nov 24 22:13:48 pundrew-desktop niri[3200758]: 2025-11-25T03:13:48.319527Z DEBUG niri::pw_utils: find_preferred_modifier: size=Size<smithay::utils::geometry::Physical> { w: 2560, h: 1440 }, fourcc=XR24, modifiers=[144115188621556484, 144115188621556484, 144115188621556484, 144115188621556484, 144115188621540100, 144115188621343492, 144115188621122308, 144115188621557508, 144115188621541124, 144115188621344516, 144115188621123332, 144115188075858436, 0, 72057594037927935]
Nov 24 22:13:48 pundrew-desktop niri[3200758]: 2025-11-25T03:13:48.319735Z DEBUG niri::pw_utils: pw stream: allocation successful (modifier=Unrecognized(144115188621556484), plane_count=2), moving to confirmation pending stream_id=4
Nov 24 22:13:48 pundrew-desktop niri[3200758]: 2025-11-25T03:13:48.320575Z DEBUG niri::pw_utils: pw stream: got format = VideoInfoRaw { format: VideoFormat::BGRx, flags: VideoFlags(0x4), modifier: 144115188621556484, size: spa_rectangle { width: 2560, height: 1440 }, framerate: spa_fraction { num: 0, denom: 1 }, max_framerate: spa_fraction { num: 165080, denom: 1000 }, views: 0, interlace_mode: 0, pixel_aspect_ratio: spa_fraction { num: 0, denom: 0 }, multiview_mode: 0, multiview_flags: 0, chroma_site: 0, color_range: 0, color_matrix: 0, transfer_function: 0, color_primaries: 0 } stream_id=4
Nov 24 22:13:48 pundrew-desktop niri[3200758]: 2025-11-25T03:13:48.320584Z DEBUG niri::pw_utils: pw stream: moving to ready state stream_id=4
Nov 24 22:13:48 pundrew-desktop niri[3200758]: 2025-11-25T03:13:48.323409Z DEBUG niri::pw_utils: pw stream: state changed: Paused -> Streaming stream_id=4
Nov 24 22:13:55 pundrew-desktop niri[3200758]: 2025-11-25T03:13:55.182715Z ERROR niri::pw_utils: error rendering cursor
Nov 24 22:13:55 pundrew-desktop niri[3200758]: 2025-11-25T03:13:55.184213Z ERROR niri::pw_utils: error rendering cursor

I don't know if these logs help but it's all I get in journal which is still flooded with these "error rendering cursor" messages.

@ASong5
Copy link

ASong5 commented Nov 27, 2025

Along with the cursor issue, niri crashed completely when I started a screencast:

v 27 12:08:21 pundrew-desktop waybar[3516842]: Error reading events from display: Connection reset by peer
Nov 27 12:08:21 pundrew-desktop xdg-desktop-portal-gtk[3517570]: Error reading events from display: Broken pipe
Nov 27 12:08:21 pundrew-desktop easyeffects[3517200]: Lost connection to Wayland compositor.
Nov 27 12:08:21 pundrew-desktop org.gnome.Nautilus[581213]: Lost connection to Wayland compositor.
Nov 27 12:08:21 pundrew-desktop niri[3516722]: 2025-11-27T17:08:21.132051Z DEBUG niri::utils::watcher: exiting watcher thread for Regular { user_path: "/home/pundrew/.config/niri/config.kdl", system_path: "/etc/niri/config.kdl" }
Nov 27 12:08:20 pundrew-desktop niri[3516722]: 2025-11-27T17:08:20.741268Z DEBUG niri::pw_utils: pw stream: state changed: Paused -> Unconnected stream_id=5
Nov 27 12:08:20 pundrew-desktop niri[3516722]: 2025-11-27T17:08:20.741164Z DEBUG niri::pw_utils: pw stream: state changed: Streaming -> Paused stream_id=5
Nov 27 12:08:20 pundrew-desktop niri[3516722]: 2025-11-27T17:08:20.741060Z DEBUG niri::pw_utils: pw stream: state changed: Paused -> Unconnected stream_id=4
Nov 27 12:08:20 pundrew-desktop niri[3516722]: 2025-11-27T17:08:20.741012Z DEBUG niri::pw_utils: pw stream: state changed: Streaming -> Paused stream_id=4
Nov 27 12:08:20 pundrew-desktop niri[3516722]: 2025-11-27T17:08:20.740910Z DEBUG niri::pw_utils: pw stream: state changed: Paused -> Unconnected stream_id=2
Nov 27 12:08:20 pundrew-desktop niri[3516722]: 2025-11-27T17:08:20.740797Z DEBUG niri::pw_utils: pw stream: state changed: Streaming -> Paused stream_id=2
Nov 27 12:08:20 pundrew-desktop niri[3516722]: 2025-11-27T17:08:20.740690Z DEBUG niri::pw_utils: pw stream: state changed: Paused -> Unconnected stream_id=1
Nov 27 12:08:20 pundrew-desktop niri[3516722]: 2025-11-27T17:08:20.739668Z DEBUG niri::pw_utils: pw stream: state changed: Paused -> Unconnected stream_id=0
Nov 27 12:08:20 pundrew-desktop niri[3516722]: 2025-11-27T17:08:20.739275Z DEBUG niri::pw_utils: pw stream: state changed: Streaming -> Paused stream_id=0
Nov 27 12:08:20 pundrew-desktop niri[3516722]: note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
Nov 27 12:08:20 pundrew-desktop niri[3516722]:              at /rustc/595b9a498bc55fcd30111e430d8e4290ed833b4c/library/core/src/ops/function.rs:250:5
Nov 27 12:08:20 pundrew-desktop niri[3516722]:   15: call_once<fn() -> core::result::Result<(), alloc::boxed::Box<dyn core::error::Error, alloc::alloc::Global>>, ()>
Nov 27 12:08:20 pundrew-desktop niri[3516722]:              at ./git/niri/src/main.rs:265:10
Nov 27 12:08:20 pundrew-desktop niri[3516722]:   14: main
Nov 27 12:08:20 pundrew-desktop niri[3516722]:              at ./.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/calloop-0.14.3/src/loop_logic.rs:670:13
Nov 27 12:08:20 pundrew-desktop niri[3516722]:   13: run<niri::niri::State, niri::main::{closure_env#3}, core::option::Option<core::time::Duration>>
Nov 27 12:08:20 pundrew-desktop niri[3516722]:              at ./git/niri/src/main.rs:265:46
Nov 27 12:08:20 pundrew-desktop niri[3516722]:   12: {closure#3}
Nov 27 12:08:20 pundrew-desktop niri[3516722]:              at ./git/niri/src/niri.rs:715:19
Nov 27 12:08:20 pundrew-desktop niri[3516722]:   11: refresh_and_flush_clients
Nov 27 12:08:20 pundrew-desktop niri[3516722]:              at ./git/niri/src/niri.rs:3816:18
Nov 27 12:08:20 pundrew-desktop niri[3516722]:   10: redraw_queued_outputs
Nov 27 12:08:20 pundrew-desktop niri[3516722]:              at ./git/niri/src/niri.rs:4635:17
Nov 27 12:08:20 pundrew-desktop niri[3516722]:    9: redraw
Nov 27 12:08:20 pundrew-desktop niri[3516722]:              at ./git/niri/src/backend/mod.rs:79:38
Nov 27 12:08:20 pundrew-desktop niri[3516722]:    8: with_primary_renderer<(), niri::niri::{impl#5}::redraw::{closure_env#3}>
Nov 27 12:08:20 pundrew-desktop niri[3516722]:              at ./git/niri/src/backend/tty.rs:1462:14
Nov 27 12:08:20 pundrew-desktop niri[3516722]:    7: with_primary_renderer<(), niri::niri::{impl#5}::redraw::{closure_env#3}>
Nov 27 12:08:20 pundrew-desktop niri[3516722]:              at ./git/niri/src/niri.rs:4645:22
Nov 27 12:08:20 pundrew-desktop niri[3516722]:    6: {closure#3}
Nov 27 12:08:20 pundrew-desktop niri[3516722]:              at ./git/niri/src/niri.rs:5325:26
Nov 27 12:08:20 pundrew-desktop niri[3516722]:    5: render_windows_for_screen_cast
Nov 27 12:08:20 pundrew-desktop niri[3516722]:    4: get_window_pointer_location
Nov 27 12:08:20 pundrew-desktop niri[3516722]:              at /rustc/595b9a498bc55fcd30111e430d8e4290ed833b4c/library/core/src/option.rs:2169:5
Nov 27 12:08:20 pundrew-desktop niri[3516722]:    3: core::option::unwrap_failed
Nov 27 12:08:20 pundrew-desktop niri[3516722]:              at /rustc/595b9a498bc55fcd30111e430d8e4290ed833b4c/library/core/src/panicking.rs:148:5
Nov 27 12:08:20 pundrew-desktop niri[3516722]:    2: core::panicking::panic
Nov 27 12:08:20 pundrew-desktop niri[3516722]:              at /rustc/595b9a498bc55fcd30111e430d8e4290ed833b4c/library/core/src/panicking.rs:78:14
Nov 27 12:08:20 pundrew-desktop niri[3516722]:    1: core::panicking::panic_fmt
Nov 27 12:08:20 pundrew-desktop niri[3516722]:              at /rustc/595b9a498bc55fcd30111e430d8e4290ed833b4c/library/std/src/panicking.rs:698:5
Nov 27 12:08:20 pundrew-desktop niri[3516722]:    0: __rustc::rust_begin_unwind
Nov 27 12:08:20 pundrew-desktop niri[3516722]: stack backtrace:
Nov 27 12:08:20 pundrew-desktop niri[3516722]: called `Option::unwrap()` on a `None` value
Nov 27 12:08:20 pundrew-desktop niri[3516722]: thread 'main' (3516722) panicked at src/niri.rs:5228:14:

Will update when I have reproduced it with verbose logs. I never experienced this prior to building with these changes.

@ASong5
Copy link

ASong5 commented Nov 27, 2025

Was able to reproduce consistently by starting a screencast and then dragging the screencasted window via Mod+MB1. @abmantis are you able to reproduce this on your system?

@abmantis
Copy link
Contributor Author

abmantis commented Nov 30, 2025

Was able to reproduce consistently by starting a screencast and then dragging the screencasted window via Mod+MB1. @abmantis are you able to reproduce this on your system?

I've just tried that and cannot reproduce the crash. But I'll look at the unwraps and see if I can make them safer.

@abmantis
Copy link
Contributor Author

abmantis commented Dec 2, 2025

@ASong5 can you try again and check the logs? The error rendering cursor message should now log the error to.
Also the crashes when dragging should now be fixed. 🤞 Can you test that out too since I was not able to reproduce it?

@ASong5
Copy link

ASong5 commented Dec 2, 2025

I just tested and the crashes are gone! However, cursor data is still not being sent properly for me:

pundrew@pundrew-desktop:~$ journalctl -r -b -0
Dec 01 21:30:25 pundrew-desktop niri[952124]:     1: Failed to bind Framebuffer
Dec 01 21:30:25 pundrew-desktop niri[952124]:     0: error binding texture
Dec 01 21:30:25 pundrew-desktop niri[952124]: Caused by:
Dec 01 21:30:25 pundrew-desktop niri[952124]: 2025-12-02T02:30:25.197522Z ERROR niri::pw_utils: error rendering cursor: error rendering
Dec 01 21:30:25 pundrew-desktop niri[952124]:     1: Failed to bind Framebuffer
Dec 01 21:30:25 pundrew-desktop niri[952124]:     0: error binding texture
Dec 01 21:30:25 pundrew-desktop niri[952124]: Caused by:
Dec 01 21:30:25 pundrew-desktop niri[952124]: 2025-12-02T02:30:25.008598Z ERROR niri::pw_utils: error rendering cursor: error rendering
Dec 01 21:30:24 pundrew-desktop niri[952124]:     1: Failed to bind Framebuffer
Dec 01 21:30:24 pundrew-desktop niri[952124]:     0: error binding texture
Dec 01 21:30:24 pundrew-desktop niri[952124]: Caused by:
Dec 01 21:30:24 pundrew-desktop niri[952124]: 2025-12-02T02:30:24.873792Z ERROR niri::pw_utils: error rendering cursor: error rendering
Dec 01 21:30:24 pundrew-desktop niri[952124]:     1: Failed to bind Framebuffer
Dec 01 21:30:24 pundrew-desktop niri[952124]:     0: error binding texture
Dec 01 21:30:24 pundrew-desktop niri[952124]: Caused by:
Dec 01 21:30:24 pundrew-desktop niri[952124]: 2025-12-02T02:30:24.737332Z ERROR niri::pw_utils: error rendering cursor: error rendering
Dec 01 21:30:24 pundrew-desktop niri[952124]:     1: Failed to bind Framebuffer
Dec 01 21:30:24 pundrew-desktop niri[952124]:     0: error binding texture
Dec 01 21:30:24 pundrew-desktop niri[952124]: Caused by:
Dec 01 21:30:24 pundrew-desktop niri[952124]: 2025-12-02T02:30:24.580520Z ERROR niri::pw_utils: error rendering cursor: error rendering
Dec 01 21:30:24 pundrew-desktop niri[952124]:     1: Failed to bind Framebuffer
Dec 01 21:30:24 pundrew-desktop niri[952124]:     0: error binding texture
Dec 01 21:30:24 pundrew-desktop niri[952124]: Caused by:
Dec 01 21:30:24 pundrew-desktop niri[952124]: 2025-12-02T02:30:24.238514Z ERROR niri::pw_utils: error rendering cursor: error rendering
Dec 01 21:30:24 pundrew-desktop niri[952124]:     1: Failed to bind Framebuffer
Dec 01 21:30:24 pundrew-desktop niri[952124]:     0: error binding texture

#511 is the most related issue I can find, but it seems to be fixed already and mainly affected nvidia cards whereas I use amd:

pundrew@pundrew-desktop:~$ glxinfo | grep "OpenGL renderer"
OpenGL renderer string: AMD Radeon RX 7800 XT (radeonsi, navi32, LLVM 20.1.8, DRM 3.64, 6.17.0-6-generic)

I'm not sure if you had a chance to test with newer versions of pipewire than 1.4.8 but I will downgrade to 1.4.8 and report back in case it is an issue with newer versions of pipewire.

@abmantis
Copy link
Contributor Author

abmantis commented Dec 2, 2025

I've just tested it with pipewire 1.4.9 since that is now available on NixOS.
Regarding the error, I'll try to look a bit into it. How are you running niri?

@ASong5
Copy link

ASong5 commented Dec 2, 2025

Tested with pipewire version 1.4.8 and the issue persists.

I'm running niri via SDDM

@busyoGG
Copy link

busyoGG commented Dec 6, 2025

Same here. It also breaks the original cursor capture function.

The error occurred at let pointer_vec = match render_to_vec

edited:

I found that pointer_elements.len() is 0 when starting screencast if you didn't move the cursor, which is why it reports an error.

But it's not the reason why the cursor disappears.

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.

Send cursor in screencast metadata

4 participants