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

Workrave Wayland support (meta) #523

Open
ValdikSS opened this issue Jan 16, 2024 · 14 comments
Open

Workrave Wayland support (meta) #523

ValdikSS opened this issue Jan 16, 2024 · 14 comments
Labels
env: wayland Wayland specific improvement Improvement of an existing feature

Comments

@ValdikSS
Copy link
Contributor

Describe the bug

Right now Workrave 1.10.52 has limited support for different Linux Wayland DEs/compositors other than Gnome's Mutter:

  1. Crash on start with segmentation fault unless started with environment variable: zsh: segmentation fault (core dumped) /usr/bin/workrave #522, Workrave fails to track keyboard and mouse activity in Gnome Shell on Wayland #212, Crash on startup under Wayland #302
  2. Inability to monitor for keyboard/mouse activity on non-Gnome (non-Mutter) compositors: no implementation for kde-idle or idle-notify Wayland protocols
  3. Incorrect position of nag bar and rest break window: seem fixed for Mutter in Non-blocking pop-up never appears centered or remembers where it was #163, still the issue for KDE Kwin.
@rcaelers
Copy link
Owner

I fixed the crash, and have just implemented monitoring using the idle-notify protocol. Current checking that this did not break anything.
This will appear in the next 1.11 beta release. If stable, I will try to backport it to 1.10. I haven't checked the incorrect position yet.

@ValdikSS
Copy link
Contributor Author

Current fix for segmentation fault on start:

  • Run as GDK_BACKEND="x11" workrave
  • Add GDK_BACKEND="x11" environment variable to the Workrave .desktop shortcut

Screenshot_20240116_224256-fs8

@ValdikSS
Copy link
Contributor Author

I fixed the crash, and have just implemented monitoring using the idle-notify protocol. Current checking that this did not break anything.

Thanks, I saw it several hours ago in main, and now I see Idle which you've pushed 30 minutes ago :D

Here's my hack written in Python, which uses Workrave DBus interface to update the activity for now.

workrave_wayland_idle_kick.tar.gz

@rcaelers rcaelers added env: wayland Wayland specific improvement Improvement of an existing feature labels Feb 11, 2024
@gringus
Copy link

gringus commented Feb 25, 2024

Would it be possible to make Wayland support configurable (eg. -DWITH_WAYLAND=OFF)? Currently, it's not possible to build it without Wayland (on a non-Wayland system).

@wolftune
Copy link

wolftune commented Mar 4, 2024

got bit by this tonight, KDE Neon moved to KDE 6 and Wayland, workrave stopped working right, and even with environment, it thinks I'm inactive when I'm actually active.

I think it needs to use kde-idle or something

@jjramsey
Copy link
Contributor

jjramsey commented Apr 3, 2024

I've tried out the latest Workrave (1.11.0_beta.12.0.g7cab420-1) on two different wlroots-based compositors, LabWC and Sway, and got the same results both times: a segfault that, if it leaves behind a $HOME/.cache/workrave/workrave.log file, leaves behind an empty one. My wlroots version is 0.17.2.

On GNOME 46, Workrave works fine so far. I've unchecked the "Force use of X11 on Wayland" option.

ETA: Here's a backtrace from GDB:

0  UnixInputMonitorFactory::create_monitor (this=0x5555557dc740, capability=<optimized out>) at /usr/include/c++/13.2.1/bits/shared_ptr_base.h:1665
#1  0x000055555567871e in workrave::input_monitor::InputMonitorFactory::create_monitor (capability=workrave::input_monitor::MonitorCapability::Activity)
    at /usr/src/debug/workrave-git/workrave/libs/input-monitor/src/InputMonitorFactory.cc:61
#2  LocalActivityMonitor::LocalActivityMonitor (this=0x55555582c5b0) at /usr/src/debug/workrave-git/workrave/libs/core/src/LocalActivityMonitor.cc:42
#3  std::_Construct<LocalActivityMonitor> (__p=0x55555582c5b0) at /usr/include/c++/13.2.1/bits/stl_construct.h:119
#4  std::allocator_traits<std::allocator<void> >::construct<LocalActivityMonitor> (__p=0x55555582c5b0) at /usr/include/c++/13.2.1/bits/alloc_traits.h:660
#5  std::_Sp_counted_ptr_inplace<LocalActivityMonitor, std::allocator<void>, (__gnu_cxx::_Lock_policy)2>::_Sp_counted_ptr_inplace<>(std::allocator<void>) (__a=..., this=0x55555582c5a0)
    at /usr/include/c++/13.2.1/bits/shared_ptr_base.h:604
#6  std::__shared_count<(__gnu_cxx::_Lock_policy)2>::__shared_count<LocalActivityMonitor, std::allocator<void>>(LocalActivityMonitor*&, std::_Sp_alloc_shared_tag<std::allocator<void> >)
    (__a=..., __p=<optimized out>, this=<optimized out>) at /usr/include/c++/13.2.1/bits/shared_ptr_base.h:971
