Lazarus
Programming => General => Topic started by: gsnak on August 13, 2020, 09:10:12 pm
-
I've recently installed Ubuntu 20.04 64bit and I've encountered problem that every GTK2 app started 25s. I reported it on launchpad (https://bugs.launchpad.net/ubuntu/+bug/1891245) and eventually was able to resolve it by installing appmenu-gtk2-module, restarting and then running /usr/libexec/gsd-xsettings
This works for other gtk2 apps, for example gmrun now starts instantly. However it did not fix lazarus-made apps. I started new lazarus project, added button, compiled it and run. The blank window appears immediately, but it's content became visible only after 25s delay. This only happen in lightweight WMs like openbox.
Here is strace ./Project1
...
socket(AF_UNIX, SOCK_STREAM|SOCK_CLOEXEC, 0) = 14
fcntl(14, F_GETFL) = 0x2 (flags O_RDWR)
fcntl(14, F_SETFL, O_RDWR|O_NONBLOCK) = 0
connect(14, {sa_family=AF_UNIX, sun_path="/run/user/1000/bus"}, 110) = 0
getpid() = 20113
geteuid() = 1000
getegid() = 1000
getpid() = 20113
geteuid() = 1000
getegid() = 1000
sendmsg(14, {msg_name=NULL, msg_namelen=0, msg_iov=[{iov_base="\0", iov_len=1}], msg_iovlen=1, msg_control=[{cmsg_len=28, cmsg_level=SOL_SOCKET, cmsg_type=SCM_CREDENTIALS, cmsg_data={pid=20113, uid=1000, gid=1000}}], msg_controllen=32, msg_flags=0}, MSG_NOSIGNAL) = 1
sendto(14, "AUTH\r\n", 6, MSG_NOSIGNAL, NULL, 0) = 6
recvfrom(14, "REJECTED EXTERNAL\r\n", 4096, 0, NULL, NULL) = 19
sendto(14, "AUTH EXTERNAL 31303030\r\n", 24, MSG_NOSIGNAL, NULL, 0) = 24
recvfrom(14, "OK d1e193bc144cb8f8d4f45a815f358"..., 4096, 0, NULL, NULL) = 37
sendto(14, "NEGOTIATE_UNIX_FD\r\n", 19, MSG_NOSIGNAL, NULL, 0) = 19
recvfrom(14, "AGREE_UNIX_FD\r\n", 4096, 0, NULL, NULL) = 15
sendto(14, "BEGIN\r\n", 7, MSG_NOSIGNAL, NULL, 0) = 7
write(17, "\1\0\0\0\0\0\0\0", 8) = 8
eventfd2(0, EFD_CLOEXEC|EFD_NONBLOCK) = 16
write(16, "\1\0\0\0\0\0\0\0", 8) = 8
write(17, "\1\0\0\0\0\0\0\0", 8) = 8
poll([{fd=16, events=POLLIN}], 1, 25000) = 1 ([{fd=16, revents=POLLIN}])
read(16, "\1\0\0\0\0\0\0\0", 16) = 8
poll([{fd=16, events=POLLIN}], 1, 24998
... here is 25s delay
) = 0 (Timeout)
write(16, "\1\0\0\0\0\0\0\0", 8) = 8
futex(0x14bc790, FUTEX_WAKE_PRIVATE, 2147483647) = 0
close(16) = 0
write(17, "\1\0\0\0\0\0\0\0", 8) = 8
futex(0x7f602241df38, FUTEX_WAKE_PRIVATE, 2147483647) = 0
futex(0x7f602241df38, FUTEX_WAKE_PRIVATE, 2147483647) = 0
statfs("/home/maly", {f_type=EXT2_SUPER_MAGIC, f_bsize=4096, f_blocks=59255762, f_bfree=57029660, f_bavail=54002204, f_files=15122432, f_ffree=14859840, f_fsid={val=[2534916902, 735370733]}, f_namelen=255, f_frsize=4096, f_flags=ST_VALID|ST_RELATIME}) = 0
futex(0x7f602241df38, FUTEX_WAKE_PRIVATE, 2147483647) = 0
futex(0x7f602241df38, FUTEX_WAKE_PRIVATE, 2147483647) = 0
inotify_init1(IN_CLOEXEC) = 16
fcntl(16, F_GETFL) = 0 (flags O_RDONLY)
fcntl(16, F_SETFL, O_RDONLY|O_NONBLOCK) = 0
write(15, "\1\0\0\0\0\0\0\0", 8) = 8
write(15, "\1\0\0\0\0\0\0\0", 8) = 8
futex(0x14b0020, FUTEX_WAKE_PRIVATE, 1) = 1
futex(0x7f602241df38, FUTEX_WAKE_PRIVATE, 2147483647) = 0
inotify_add_watch(16, "/home/maly/.config/ibus/bus", IN_MODIFY|IN_ATTRIB|IN_CLOSE_WRITE|IN_MOVED_FROM|IN_MOVED_TO|IN_CREATE|IN_DELETE|IN_DELETE_SELF|IN_MOVE_SELF|IN_UNMOUNT|IN_ONLYDIR) = 1
openat(AT_FDCWD, "/home/maly/.config/ibus/bus/0b994dfb915f499ba5a6a4702cf76e43-unix-0", O_RDONLY) = 18
fstat(18, {st_mode=S_IFREG|0664, st_size=379, ...}) = 0
read(18, "# This file is created by ibus-d"..., 4096) = 379
read(18, "", 4096) = 0
close(18) = 0
kill(13462, 0) = -1 ESRCH (No such process)
mmap(NULL, 8392704, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_STACK, -1, 0) = 0x7f601df64000
mprotect(0x7f601df65000, 8388608, PROT_READ|PROT_WRITE) = 0
clone(child_stack=0x7f601e763cf0, flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM|CLONE_SETTLS|CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID, parent_tid=[20119], tls=0x7f601e764700, child_tidptr=0x7f601e7649d0) = 20119
futex(0x1321ea0, FUTEX_WAKE_PRIVATE, 1) = 1
futex(0x7f602241dd80, FUTEX_WAKE_PRIVATE, 1) = 1
futex(0x7f602241df38, FUTEX_WAKE_PRIVATE, 2147483647) = 0
futex(0x7f602247e2a0, FUTEX_WAIT_PRIVATE, 2, NULL) = -1 EAGAIN (Resource temporarily unavailable)
futex(0x7f602247e2a0, FUTEX_WAKE_PRIVATE, 1) = 0
poll([{fd=4, events=POLLIN|POLLOUT}], 1, -1) = 1 ([{fd=4, revents=POLLIN|POLLOUT}])
...
When I'm debugging the project the delay starts at Application.run; then it takes 25s inside this in gtk2widgetset.inc:
while g_main_context_pending(g_main_context_default) and (i>0) do
begin
if FGtkTerminated then
break;
if not g_main_context_iteration(g_main_context_default, False) then
break;
dec(i);
end;
Any idea how to fix this?
-
See issue https://bugs.freepascal.org/view.php?id=36359 (https://bugs.freepascal.org/view.php?id=36359). This is not specific to Lazarus GTK2 applications, but impacts many GTK applications (KeepassXC, Filezilla, OnlyOffice Desktop-Editor, HexChat).
Despite the prevalence, this bug still exists, months after the initial report https://bugs.launchpad.net/ubuntu/+source/dbus/+bug/1852016 (https://bugs.launchpad.net/ubuntu/+source/dbus/+bug/1852016). Perhaps you can add your voice there to help get this prioritized.
The simplest solution is
sudo apt-get install appmenu-gtk2-module
On the other hand, most Lazarus projects can now target QT5, which does not have this problem. It looks like GTK3 has issues that will not be fixed (e.g. unable to multi-sample OpenGL) now that development has moved to GTK4. Therefore, it seems like QT5 is the only modern and complete widgetset for Linux.
-
The only thing that worked was using "dbus-launch ./project1" so for every lazarus project I will create script that runs project executable via dbus-launch. I cannot use "dbus-launch openbox" because it is not "inherited" so if openbox runs other programs, it will no longer work. For example if i use "dbus-launch ./project1" it is fast, but if I run "dbus-launch xterm" and in xterm I run ./project it is slow again. It is annoying but at least it works.
If someone know of proper fix let me know.
-
Despite the prevalence, this bug still exists, months after the initial report https://bugs.launchpad.net/ubuntu/+source/dbus/+bug/1852016 (https://bugs.launchpad.net/ubuntu/+source/dbus/+bug/1852016). Perhaps you can add your voice there to help get this prioritized.
I wouldn't bet on it being fixed at all, as GTK2 is pretty much a dead horse now. GTK4 is close to being released and most Linux distros that have relied on GTK2 (like XFCE) are currently updating to GTK3. GTK2 is now just maintained by a small (and shrinking) number of people, so there is not much workforce behind to fix bugs anymore, especeially if the bugs aren't that bad and can be circumvented
-
That is bad. GTK3 implementation is LCL Interface is still in alpha state now.
-
I think the problem disappears if you install a certain package...i don't know what.
My applications are opening fast without any prefixes. I have tested this in Ubuntu 19.09 2004 with Gnome, Xface and kde DE.
-
My Ubuntu Mate 20.04 64-bit is working good, never have any performance issue.
-
Installing package appmenu-gtk2-module only works in gnome, maybe xfce. In small VMs (openbox, ...) it doesn't work.
Maybe we could try to find what file is GTK trying to open for 25000ms and add option to GTK that would skip this file (it doesn't find it anyway and app still works.)
-
Installing package appmenu-gtk2-module only works in gnome, maybe xfce. In small VMs (openbox, ...) it doesn't work.
there is a quote for SmlallVMs in the Bugreport
I had to start openbox with:
/usr/bin/dbus-launch --exit-with-session openbox --startup $HOME/.config/openbox/autostart
The dbus-launch --exit-with-session apparently starts some service that gnome apps now insist on.
maybe it works for your openbox, if the appmenue... does not work for you.
-
I've tried it, it doesn't work.
-
My Ubuntu Mate 20.04 64-bit is working good, never have any performance issue.
I've been experiencing general performance issues (starting applications and closing them mainly) in two of my three Ubuntu 20.04 installations (a desktop and a netbook) for a few days since certain packages where updated. Recentlly, everything is back again to normall performance. Not really sure what happened...
-
25 seconds is the "service_start_timeout" default limit from dbus-daemon.
Here the problem is that GTK_MODULES environment variable is not set when dbus-daemon is launched at start of session (it is normally launched by an init script).
You need to update it with:
dbus-update-activation-environment --systemd GTK_MODULES
-
For me
sudo apt-get install appmenu-gtk2-module
worked, but it did require not only an install, but also re-booting the computer.
-
25 seconds is the "service_start_timeout" default limit from dbus-daemon.
Here the problem is that GTK_MODULES environment variable is not set when dbus-daemon is launched at start of session (it is normally launched by an init script).
You need to update it with:
dbus-update-activation-environment --systemd GTK_MODULES
It doesn't work:
$ dbus-update-activation-environment --systemd GTK_MODULES
dbus-update-activation-environment: warning: error sending to systemd: org.freedesktop.DBus.Error.Spawn.ChildExited: Process org.freedesktop.systemd1 exited with status 1
-
Gentlemen, I found it. I compared `env` between unity and openbox and found it. It is as simple as putting this:
export GTK_MODULES=gail:atk-bridge:appmenu-gtk-module
In ~/.profile. Now everything is fast.
-
GTK4 is close to being released and most Linux distros that have relied on GTK2 (like XFCE) are currently updating to GTK3.
What is the situation about Lazarus in regard to GTK4?
-
As far as I know GTK4 haven't started yet:
https://wiki.lazarus.freepascal.org/Roadmap#General_status_of_LCL_interfaces
-
Gentlemen, I found it. I compared `env` between unity and openbox and found it. It is as simple as putting this:
export GTK_MODULES=gail:atk-bridge:appmenu-gtk-module
In ~/.profile. Now everything is fast.
Maybe you should indicated in the title <SOLVED>, so other people will know there is a solution.
-
Installing appmenu-gtk-module package should not be necessary.
It is just a workaround. It works because it contains this systemd service:
https://github.com/rilian-la-te/vala-panel-appmenu/blob/master/subprojects/appmenu-gtk-module/data/appmenu-gtk-module.service.in (https://github.com/rilian-la-te/vala-panel-appmenu/blob/master/subprojects/appmenu-gtk-module/data/appmenu-gtk-module.service.in)
As you can see it updates GTK_MODULES environment variable after dbus-daemon execution (that's why you need to reboot) and only for xfce, mate and gnome (that's why it don't work with openbox).
-
Some conflicting statements here.
> Gentlemen, I found it. I compared `env` between unity ..
Unity ?? Seriously ? anyway ....
We do know that on most desktops, appmenu-gtk-module 'fixes' the problem. In an earlier Ubuntu, they left it off the list of dependencies for GTK2. Manually installing it fixed the problem but introduced other issues. Since then, Canonical ship gtk2 AND appmenu... as standard, out of the box and it all works.
Can we please clarify, does installing appmenu-gtk-module fix the OpenBox situation ?
If an OpenBox distro has a problem and its fixed by manually installing appmenu-gtk-module, then the problem is, again, that the packagers have not included appmenu-gtk-modual as part of GTK2 and they should have.
We cannot say to our OpenBox end users that they need to do some system reconfig before they can use our app, thats too hard. We can just get away with saying "manually install appmenu-gtk-module". Note we cannot just add appmenu-gtk-module to our app's list of dependencies because older distributions do not have (or need) appmenu-gtk-module and demanding it will break the install.
This is one of those problems that just keeps on giving ....
Davo