Weston display issue depending on user id

Dear Toradex team,

A third party Qt GUI application does not display when executed as user root but is displayed when executed as user torizon. How does the user id affects display on a weston container ?

Here is a bit of context :

I try to run a third party application to manage a USB3 camera (IDS-imaging drivers and GUI interface -
IDS peak 2.8.0 for Linux ARMv8 (64-bit) - Debian package
)
The application runs in its own debug container (privileged=true and user : 0:0) and depends on weston-vivante:3.

The application needs to run as root in order to access the USB3 camera (the camera is then correctly detected - The camera won’t be detected if executed as user torizon). I can test the camera detection using some command line interface.

Now, I also would like to use the IDS-Imaging GUI front-end (showing video on the HDMI screen), but it does not launch as root due to a display issue (see logs here below with QT_DEBUG_PLUGINS=1). However, when the GUI is ran as user torizon, it nicely displays (see second log here after). In other words I have one part of the application that must run as root (camera detection) while the other part must run as torizon (image display). But I would like to have both at the same time !

Here are the logs depending on user :

Third party IDS-Imaging GUI ran as user root fails

root@apalis-imx8-14716873:/# export QT_DEBUG_PLUGINS=1
root@apalis-imx8-14716873:/# export QT_QPA_PLATFORM="xcb"
root@apalis-imx8-14716873:/# /usr/lib/ids/bin/ids_peak_cockpit
QFactoryLoader::QFactoryLoader() checking directory path "/usr/lib/aarch64-linux-gnu/qt5/plugins/platforms" ...
QFactoryLoader::QFactoryLoader() looking at "/usr/lib/aarch64-linux-gnu/qt5/plugins/platforms/libqeglfs.so"
Found metadata in lib /usr/lib/aarch64-linux-gnu/qt5/plugins/platforms/libqeglfs.so, metadata=
{
    "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
    "MetaData": {
        "Keys": [
            "eglfs"
        ]
    },
    "archreq": 0,
    "className": "QEglFSIntegrationPlugin",
    "debug": false,
    "version": 331520

< ...
   many more similar messages 
...>

Got keys from plugin meta data ("xcb")
QFactoryLoader::QFactoryLoader() checking directory path "/usr/lib/ids/bin/platforms" ...
loaded library "/usr/lib/aarch64-linux-gnu/qt5/plugins/platforms/libqxcb.so"
Authorization required, but no authorization protocol specified

qt.qpa.xcb: could not connect to display :0
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

Available platform plugins are: eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, xcb.

Aborted (core dumped)

Third party IDS-Imaging GUI ran as user torizon succeeds

root@apalis-imx8-14716873:/# su torizon
$ export QT_DEBUG_PLUGINS=1
$ export QT_QPA_PLATFORM="xcb"
$ /usr/lib/ids/bin/ids_peak_cockpit         
QFactoryLoader::QFactoryLoader() checking directory path "/usr/lib/aarch64-linux-gnu/qt5/plugins/platforms" ...
QFactoryLoader::QFactoryLoader() looking at "/usr/lib/aarch64-linux-gnu/qt5/plugins/platforms/libqeglfs.so"
Found metadata in lib /usr/lib/aarch64-linux-gnu/qt5/plugins/platforms/libqeglfs.so, metadata=
{
    "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
    "MetaData": {
        "Keys": [
            "eglfs"
        ]
    },
    "archreq": 0,
    "className": "QEglFSIntegrationPlugin",
    "debug": false,
    "version": 331520
}


<... 
many more similar messages 
...>


Got keys from plugin meta data ("xcb_glx")
QFactoryLoader::QFactoryLoader() checking directory path "/usr/lib/ids/bin/xcbglintegrations" ...
loaded library "/usr/lib/aarch64-linux-gnu/qt5/plugins/xcbglintegrations/libqxcb-glx-integration.so"
loaded library "/usr/lib/aarch64-linux-gnu/qt5/plugins/xcbglintegrations/libqxcb-egl-integration.so"
QFactoryLoader::QFactoryLoader() checking directory path "/usr/lib/aarch64-linux-gnu/qt5/plugins/accessiblebridge" ...
QFactoryLoader::QFactoryLoader() checking directory path "/usr/lib/ids/bin/accessiblebridge" ...

Now, a custom application I have developed also run as root but in this case the GUI is shown successfully. Here are the logs :

Custom GUI as user root succeed.

qt.core.plugin.factoryloader: checking directory path "/usr/lib/aarch64-linux-gnu/qt6/plugins/platforms" ...
qt.core.plugin.factoryloader: looking at "/usr/lib/aarch64-linux-gnu/qt6/plugins/platforms/libqminimal.so"
qt.core.plugin.loader: Found metadata in lib /usr/lib/aarch64-linux-gnu/qt6/plugins/platforms/libqminimal.so, metadata=
{
    "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
    "MetaData": {
        "Keys": [
            "minimal"
        ]
    },
    "archlevel": 0,
    "className": "QMinimalIntegrationPlugin",
    "debug": false,
    "version": 394240
}

<... 
many more similar messages 
...>

qt.core.plugin.factoryloader: Got keys from plugin meta data QList("vnc")
qt.core.plugin.factoryloader: checking directory path "/root/app/platforms" ...
qt.core.library: "/usr/lib/aarch64-linux-gnu/qt6/plugins/platforms/libqwayland-generic.so" loaded library
QStandardPaths: runtime directory '/tmp/1000-runtime-dir' is not owned by UID 0, but a directory permissions 0700 owned by UID 1000 GID 0
qt.core.plugin.factoryloader: checking directory path "/usr/lib/aarch64-linux-gnu/qt6/plugins/platformthemes" ...
qt.core.plugin.factoryloader: checking directory path "/root/app/platformthemes" ...
qt.core.plugin.factoryloader: checking directory path "/usr/lib/aarch64-linux-gnu/qt6/plugins/styles" ...
qt.core.plugin.factoryloader: checking directory path "/root/app/styles" ...

So it seems there is no fundamental limitation to display on Weston when launched as user root but it does not work for all applications.

Do you have some hint why it behaves like this ? Is there some environment variable I should set on the application side, or alternatively modify the Weston configuration ?

Best regards,
Fabian

Greetings @fdortu,

The issue here is that you’re setting QT_QPA_PLATFORM="xcb" for your third-party GUI. This means Qt will use the XWayland x-server to display this GUI. By default x-server type applications don’t work for root user. This is why you’re seeing this kind of behavior.

There is a workaround for this however. For XWayland it doesn’t seem to disallow specifically the root user. What it does is check that if the user launching the GUI application is the same user that started Weston/Wayland. This means if we start Weston/Wayland as the root user then it should work.

I launched the Weston container adding this environment variable to it WAYLAND_USER=root. In another container I launched an example Qt app with QT_QPA_PLATFORM="xcb", and it worked! Where before it failed with a simlar error as your third-party GUI. Give this a try and let me know how it works out.

Best Regards,
Jeremias

Thanks Jeremias,

It works!

Fabian

Perfect glad to hear you were able to proceed!