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

QML rendering fails in snap confined environment #191

Open
JanisErdmanis opened this issue Nov 16, 2023 · 1 comment
Open

QML rendering fails in snap confined environment #191

JanisErdmanis opened this issue Nov 16, 2023 · 1 comment

Comments

@JanisErdmanis
Copy link

One of the prerequisites to get an application into Snap Store is that it should use a snap confined environment and only use interfaces required for the application functionality. I have made some progress in running a QML application under the snap-confined environment, though with limited success so far.

I am linking the QML application to display drivers and libGL with the snap environment. I do this by using the mesa-core22 content environment library and setting __EGL_VENDOR_LIBRARY_DIRS, LIBGL_DRIVERS_PATH and LD_LIBRARY_PATH environment variables to link to a locally mounted libGL library location resulting in a following snap.yaml configuration:

name: qmlapp-strict
base: core22
version: '0.1.0'
summary: Summary of the app
description: Longer description of the app
grade: devel
confinement: strict

architectures:
- amd64

apps:
  qmlapp-strict:
    command: bin/qmlapp-strict
    desktop: meta/gui/qmlapp-strict.desktop
    plugs:
    - opengl
    - wayland
    - network
    - graphics-core22
    - desktop
    - x11

environment:
  __EGL_VENDOR_LIBRARY_DIRS: $SNAP/graphics/usr/share/glvnd/egl_vendor.d   
  LIBGL_DRIVERS_PATH: $SNAP/graphics/usr/lib/x86_64-linux-gnu/dri
  LD_LIBRARY_PATH: $SNAP/graphics/usr/lib/:$SNAP/graphics/usr/lib/x86_64-linux-gnu/
  PATH: $SNAP/bin/:$PATH
  QT_QPA_PLATFORM: xcb

plugs:
  graphics-core22:
    interface: content
    target: $SNAP/graphics
    default-provider: mesa-core22

layout:
  /usr/share/libdrm:
    bind: $SNAP/graphics/libdrm
  /usr/share/drirc.d:
    bind: $SNAP/graphics/drirc.d

The result is an application window which opens but does not draw any content shown on the left:

qmlapp-strict qmlapp-outside

The output of the session I get is:

Qt: Session management error: Could not open network socket
Qt Warning: Unrecognized OpenGL version ((null):0, (null))
Qt Warning: Unrecognized OpenGL version ((null):0, (null))
Qt Warning: Unrecognized OpenGL version ((null):0, (null))
Qt Warning: Unrecognized OpenGL version ((null):0, (null))
Qt Warning: Unrecognized OpenGL version ((null):0, (null))
Qt Warning: Unrecognized OpenGL version ((null):0, (null))

When running under Wayland with QT_QPA_PLATFORM=wayland, I get the same window but without warnings. On the right, I show how the application should look like started outside a confined environment using SNAP=. SNAP_USER_COMMON=. bin/qmlapp-strict from squashfs-root snap directory, which can be obtained from the snap with unsqaushfs.

The warnings led me to test whether OpenGL actually works. I tested that by bundling a simple window with GLAbstractions with the same setup, which draws everything as expected:

glapp-strict

Thus, it looks like the issue is on the QML side, and I have no clue how to proceed to resolve it.

The snap is around 200 MB large, available for download from here or can be generated with AppBundler.jl by running examples/qmlapp-strict/meta/build.jl build script.

@ufechner7
Copy link
Member

Interesting idea! Would be nice if we could make it work, but I know that snap store is quite restrictive.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants