Discussion:
starting qt application after DRM initialized
(too old to reply)
Belisko Marek
2018-12-06 21:58:31 UTC
Permalink
Hi,

I'm trying to run qt qml application on intel nuc but when booted from
hdd I'll get an eror when app is started:

Dec 06 21:39:43 b2qt-intel-corei7-64 appcontroller[232]:
"QT_IM_MODULE" "qtvirtualkeyboard"
Dec 06 21:39:43 b2qt-intel-corei7-64 appcontroller[232]:
"QT_QPA_EGLFS_FORCE888" "0"
Dec 06 21:39:43 b2qt-intel-corei7-64 appcontroller[232]:
"QT_QPA_EGLFS_KMS_CONFIG" "/etc/kms.conf"
Dec 06 21:39:43 b2qt-intel-corei7-64 appcontroller[232]:
"QT_QUICK_CONTROLS_1_STYLE" "Flat"
Dec 06 21:39:43 b2qt-intel-corei7-64 appcontroller[232]:
"XDG_RUNTIME_DIR" "/run/user/0"
Dec 06 21:39:43 b2qt-intel-corei7-64 appcontroller[232]: "/opt/test"
("--applications-root", "/data/user/qt")
Dec 06 21:39:44 b2qt-intel-corei7-64 appcontroller[232]: Could not
find DRM device!
Dec 06 21:39:44 b2qt-intel-corei7-64 appcontroller[232]: quit

and unit looks like:
[Unit]
Description=Demo
After=systemd-user-sessions.service

[Service]
ExecStart=-/usr/bin/appcontroller /opt/test --applications-root /data/user/qt

[Install]
WantedBy=multi-user.target

I think it is some kind of timing issue as when booting same image
from usb stick application will automatically start while when booting
from hdd I get above error. Would be possible to postpone it somehow
until DRM display is initialized? Thanks.

BR,

marek

--
as simple and primitive as possible
-------------------------------------------------
Marek Belisko - OPEN-NANDRA
Freelance Developer

Ruska Nova Ves 219 | Presov, 08005 Slovak Republic
Tel: +421 915 052 184
skype: marekwhite
twitter: #opennandra
web: http://open-nandra.com
Tomasz Torcz
2018-12-07 05:25:55 UTC
Permalink
Post by Belisko Marek
Hi,
I'm trying to run qt qml application on intel nuc but when booted from
I think it is some kind of timing issue as when booting same image
from usb stick application will automatically start while when booting
from hdd I get above error. Would be possible to postpone it somehow
until DRM display is initialized? Thanks.
This is exactly the problem GDM (GNOME Display Manager) encountered
few years ago. The solution was devised – your application needs to wait
until CanGraphical property goes to yes on the seat application is
using.
See https://gitlab.gnome.org/GNOME/gdm/issues/103
--
Tomasz Torcz 72->| 80->|
xmpp: ***@chrome.pl 72->| 80->|
Belisko Marek
2018-12-07 07:36:18 UTC
Permalink
Hi Tomasz,
Post by Tomasz Torcz
Post by Belisko Marek
Hi,
I'm trying to run qt qml application on intel nuc but when booted from
I think it is some kind of timing issue as when booting same image
from usb stick application will automatically start while when booting
from hdd I get above error. Would be possible to postpone it somehow
until DRM display is initialized? Thanks.
This is exactly the problem GDM (GNOME Display Manager) encountered
few years ago. The solution was devised – your application needs to wait
until CanGraphical property goes to yes on the seat application is
using.
Thanks for info. But I'm not suing any GDM (nor X) just qml
application. So IIRC then I need to code something in my application
to wait until
CanGraphical is available? I'm bit confused ;). I was thinking about
approach that systemd can postpone starting of my application until
DRM is available (not sure is such trigger exists though).
Thanks.
Post by Tomasz Torcz
See https://gitlab.gnome.org/GNOME/gdm/issues/103
--
Tomasz Torcz 72->| 80->|
_______________________________________________
systemd-devel mailing list
https://lists.freedesktop.org/mailman/listinfo/systemd-devel
BR,

marek
--
as simple and primitive as possible
-------------------------------------------------
Marek Belisko - OPEN-NANDRA
Freelance Developer

