wluma: Crash with AMD GPU
Hey,
I wanted to try wluma with ddcutil support on my desktop but it crashes immediately (I tried both amdvlk and vulkan-radeon since it seems to be a vulkan issue). On my notebook with an integrated Intel GPU it runs fine, unless I connect my external display, then it fails here: https://github.com/maximbaz/wluma/blob/4538b692274d27780ce1ac832a6b2156cb066810/src/predictor/controller.rs#L69 ddcutil by itself works completely fine as the same user that runs wluma:
ddcutil --mfg GSM getvcp 10
VCP code 0x10 (Brightness ): current value = 85, max value = 100
I appended my config and the backtrace.
config
[frame]
processor = "vulkan"
capturer = "wlroots"
[als.time]
thresholds = { 0 = "night", 7 = "dark", 9 = "dim", 11 = "normal", 13 = "bright", 16 = "normal", 18 = "dark", 20 = "night" }
[[output.ddcutil]]
name = "LG HDR 4K"
backtrace
Continue adjusting brightness and wluma will learn your preference over time.
thread ‘predictor-LG HDR 4K’ panicked at ‘Unable to compute luma percent: ERROR_MEMORY_MAP_FAILED’, src/frame/capturer/wlroots.rs:124:26
stack backtrace:
0: rust_begin_unwind
at /rustc/1.58.0/library/std/src/panicking.rs:498:5
1: core::panicking::panic_fmt
at /rustc/1.58.0/library/core/src/panicking.rs:107:14
2: core::result::unwrap_failed
at /rustc/1.58.0/library/core/src/result.rs:1613:5
3: core::result::Result<T,E>::expect
at /rustc/1.58.0/library/core/src/result.rs:1255:23
4: wluma::frame::capturer::wlroots::Capturer::capture_frame::{{closure}}
at ./src/frame/capturer/wlroots.rs:121:32
5: wayland_client::proxy::Main::quick_assign::{{closure}}
at /home/xenrox/.local/state/cargo/registry/src/github.com-1ecc6299db9ec823/wayland-client-0.29.4/src/proxy.rs:273:64
6: wayland_commons::filter::Filter<E>::send
at /home/xenrox/.local/state/cargo/registry/src/github.com-1ecc6299db9ec823/wayland-commons-0.29.4/src/filter.rs💯13
7: wayland_client:👿:make_dispatcher::{{closure}}
at /home/xenrox/.local/state/cargo/registry/src/github.com-1ecc6299db9ec823/wayland-client-0.29.4/src/rust_imp/mod.rs:194:49
8: <wayland_client:👿:ImplDispatcher<I,F> as wayland_client:👿:Dispatcher>::dispatch
at /home/xenrox/.local/state/cargo/registry/src/github.com-1ecc6299db9ec823/wayland-client-0.29.4/src/rust_imp/mod.rs:179:9
9: wayland_client:👿:queues::EventQueueInner::dispatch_buffer
at /home/xenrox/.local/state/cargo/registry/src/github.com-1ecc6299db9ec823/wayland-client-0.29.4/src/rust_imp/queues.rs:163:23
10: wayland_client:👿:queues::EventQueueInner::dispatch_pending
at /home/xenrox/.local/state/cargo/registry/src/github.com-1ecc6299db9ec823/wayland-client-0.29.4/src/rust_imp/queues.rs:198:31
11: wayland_client:👿:queues::EventQueueInner::dispatch
at /home/xenrox/.local/state/cargo/registry/src/github.com-1ecc6299db9ec823/wayland-client-0.29.4/src/rust_imp/queues.rs:102:28
12: wayland_client::event_queue::EventQueue::dispatch
at /home/xenrox/.local/state/cargo/registry/src/github.com-1ecc6299db9ec823/wayland-client-0.29.4/src/event_queue.rs:152:9
13: <wluma::frame::capturer::wlroots::Capturer as wluma::frame::capturer::Capturer>::run
at ./src/frame/capturer/wlroots.rs:60:13
14: wluma::main::{{closure}}::{{closure}}
at ./src/main.rs:99:21
note: Some details are omitted, run with RUST_BACKTRACE=full
for a verbose backtrace.
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 24 (13 by maintainers)
Commits related to this issue
- increase initial timeout See https://github.com/maximbaz/wluma/issues/27#issuecomment-1014897178 — committed to maximbaz/wluma by maximbaz 2 years ago
Yes it seems like I am all out of bugs. Thanks a lot for your help @maximbaz , @cyrinux!
Perfect, at least we will not be walking in the dark, but we have precise description of what to fix, with helpful links 😁
Will share some hints in case you want to try to play around, if not - no big deal, we will get to this eventually 😉
It crashes on mapping the memory here:
https://github.com/maximbaz/wluma/blob/a57c4f7bb7997d6bc58efaf73a99f00d5fe24212/src/frame/processor/vulkan.rs#L66
It tried to map the memory to the following allocated buffer:
https://github.com/maximbaz/wluma/blob/a57c4f7bb7997d6bc58efaf73a99f00d5fe24212/src/frame/processor/vulkan.rs#L165
Which was allocated in some memory that fits these requirements:
https://github.com/maximbaz/wluma/blob/a57c4f7bb7997d6bc58efaf73a99f00d5fe24212/src/frame/processor/vulkan.rs#L159
Specifically, I’m nearly positive that the bug is here:
https://github.com/maximbaz/wluma/blob/a57c4f7bb7997d6bc58efaf73a99f00d5fe24212/src/frame/processor/vulkan.rs#L161
Instead of picking the index of the right memory, we just pass
0
, which on our laptop is the only available memory, so the choice is always right 😁The fix could be as simple as trying to hardcode there
1
and seeing if it works, but I dont know if indices are actually incremental - but for sure there is an API call where we can get the right index for the memory that reportsVK_MEMORY_PROPERTY_HOST_VISIBLE_BIT
(as per the error message), and then pass the right index there.If you do look into it, please keep us posted how it goes!
Yes, I am on Arch.
Yes 5 is enough, it only failed one or two times with 4.
With https://github.com/maximbaz/wluma/commit/40445411c04abd812eb7cbb231d256d59f4bf953 the missing serial number should be fixed, together with having more debug logging to identify why displays are not being matched. Untested by hopefully will work 😛
DDC/I2C errors like the above is something @cyrinux experienced as well (I dont use external monitors so we’ve been testing on his setup), we concluded that it’s just transient errors that we can’t do anything about - although for him the errors only happened if he was messing with screen using
ddcutil
cli in parallel. So for you the errors occur even just by running wluma and nothing else?To clarify, as long as the errors are transient, the app should just work, we log and ignore those errors.
Let me summarize to see if I remember it all correctly, the state with the latest
main
code:capturer=none
now workscapturer=wlroots
now works with both only internal screen and with external display plugged in.Everything correct?
Made some progress: One problem is, that my display has no serial. Because of that serial is not Some but None and the iteration does not even reach the display I actually want to select here: https://github.com/maximbaz/wluma/blob/4538b692274d27780ce1ac832a6b2156cb066810/src/brightness/ddcutil.rs#L60 After fixing that (substituted serial_number with model_id) it can actually match my display (no more warning) but still fails at getting the intial brightness
@maximbaz Sure I would love to help with debugging the vulkan crash.
I have applied https://github.com/maximbaz/wluma/pull/28 and here is the new output if that helps:
config
Edit: This is with capturer none.