#7  std::__shared_ptr<LocalActivityMonitor, (__gnu_cxx::_Lock_policy)2>::__shared_ptr<std::allocator<void>>(std::_Sp_alloc_shared_tag<std::allocator<void> >) (__tag=..., this=<optimized out>)
    at /usr/include/c++/13.2.1/bits/shared_ptr_base.h:1712
#8  std::shared_ptr<LocalActivityMonitor>::shared_ptr<std::allocator<void>>(std::_Sp_alloc_shared_tag<std::allocator<void> >) (__tag=..., this=<optimized out>) at /usr/include/c++/13.2.1/bits/shared_ptr.h:464
#9  std::make_shared<LocalActivityMonitor> () at /usr/include/c++/13.2.1/bits/shared_ptr.h:1010
#10 Core::init_monitor (this=0x555555836dd0, display_name=<optimized out>) at /usr/src/debug/workrave-git/workrave/libs/core/src/Core.cc:184
#11 0x000055555567a09a in Core::init (this=this@entry=0x555555836dd0, argc=<optimized out>, argv=<optimized out>, app=app@entry=0x5555557a2540, display_name=0x7fffffffedd4 "wayland-0")
    at /usr/src/debug/workrave-git/workrave/libs/core/src/Core.cc:136
#12 0x00005555555eb69c in Application::init_core (this=0x5555557a2540) at /usr/src/debug/workrave-git/workrave/ui/app/Application.cc:261
#13 0x00005555555ddc18 in Application::main (this=this@entry=0x5555557a2540) at /usr/src/debug/workrave-git/workrave/ui/app/Application.cc:97
#14 0x00005555555e038f in run (argv=<optimized out>, argc=1) at /usr/src/debug/workrave-git/workrave/ui/app/main.cc:118
#15 main (argc=1, argv=<optimized out>) at /usr/src/debug/workrave-git/workrave/ui/app/main.cc:128

@jjramsey
Copy link
Contributor

jjramsey commented Apr 4, 2024

I recompiled Workrave with CMAKE_BUILD_TYPE set to debug and tested it in a labwc session again. Here's what I got:

gdb /usr/bin/workrave 
GNU gdb (GDB) 14.2
Copyright (C) 2023 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-pc-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from /usr/bin/workrave...
Reading symbols from /usr/lib/debug/usr/bin/workrave.debug...
(gdb) r
Starting program: /usr/bin/workrave 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/usr/lib/libthread_db.so.1".
[2024-04-04 16:50:30.776] [workrave] [info ] Workrave started
[2024-04-04 16:50:30.776] [workrave] [info ] Log file: /home/jjramsey/.cache/workrave/workrave.log
[New Thread 0x7ffff25ff6c0 (LWP 12221)]
[New Thread 0x7ffff1dfe6c0 (LWP 12222)]
[New Thread 0x7ffff15fd6c0 (LWP 12223)]
[New Thread 0x7ffff0dfc6c0 (LWP 12224)]
[New Thread 0x7fffe3fff6c0 (LWP 12225)]

Thread 1 "workrave" received signal SIGSEGV, Segmentation fault.
0x0000555555820a71 in UnixInputMonitorFactory::create_monitor (this=0x555555ac1140, 
    capability=workrave::input_monitor::MonitorCapability::Activity)
    at /usr/src/debug/workrave-git/workrave/libs/input-monitor/src/unix/UnixInputMonitorFactory.cc:124
124	          initialized = monitor->init();
(gdb) bt
#0  0x0000555555820a71 in UnixInputMonitorFactory::create_monitor
    (this=0x555555ac1140, capability=workrave::input_monitor::MonitorCapability::Activity)
    at /usr/src/debug/workrave-git/workrave/libs/input-monitor/src/unix/UnixInputMonitorFactory.cc:124
#1  0x0000555555820418 in workrave::input_monitor::InputMonitorFactory::create_monitor
    (capability=workrave::input_monitor::MonitorCapability::Activity)
    at /usr/src/debug/workrave-git/workrave/libs/input-monitor/src/InputMonitorFactory.cc:61
#2  0x0000555555618f7a in LocalActivityMonitor::LocalActivityMonitor (this=0x555555adfa30, this=<optimized out>)
    at /usr/src/debug/workrave-git/workrave/libs/core/src/LocalActivityMonitor.cc:42
#3  0x0000555555799fd0 in std::_Construct<LocalActivityMonitor> (__p=0x555555adfa30)
    at /usr/include/c++/13.2.1/bits/stl_construct.h:119
#4  0x0000555555611cb1 in std::allocator_traits<std::allocator<void> >::construct<LocalActivityMonitor> (__p=0x555555adfa30)
    at /usr/include/c++/13.2.1/bits/alloc_traits.h:660
#5  std::_Sp_counted_ptr_inplace<LocalActivityMonitor, std::allocator<void>, (__gnu_cxx::_Lock_policy)2>::_Sp_counted_ptr_inplace<>(std::allocator<void>) (this=0x555555adfa20, __a=..., this=<optimized out>, __a=...)
    at /usr/include/c++/13.2.1/bits/shared_ptr_base.h:604