Ruska Nova Ves 219 | Presov, 08005 Slovak Republic
Tel: +421 915 052 184
skype: marekwhite
twitter: #opennandra
web: http://open-nandra.com
Mantas Mikulėnas
2018-12-07 08:20:31 UTC
Permalink
Post by Belisko Marek
Hi Tomasz,
Post by Tomasz Torcz
Post by Belisko Marek
Hi,
I'm trying to run qt qml application on intel nuc but when booted from
I think it is some kind of timing issue as when booting same image
from usb stick application will automatically start while when booting
from hdd I get above error. Would be possible to postpone it somehow
until DRM display is initialized? Thanks.
This is exactly the problem GDM (GNOME Display Manager) encountered
few years ago. The solution was devised – your application needs to wait
until CanGraphical property goes to yes on the seat application is
using.
Thanks for info. But I'm not suing any GDM (nor X) just qml
application. So IIRC then I need to code something in my application
to wait until
CanGraphical is available?
Yes, to use this method you would need to access logind's D-Bus API. I'm
not sure whether QML provides D-Bus access, although Qt does.
Post by Belisko Marek
I was thinking about
approach that systemd can postpone starting of my application until
DRM is available (not sure is such trigger exists though).
It sounds more like you're looking for a dependency, not a trigger.
(Although either would work, I guess.)

In systemd itself, the only available built-in dependency is "device now
available in /dev or /sys". For example, you could use this, assuming
there's only one card and it's always called "card0":

[Unit]
Requires=dev-dri-card0.device
After=dev-dri-card0.device

(Note: This also needs udev/rules.d/99-systemd.rules to be extended with an
apropriate TAG+="systemd".)
--
Mantas Mikulėnas
Lennart Poettering
2018-12-07 11:34:29 UTC
Permalink
Post by Belisko Marek
[Unit]
Description=Demo
After=systemd-user-sessions.service
[Service]
ExecStart=-/usr/bin/appcontroller /opt/test --applications-root /data/user/qt
[Install]
WantedBy=multi-user.target
I think it is some kind of timing issue as when booting same image
from usb stick application will automatically start while when booting
from hdd I get above error. Would be possible to postpone it somehow
until DRM display is initialized? Thanks.
You have two options:

1. The correct solution: make your tool wait internally that the
CanGraphical= bus property of logind's Seat object "seat0" turns to
"true". Then enumerate all devices belonging to the Seat, and open
and use them. This is how "gdm" does and how this should be done in
generic codepaths.

2. If you want a quicker, slightly sloppy solution that only works if
you design for a specific hardware setup you know well: mark your
drm device via a udev rule with the "systemd" tag
(TAGS+="systemd"). This makes the drm device show up as a ".device"
unit in systemd. Then, change your service to say "Wants=…" and
"After=…" that .device unit. This then makes sure that the service
will not even be started before the device is around.

Lennart

--
Lennart Poettering, Red Hat
Belisko Marek
2018-12-07 11:45:30 UTC
Permalink
On Fri, Dec 7, 2018 at 12:34 PM Lennart Poettering
Post by Lennart Poettering
Post by Belisko Marek
[Unit]
Description=Demo
After=systemd-user-sessions.service
[Service]
ExecStart=-/usr/bin/appcontroller /opt/test --applications-root /data/user/qt
[Install]
WantedBy=multi-user.target
I think it is some kind of timing issue as when booting same image
from usb stick application will automatically start while when booting
from hdd I get above error. Would be possible to postpone it somehow
until DRM display is initialized? Thanks.
1. The correct solution: make your tool wait internally that the
CanGraphical= bus property of logind's Seat object "seat0" turns to
"true". Then enumerate all devices belonging to the Seat, and open
and use them. This is how "gdm" does and how this should be done in
generic codepaths.
2. If you want a quicker, slightly sloppy solution that only works if
you design for a specific hardware setup you know well: mark your
drm device via a udev rule with the "systemd" tag
(TAGS+="systemd"). This makes the drm device show up as a ".device"
unit in systemd. Then, change your service to say "Wants=…" and
"After=…" that .device unit. This then makes sure that the service
will not even be started before the device is around.
Thanks a lot for valuable info. I'll try and get back with results.
Post by Lennart Poettering
Lennart
--
Lennart Poettering, Red Hat
BR,

marek
--
as simple and primitive as possible
-------------------------------------------------
Marek Belisko - OPEN-NANDRA
Freelance Developer

Ruska Nova Ves 219 | Presov, 08005 Slovak Republic
Tel: +421 915 052 184
skype: marekwhite
twitter: #opennandra
web: http://open-nandra.com
Loading...