#6  0x00005555556116eb in std::__shared_count<(__gnu_cxx::_Lock_policy)2>::__shared_count<LocalActivityMonitor, std::allocator<void>>(LocalActivityMonitor*&, std::_Sp_alloc_shared_tag<std::allocator<void> >)
    (this=0x7fffffffe668, __p=@0x7fffffffe660: 0x0, __a=..., this=<optimized out>, __p=<optimized out>, __a=...)
    at /usr/include/c++/13.2.1/bits/shared_ptr_base.h:971
#7  0x0000555555793b8a in std::__shared_ptr<LocalActivityMonitor, (__gnu_cxx::_Lock_policy)2>::__shared_ptr<std::allocator<void>>(std::_Sp_alloc_shared_tag<std::allocator<void> >) (this=0x7fffffffe660, __tag=..., this=<optimized out>, __tag=...)
    at /usr/include/c++/13.2.1/bits/shared_ptr_base.h:1712
#8  0x0000555555610613 in std::shared_ptr<LocalActivityMonitor>::shared_ptr<std::allocator<void>>(std::_Sp_alloc_shared_tag<std::allocator<void> >) (this=0x7fffffffe660, __tag=..., this=<optimized out>, __tag=...)
    at /usr/include/c++/13.2.1/bits/shared_ptr.h:464
#9  0x0000555555790020 in std::make_shared<LocalActivityMonitor> () at /usr/include/c++/13.2.1/bits/shared_ptr.h:1010
#10 0x000055555578c120 in Core::init_monitor (this=0x555555ac17a0, display_name=0x7fffffffedd3 "wayland-0")
    at /usr/src/debug/workrave-git/workrave/libs/core/src/Core.cc:184
#11 0x000055555578bc6e in Core::init
--Type <RET> for more, q to quit, c to continue without paging--
    (this=0x555555ac17a0, argc=1, argv=0x7fffffffe958, app=0x555555a30540, display_name=0x7fffffffedd3 "wayland-0")
    at /usr/src/debug/workrave-git/workrave/libs/core/src/Core.cc:136
#12 0x0000555555640d05 in Application::init_core (this=0x555555a30540) at /usr/src/debug/workrave-git/workrave/ui/app/Application.cc:261
#13 0x000055555563fe05 in Application::main (this=0x555555a30540) at /usr/src/debug/workrave-git/workrave/ui/app/Application.cc:97
#14 0x000055555563839b in run (argc=1, argv=0x7fffffffe958) at /usr/src/debug/workrave-git/workrave/ui/app/main.cc:118
#15 0x0000555555638461 in main (argc=1, argv=0x7fffffffe958) at /usr/src/debug/workrave-git/workrave/ui/app/main.cc:128
(gdb) q
A debugging session is active.

	Inferior 1 [process 12218] will be killed.

Quit anyway? (y or n) y

@jjramsey
Copy link
Contributor

jjramsey commented Apr 4, 2024

I think I figured out the problem. Even though the CMake variable HAVE_MONITORS includes "wayland" as one of the monitors, Wayland support isn't fully built unless -DHAVE_WAYLAND:BOOL=TRUE is set when CMake is configuring the build.

I'm not sure, but I think what is happening is that in UnixInputMonitorFactory.cc, monitor_method is set to "wayland", but since HAVE_WAYLAND is undefined, the else if (monitor_method == "wayland") block is never executed, so the monitor variable is still nullptr when line 124, initialized = monitor->init();, is executed, hence the segfault.

@ValdikSS
Copy link
Contributor Author

ValdikSS commented Apr 24, 2024

I can confirm the issue @jjramsey described (and the fix proposed). Additionally, on KDE I don't see the applet anymore. "Show fallback applet" works, but only when X11 session is forced.

The window still works, but no applet. The application overall works as well.

@wolftune
Copy link

@ValdikSS try the updated applet as described at wojnilowicz/workrave-applet#12 (comment)

And if you have it working, maybe post at that issue to encourage the applet developer to formalize release of the KDE6 support

@patch-work
Copy link

Everything works on Fedora Linux 40, except timers and sound.
##543

@jjramsey
Copy link
Contributor

Wayland not working under LabWC and Sway compositors: #550

@andreas-hartmann
Copy link

I'm still getting a segfault when using the version from the PPA on Plasma 6 Wayland unless I use GDK_BACKEND="x11" . Is all that's needed a new release on the PPA?

@ValdikSS
Copy link
Contributor Author

ValdikSS commented Oct 4, 2024

@rcaelers current git master:

  1. Always forces X11 mode for some reason ([workrave] [info ] Forcing X11 backend), thus activity detection doesn't work
  2. Has seemingly broken dconf (settings are not saved, default settings for sound paths are not loaded

beta 13 used to work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
env: wayland Wayland specific improvement Improvement of an existing feature
Projects
None yet
Development

No branches or pull requests

7 participants