Electron app can't get a webgl context on Debian


#1

I don’t run Debian myself, but I’ve received some bug reports that Polarr (an electron snap) doesn’t work on Debian. Polarr does run on Ubuntu. Looking at the Polarr logs I’ve been sent, I can tell that Polarr 5 is failing to get a webgl context where Polarr 4 was able to get a webgl context. This is basically canvas.createContext(“webgl”) returns null in Electron but now on Debian.

package.json
{
  "name": "polarr",
  "version": "5.1.2",
  "description": "Powerful and easy-to-use photo editor.",
  "main": "main.js",
  "author": "Polarr, Inc",
  "scripts": {
    "start": "electron . --dev",
    "build:mac": "electron-packager . Polarr --name=Polarr --platform=darwin --arch=x64 --icon=icon.icns --asar --overwrite --version-string.ProductName=Polarr",
    "build:win": "node build_win.js",
    "build:linux": "node build_linux.js",
    "docker": "bash run-docker.sh",
    "snap:linux": "electron-builder",
    "build_win_zh": "node build_win_zh.js"
  },
  "build": {
    "appId": "co.polarr.photoeditor",
    "linux": {
      "icon": "icon",
      "synopsis": "Powerful and easy-to-use photo editor.",
      "description": "Used by the world's most professional portrait and landscape photographers, Polarr offers advanced auto-enhance tools and sophisticated filters to edit every detail of your photo.",
      "category": "Graphics;Photography",
      "target": [
        "snap"
      ]
    },
    "fileAssociations": [
      {
        "ext": [
          "tiff",
          "tif",
          "3fr",
          "ari",
          "arw",
          "bay",
          "crw",
          "cr2",
          "cap",
          "dcs",
          "dcr",
          "dng",
          "drf",
          "eip",
          "erf",
          "fff",
          "iiq",
          "k25",
          "kdc",
          "mef",
          "mos",
          "mrw",
          "nef",
          "nrw",
          "obm",
          "orf",
          "pef",
          "ptx",
          "pxn",
          "r3d",
          "raf",
          "raw",
          "rwl",
          "rw2",
          "rwz",
          "sr2",
          "srf",
          "srw",
          "x3f"
        ],
        "name": "Raw Image"
      },
      {
        "ext": ["jpg", "jpeg", "png", "bmp", "gif"],
        "name": "Image"
      }
    ],
    "extraResources": [
      "node_modules/sharp/vendor/lib"
    ],
    "appImage": {},
    "snap": {
      "confinement": "strict",
      "summary": "Powerful and easy-to-use photo editor.",
      "grade": "stable",
      "stagePackages": [
        "default",
        "libcanberra-gtk-module",
        "libgail-3-0",
        "libatk1.0-0",
        "unity-gtk-module-common"
      ],
      "plugs": [
        "default",
        "removable-media"
      ],
      "environment": {
        "LD_LIBRARY_PATH": "$SNAP/usr/lib:$SNAP/usr/lib/x86_64-linux-gnu:$SNAP/app/resources/node_modules/sharp/vendor/lib"
      }
    }
  },
  "devDependencies": {
    "asar": "^0.14.3",
    "electron": "^2.0.0",
    "electron-builder": "^20.8.2",
    "electron-packager": "^12.1.0",
    "electron-squirrel-startup": "^1.0.0",
    "electron-winstaller": "^2.6.4",
    "env-paths": "^1.0.0",
    "grunt": "^1.0.2",
    "grunt-electron-installer": "^2.1.0",
    "iconv-lite": "^0.4.18",
    "locate-path": "^3.0.0",
    "universalify": "^0.1.0"
  },
  "dependencies": {
    "electron-fetch": "^1.0.0",
    "get-pixels": "^3.3.0",
    "libraw": "file:libraw",
    "readable-stream": "^3.0.1",
    "sharp": "^0.20.5",
    "temp": "^0.8.3",
    "url-exists": "^1.0.3"
  }
}

I had to remove libgl1-mesa-glx from stagePackages when rebuilding Polarr because in the last 8 months that magic line changed from being necessary to causing the problem it used to solve:

$ polarr
Gtk-Message: 02:52:42.548: Failed to load module "canberra-gtk-module"
Gtk-Message: 02:52:42.558: Failed to load module "canberra-gtk-module"
process.argv [ '/snap/polarr/x1/app/polarr' ]
libGL error: No matching fbConfigs or visuals found
libGL error: failed to load driver: swrast
libGL error: No matching fbConfigs or visuals found
libGL error: failed to load driver: swrast
Unhandled rejection: TypeError: Cannot set property 'HALF_FLOAT_OES' of null
    at Object.create (file:///snap/polarr/x1/app/resources/app.asar/js/build/editor.js:35:139097)
    at Object.<anonymous> (file:///snap/polarr/x1/app/resources/app.asar/js/build/editor.js:12:4392)
    at r (file:///snap/polarr/x1/app/resources/app.asar/js/build/editor.js:1:157)
    at Object.<anonymous> (file:///snap/polarr/x1/app/resources/app.asar/js/build/editor.js:20:323358)
    at r (file:///snap/polarr/x1/app/resources/app.asar/js/build/editor.js:1:157)
    at file:///snap/polarr/x1/app/resources/app.asar/js/build/editor.js:40:731021
    at file:///snap/polarr/x1/app/resources/app.asar/js/build/editor.js:20:104938
    at file:///snap/polarr/x1/app/resources/app.asar/js/build/editor.js:69:33067
    at De (file:///snap/polarr/x1/app/resources/app.asar/js/build/editor.js:69:28320)
    at qe (file:///snap/polarr/x1/app/resources/app.asar/js/build/editor.js:69:28804)

#2

I don’t know whether the electron builder automatically adds the opengl plug, but you could try adding it to the build.snap.plugs list in your package.json file.


#3

electron-builder adds the opengl plug as part of default, and adding it again fails the build:

Setting target machine to 'amd64'
Issues while validating snapcraft.yaml: The 'apps/polarr/plugs' property does not match the required schema: ['desktop', 'desktop-legacy', 'home', 'x11', 'unity7', 'browser-support', 'network', 'gsettings', 'pulseaudio', 'opengl', 'opengl', 'removable-media'] has non-unique elements
  ⨯ exit status 2

#4

I believe failed to load driver issues, then, will be a result of the build not including the mesa libraries. You’ll want to add libglu1-mesa to your stagePackages to pull all the required libraries.


#5

That similarly causes the snap to fail to run on Ubuntu:

$ polarr
Gtk-Message: 03:15:57.121: Failed to load module "canberra-gtk-module"
Gtk-Message: 03:15:57.131: Failed to load module "canberra-gtk-module"
process.argv [ '/snap/polarr/x2/app/polarr' ]
libGL error: No matching fbConfigs or visuals found
libGL error: failed to load driver: swrast
libGL error: No matching fbConfigs or visuals found
libGL error: failed to load driver: swrast
Unhandled rejection: TypeError: Cannot set property 'HALF_FLOAT_OES' of null
    at Object.create (file:///snap/polarr/x2/app/resources/app.asar/js/build/editor.js:35:139097)
    at Object.<anonymous> (file:///snap/polarr/x2/app/resources/app.asar/js/build/editor.js:12:4392)
    at r (file:///snap/polarr/x2/app/resources/app.asar/js/build/editor.js:1:157)
    at Object.<anonymous> (file:///snap/polarr/x2/app/resources/app.asar/js/build/editor.js:20:323358)
    at r (file:///snap/polarr/x2/app/resources/app.asar/js/build/editor.js:1:157)
    at file:///snap/polarr/x2/app/resources/app.asar/js/build/editor.js:40:731021
    at file:///snap/polarr/x2/app/resources/app.asar/js/build/editor.js:20:104938
    at file:///snap/polarr/x2/app/resources/app.asar/js/build/editor.js:69:33067
    at De (file:///snap/polarr/x2/app/resources/app.asar/js/build/editor.js:69:28320)
    at qe (file:///snap/polarr/x2/app/resources/app.asar/js/build/editor.js:69:28804)

#6

In a weak moment of wild guessing i’d say you are using an nvidia card …


#7

I’m using an Nvidia 1070.


#8

Can you run:

$ sudo /usr/lib/snapd/snap-discard-ns polarr
$ SNAPD_DEBUG=1 SNAP_CONFINE_DEBUG=1 snap run polarr

and post the log somewhere?


#9

It looks like the problem isn’t Debian-specific, but that systems that don’t have Nvidia drivers installed can’t get a WebGL context in the Electron app:

uname -a

Linux HP-Pro-x2-612-G1 4.15.0-34-generic #37-Ubuntu SMP Mon Aug 27 15:21:48 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

snap --version

snap 2.35
snapd 2.35
series 16
ubuntu 18.04
kernel 4.15.0-34-generic

SNAPD_DEBUG=1 SNAP_CONFINE_DEBUG=1 snap run polarr

2018/09/12 19:14:57.127384 cmd.go:203: DEBUG: restarting into “/snap/core/current/usr/bin/snap”
DEBUG: security tag: snap.polarr.polarr
DEBUG: executable: /usr/lib/snapd/snap-exec
DEBUG: confinement: non-classic
DEBUG: base snap: core
DEBUG: ruid: 1000, euid: 0, suid: 0
DEBUG: rgid: 1000, egid: 0, sgid: 0
DEBUG: apparmor label on snap-confine is: /snap/core/5328/usr/lib/snapd/snap-confine
DEBUG: apparmor mode is: enforce
DEBUG: checking if the current process shares mount namespace with the init process
DEBUG: re-associating is not required
DEBUG: creating lock directory /run/snapd/lock (if missing)
DEBUG: opening lock directory /run/snapd/lock
DEBUG: opening lock file: /run/snapd/lock/.lock
DEBUG: sanity timeout initialized and set for three seconds
DEBUG: acquiring exclusive lock (scope (global), uid 0)
DEBUG: sanity timeout reset and disabled
DEBUG: ensuring that snap mount directory is shared
DEBUG: unsharing snap namespace directory
DEBUG: creating namespace group directory /run/snapd/ns
DEBUG: namespace group directory does not require intialization
DEBUG: releasing lock 4
DEBUG: snap-update-ns executable: /snap/core/5328/usr/lib/snapd/snap-update-ns
DEBUG: opened snap-update-ns executable as file descriptor 3
DEBUG: creating lock directory /run/snapd/lock (if missing)
DEBUG: opening lock directory /run/snapd/lock
DEBUG: opening lock file: /run/snapd/lock/polarr.lock
DEBUG: sanity timeout initialized and set for three seconds
DEBUG: acquiring exclusive lock (scope polarr, uid 0)
DEBUG: sanity timeout reset and disabled
DEBUG: initializing mount namespace: polarr
DEBUG: opening namespace group directory /run/snapd/ns
DEBUG: initializing new namespace group polarr
DEBUG: forking support process for mount namespace capture
DEBUG: forked support process has pid 13442
DEBUG: unsharing the mount namespace
DEBUG: forked support process has pid 0
DEBUG: changing apparmor hat of the support process for mount namespace capture
DEBUG: changing apparmor hat to mount-namespace-capture-helper
DEBUG: ensuring that parent process is still alive
DEBUG: waiting for a eventfd data from the parent process to continue
DEBUG: sanity timeout initialized and set for three seconds
DEBUG: scratch directory for constructing namespace: /tmp/snap.rootfs_eqNAfY
DEBUG: performing operation: (disabled) use debug build to see details
DEBUG: performing operation: (disabled) use debug build to see details
DEBUG: performing operation: (disabled) use debug build to see details
DEBUG: performing operation: (disabled) use debug build to see details
DEBUG: performing operation: (disabled) use debug build to see details
DEBUG: performing operation: (disabled) use debug build to see details
DEBUG: performing operation: (disabled) use debug build to see details
DEBUG: performing operation: (disabled) use debug build to see details
DEBUG: performing operation: (disabled) use debug build to see details
DEBUG: performing operation: (disabled) use debug build to see details
DEBUG: performing operation: (disabled) use debug build to see details
DEBUG: performing operation: (disabled) use debug build to see details
DEBUG: performing operation: (disabled) use debug build to see details
DEBUG: performing operation: (disabled) use debug build to see details
DEBUG: performing operation: (disabled) use debug build to see details
DEBUG: performing operation: (disabled) use debug build to see details
DEBUG: performing operation: (disabled) use debug build to see details
DEBUG: performing operation: (disabled) use debug build to see details
DEBUG: performing operation: (disabled) use debug build to see details
DEBUG: performing operation: (disabled) use debug build to see details
DEBUG: performing operation: (disabled) use debug build to see details
DEBUG: performing operation: (disabled) use debug build to see details
DEBUG: performing operation: (disabled) use debug build to see details
DEBUG: performing operation: (disabled) use debug build to see details
DEBUG: performing operation: (disabled) use debug build to see details
DEBUG: performing operation: (disabled) use debug build to see details
DEBUG: performing operation: (disabled) use debug build to see details
DEBUG: performing operation: (disabled) use debug build to see details
DEBUG: performing operation: (disabled) use debug build to see details
DEBUG: performing operation: (disabled) use debug build to see details
DEBUG: performing operation: (disabled) use debug build to see details
DEBUG: performing operation: (disabled) use debug build to see details
DEBUG: performing operation: (disabled) use debug build to see details
DEBUG: performing operation: (disabled) use debug build to see details
DEBUG: performing operation: (disabled) use debug build to see details
DEBUG: performing operation: (disabled) use debug build to see details
DEBUG: performing operation: (disabled) use debug build to see details
DEBUG: performing operation: (disabled) use debug build to see details
DEBUG: performing operation: (disabled) use debug build to see details
DEBUG: performing operation: (disabled) use debug build to see details
DEBUG: performing operation: (disabled) use debug build to see details
DEBUG: performing operation: (disabled) use debug build to see details
DEBUG: performing operation: (disabled) use debug build to see details
DEBUG: performing operation: (disabled) use debug build to see details
DEBUG: performing operation: (disabled) use debug build to see details
DEBUG: performing operation: pivot_root /tmp/snap.rootfs_eqNAfY /tmp/snap.rootfs_eqNAfY//var/lib/snapd/hostfs
DEBUG: performing operation: (disabled) use debug build to see details
DEBUG: performing operation: rmdir /var/lib/snapd/hostfs//tmp/snap.rootfs_eqNAfY
DEBUG: performing operation: (disabled) use debug build to see details
DEBUG: performing operation: (disabled) use debug build to see details
DEBUG: performing operation: (disabled) use debug build to see details
DEBUG: performing operation: (disabled) use debug build to see details
DEBUG: performing operation: (disabled) use debug build to see details
DEBUG: performing operation: (disabled) use debug build to see details
DEBUG: performing operation: (disabled) use debug build to see details
DEBUG: performing operation: (disabled) use debug build to see details
DEBUG: performing operation: mount --move /var/lib/snapd /tmp/snapd.quirks_uC9nde
DEBUG: creating writable mimic directory /var/lib based on /snap/core/current//var/lib
DEBUG: mounting tmpfs at /var/lib
DEBUG: bind-mounting all the files from the reference directory
DEBUG: creating empty directory at /var/lib/apparmor
DEBUG: performing operation: mount /snap/core/current//var/lib/apparmor /var/lib/apparmor -o ro,nosuid,nodev,rbind,rslave
DEBUG: creating empty directory at /var/lib/classic
DEBUG: performing operation: mount /snap/core/current//var/lib/classic /var/lib/classic -o ro,nosuid,nodev,rbind,rslave
DEBUG: creating empty directory at /var/lib/cloud
DEBUG: performing operation: mount /snap/core/current//var/lib/cloud /var/lib/cloud -o ro,nosuid,nodev,rbind,rslave
DEBUG: creating empty directory at /var/lib/console-conf
DEBUG: performing operation: mount /snap/core/current//var/lib/console-conf /var/lib/console-conf -o ro,nosuid,nodev,rbind,rslave
DEBUG: creating empty directory at /var/lib/dbus
DEBUG: performing operation: mount /snap/core/current//var/lib/dbus /var/lib/dbus -o ro,nosuid,nodev,rbind,rslave
DEBUG: creating empty directory at /var/lib/dhcp
DEBUG: performing operation: mount /snap/core/current//var/lib/dhcp /var/lib/dhcp -o ro,nosuid,nodev,rbind,rslave
DEBUG: creating empty directory at /var/lib/extrausers
DEBUG: performing operation: mount /snap/core/current//var/lib/extrausers /var/lib/extrausers -o ro,nosuid,nodev,rbind,rslave
DEBUG: creating empty directory at /var/lib/initramfs-tools
DEBUG: performing operation: mount /snap/core/current//var/lib/initramfs-tools /var/lib/initramfs-tools -o ro,nosuid,nodev,rbind,rslave
DEBUG: creating empty directory at /var/lib/initscripts
DEBUG: performing operation: mount /snap/core/current//var/lib/initscripts /var/lib/initscripts -o ro,nosuid,nodev,rbind,rslave
DEBUG: creating empty directory at /var/lib/insserv
DEBUG: performing operation: mount /snap/core/current//var/lib/insserv /var/lib/insserv -o ro,nosuid,nodev,rbind,rslave
DEBUG: creating empty directory at /var/lib/logrotate
DEBUG: performing operation: mount /snap/core/current//var/lib/logrotate /var/lib/logrotate -o ro,nosuid,nodev,rbind,rslave
DEBUG: creating empty directory at /var/lib/machines
DEBUG: performing operation: mount /snap/core/current//var/lib/machines /var/lib/machines -o ro,nosuid,nodev,rbind,rslave
DEBUG: creating empty directory at /var/lib/misc
DEBUG: performing operation: mount /snap/core/current//var/lib/misc /var/lib/misc -o ro,nosuid,nodev,rbind,rslave
DEBUG: creating empty directory at /var/lib/pam
DEBUG: performing operation: mount /snap/core/current//var/lib/pam /var/lib/pam -o ro,nosuid,nodev,rbind,rslave
DEBUG: creating empty directory at /var/lib/python
DEBUG: performing operation: mount /snap/core/current//var/lib/python /var/lib/python -o ro,nosuid,nodev,rbind,rslave
DEBUG: creating empty directory at /var/lib/resolvconf
DEBUG: performing operation: mount /snap/core/current//var/lib/resolvconf /var/lib/resolvconf -o ro,nosuid,nodev,rbind,rslave
DEBUG: creating empty directory at /var/lib/snapd
DEBUG: performing operation: mount /snap/core/current//var/lib/snapd /var/lib/snapd -o ro,nosuid,nodev,rbind,rslave
DEBUG: creating empty directory at /var/lib/sudo
DEBUG: performing operation: mount /snap/core/current//var/lib/sudo /var/lib/sudo -o ro,nosuid,nodev,rbind,rslave
DEBUG: creating empty directory at /var/lib/systemd
DEBUG: performing operation: mount /snap/core/current//var/lib/systemd /var/lib/systemd -o ro,nosuid,nodev,rbind,rslave
DEBUG: creating empty directory at /var/lib/ubuntu-fan
DEBUG: performing operation: mount /snap/core/current//var/lib/ubuntu-fan /var/lib/ubuntu-fan -o ro,nosuid,nodev,rbind,rslave
DEBUG: creating empty directory at /var/lib/ucf
DEBUG: performing operation: mount /snap/core/current//var/lib/ucf /var/lib/ucf -o ro,nosuid,nodev,rbind,rslave
DEBUG: creating empty directory at /var/lib/update-rc.d
DEBUG: performing operation: mount /snap/core/current//var/lib/update-rc.d /var/lib/update-rc.d -o ro,nosuid,nodev,rbind,rslave
DEBUG: creating empty directory at /var/lib/urandom
DEBUG: performing operation: mount /snap/core/current//var/lib/urandom /var/lib/urandom -o ro,nosuid,nodev,rbind,rslave
DEBUG: creating empty directory at /var/lib/vim
DEBUG: performing operation: mount /snap/core/current//var/lib/vim /var/lib/vim -o ro,nosuid,nodev,rbind,rslave
DEBUG: creating empty directory at /var/lib/waagent
DEBUG: performing operation: mount /snap/core/current//var/lib/waagent /var/lib/waagent -o ro,nosuid,nodev,rbind,rslave
DEBUG: performing operation: umount /var/lib/snapd
DEBUG: performing operation: mount --move /tmp/snapd.quirks_uC9nde /var/lib/snapd
DEBUG: performing operation: rmdir /tmp/snapd.quirks_uC9nde
DEBUG: calling snap-update-ns to initialize mount namespace
DEBUG: waiting for snap-update-ns to finish…
DEBUG: launching snap-update-ns under per-snap profile snap-update-ns.polarr
DEBUG: requesting changing of apparmor profile on next exec to snap-update-ns.polarr
DEBUG: fexecv(3 (snap-update-ns), snap-update-ns --from-snap-confine polarr,)
main.go:103: DEBUG: locking mount namespace of snap “polarr”
main.go:122: DEBUG: freezing processes of snap “polarr”
main.go:214: DEBUG: desired mount profile:
main.go:216: DEBUG: /var/lib/snapd/hostfs/usr/share/fonts /usr/share/fonts none bind,ro 0 0
main.go:216: DEBUG: /var/lib/snapd/hostfs/usr/local/share/fonts /usr/local/share/fonts none bind,ro 0 0
main.go:216: DEBUG: /var/lib/snapd/hostfs/var/cache/fontconfig /var/cache/fontconfig none bind,ro 0 0
main.go:219: DEBUG: current mount profile (before applying changes): (none)
change.go:405: DEBUG: desiredIDs: map[/usr/local/share/fonts:true /usr/share/fonts:true /var/cache/fontconfig:true]
change.go:406: DEBUG: reuse: map[]
main.go:225: DEBUG: mount changes needed:
main.go:227: DEBUG: mount (/var/lib/snapd/hostfs/usr/local/share/fonts /usr/local/share/fonts none bind,ro 0 0)
main.go:227: DEBUG: mount (/var/lib/snapd/hostfs/usr/share/fonts /usr/share/fonts none bind,ro 0 0)
main.go:227: DEBUG: mount (/var/lib/snapd/hostfs/var/cache/fontconfig /var/cache/fontconfig none bind,ro 0 0)
main.go:174: DEBUG: performing mount changes:
main.go:177: DEBUG: * mount (/var/lib/snapd/hostfs/usr/local/share/fonts /usr/local/share/fonts none bind,ro 0 0)
change.go:294: DEBUG: mount “/var/lib/snapd/hostfs/usr/local/share/fonts” “/usr/local/share/fonts” “none” 4097 “” (error: )
main.go:177: DEBUG: * mount (/var/lib/snapd/hostfs/usr/share/fonts /usr/share/fonts none bind,ro 0 0)
change.go:294: DEBUG: mount “/var/lib/snapd/hostfs/usr/share/fonts” “/usr/share/fonts” “none” 4097 “” (error: )
main.go:177: DEBUG: * mount (/var/lib/snapd/hostfs/var/cache/fontconfig /var/cache/fontconfig none bind,ro 0 0)
change.go:294: DEBUG: mount “/var/lib/snapd/hostfs/var/cache/fontconfig” “/var/cache/fontconfig” “none” 4097 “” (error: )
main.go:214: DEBUG: current mount profile (after applying changes):
main.go:216: DEBUG: /var/lib/snapd/hostfs/usr/local/share/fonts /usr/local/share/fonts none bind,ro 0 0
main.go:216: DEBUG: /var/lib/snapd/hostfs/usr/share/fonts /usr/share/fonts none bind,ro 0 0
main.go:216: DEBUG: /var/lib/snapd/hostfs/var/cache/fontconfig /var/cache/fontconfig none bind,ro 0 0
main.go:160: DEBUG: saving current mount profile of snap “polarr”
main.go:127: DEBUG: thawing processes of snap “polarr”
main.go:99: DEBUG: unlocking mount namespace of snap “polarr”
DEBUG: snap-update-ns finished successfully
DEBUG: asking support process for mount namespace capture (pid: 13442) to perform the capture
DEBUG: waiting for the support process for mount namespace capture to exit
DEBUG: sanity timeout reset and disabled
DEBUG: capturing mount namespace of process 13432 in namespace group polarr
DEBUG: successfully captured mount namespace in namespace group polarr
DEBUG: support process for mount namespace capture exited normally
DEBUG: releasing resources associated with namespace group polarr
DEBUG: moved process 13432 to freezer cgroup hierarchy for snap polarr
DEBUG: releasing lock 5
DEBUG: sc_setup_user_mounts: polarr
DEBUG: performing operation: (disabled) use debug build to see details
DEBUG: calling snap-update-ns to initialize user mounts
DEBUG: waiting for snap-update-ns to finish…
DEBUG: launching snap-update-ns under per-snap profile snap-update-ns.polarr
DEBUG: requesting changing of apparmor profile on next exec to snap-update-ns.polarr
DEBUG: fexecv(3 (snap-update-ns), snap-update-ns --user-mounts polarr,)
main.go:214: DEBUG: desired mount profile:
main.go:216: DEBUG: /run/user/1000/doc/by-app/snap.polarr /run/user/1000/doc none bind,rw,x-snapd.ignore-missing 0 0
change.go:405: DEBUG: desiredIDs: map[/run/user/1000/doc:true]
change.go:406: DEBUG: reuse: map[]
main.go:225: DEBUG: mount changes needed:
main.go:227: DEBUG: mount (/run/user/1000/doc/by-app/snap.polarr /run/user/1000/doc none bind,rw,x-snapd.ignore-missing 0 0)
main.go:174: DEBUG: performing mount changes:
main.go:177: DEBUG: * mount (/run/user/1000/doc/by-app/snap.polarr /run/user/1000/doc none bind,rw,x-snapd.ignore-missing 0 0)
main.go:219: DEBUG: current mount profile (after applying changes): (none)
DEBUG: snap-update-ns finished successfully
DEBUG: resetting PATH to values in sync with core snap
DEBUG: snappy_udev_init
DEBUG: setup_devices_cgroup
DEBUG: write_string_to_file /sys/fs/cgroup/devices/snap.polarr.polarr/tasks 13432
DEBUG: write_string_to_file /sys/fs/cgroup/devices/snap.polarr.polarr/devices.deny a
DEBUG: run_snappy_app_dev_add: /sys/class/mem/null snap_polarr_polarr
DEBUG: running snap-device-helper add snap_polarr_polarr /sys/class/mem/null 1:3
DEBUG: run_snappy_app_dev_add: /sys/class/mem/full snap_polarr_polarr
DEBUG: running snap-device-helper add snap_polarr_polarr /sys/class/mem/full 1:7
DEBUG: run_snappy_app_dev_add: /sys/class/mem/zero snap_polarr_polarr
DEBUG: running snap-device-helper add snap_polarr_polarr /sys/class/mem/zero 1:5
DEBUG: run_snappy_app_dev_add: /sys/class/mem/random snap_polarr_polarr
DEBUG: running snap-device-helper add snap_polarr_polarr /sys/class/mem/random 1:8
DEBUG: run_snappy_app_dev_add: /sys/class/mem/urandom snap_polarr_polarr
DEBUG: running snap-device-helper add snap_polarr_polarr /sys/class/mem/urandom 1:9
DEBUG: run_snappy_app_dev_add: /sys/class/tty/tty snap_polarr_polarr
DEBUG: running snap-device-helper add snap_polarr_polarr /sys/class/tty/tty 5:0
DEBUG: run_snappy_app_dev_add: /sys/class/tty/console snap_polarr_polarr
DEBUG: running snap-device-helper add snap_polarr_polarr /sys/class/tty/console 5:1
DEBUG: run_snappy_app_dev_add: /sys/class/tty/ptmx snap_polarr_polarr
DEBUG: running snap-device-helper add snap_polarr_polarr /sys/class/tty/ptmx 5:2
DEBUG: running snap-device-helper add snap_polarr_polarr /dev/pts/slaves 136:*
DEBUG: running snap-device-helper add snap_polarr_polarr /dev/pts/slaves 137:*
DEBUG: running snap-device-helper add snap_polarr_polarr /dev/pts/slaves 138:*
DEBUG: running snap-device-helper add snap_polarr_polarr /dev/pts/slaves 139:*
DEBUG: running snap-device-helper add snap_polarr_polarr /dev/pts/slaves 140:*
DEBUG: running snap-device-helper add snap_polarr_polarr /dev/pts/slaves 141:*
DEBUG: running snap-device-helper add snap_polarr_polarr /dev/pts/slaves 142:*
DEBUG: running snap-device-helper add snap_polarr_polarr /dev/pts/slaves 143:*
DEBUG: running snap-device-helper add snap_polarr_polarr /dev/uhid 10:239
DEBUG: run_snappy_app_dev_add: /sys/devices/pci0000:00/0000:00:02.0/drm/card0 snap_polarr_polarr
DEBUG: running snap-device-helper add snap_polarr_polarr /sys/devices/pci0000:00/0000:00:02.0/drm/card0 226:0
DEBUG: run_snappy_app_dev_add: /sys/devices/pci0000:00/0000:00:02.0/drm/card0/card0-DP-1 snap_polarr_polarr
DEBUG: running snap-device-helper add snap_polarr_polarr /sys/devices/pci0000:00/0000:00:02.0/drm/card0/card0-DP-1 0:0
DEBUG: run_snappy_app_dev_add: /sys/devices/pci0000:00/0000:00:02.0/drm/card0/card0-DP-2 snap_polarr_polarr
DEBUG: running snap-device-helper add snap_polarr_polarr /sys/devices/pci0000:00/0000:00:02.0/drm/card0/card0-DP-2 0:0
DEBUG: run_snappy_app_dev_add: /sys/devices/pci0000:00/0000:00:02.0/drm/card0/card0-HDMI-A-1 snap_polarr_polarr
DEBUG: running snap-device-helper add snap_polarr_polarr /sys/devices/pci0000:00/0000:00:02.0/drm/card0/card0-HDMI-A-1 0:0
DEBUG: run_snappy_app_dev_add: /sys/devices/pci0000:00/0000:00:02.0/drm/card0/card0-HDMI-A-2 snap_polarr_polarr
DEBUG: running snap-device-helper add snap_polarr_polarr /sys/devices/pci0000:00/0000:00:02.0/drm/card0/card0-HDMI-A-2 0:0
DEBUG: run_snappy_app_dev_add: /sys/devices/pci0000:00/0000:00:02.0/drm/card0/card0-eDP-1 snap_polarr_polarr
DEBUG: running snap-device-helper add snap_polarr_polarr /sys/devices/pci0000:00/0000:00:02.0/drm/card0/card0-eDP-1 0:0
DEBUG: creating user data directory: /home/polarruser/snap/polarr/8
DEBUG: requesting changing of apparmor profile on next exec to snap.polarr.polarr
DEBUG: loading bpf program for security tag snap.polarr.polarr
DEBUG: read 6144 bytes from /var/lib/snapd/seccomp/bpf//snap.polarr.polarr.bin
DEBUG: raising privileges to load seccomp profile
DEBUG: dropping privileges after loading seccomp profile
DEBUG: execv(/usr/lib/snapd/snap-exec, /usr/lib/snapd/snap-exec…)
DEBUG: argv[1] = polarr

glxinfo -B

name of display: :0
display: :0 screen: 0
direct rendering: Yes
Extended renderer info (GLX_MESA_query_renderer):
Vendor: Intel Open Source Technology Center (0x8086)
Device: Mesa DRI Intel® Haswell (0xa1e)
Version: 18.0.5
Accelerated: yes
Video memory: 1536MB
Unified memory: yes
Preferred profile: core (0x1)
Max core profile version: 4.5
Max compat profile version: 3.0
Max GLES1 profile version: 1.1
Max GLES[23] profile version: 3.1
OpenGL vendor string: Intel Open Source Technology Center
OpenGL renderer string: Mesa DRI Intel® Haswell
OpenGL core profile version string: 4.5 (Core Profile) Mesa 18.0.5
OpenGL core profile shading language version string: 4.50
OpenGL core profile context flags: (none)
OpenGL core profile profile mask: core profile

OpenGL version string: 3.0 Mesa 18.0.5
OpenGL shading language version string: 1.30
OpenGL context flags: (none)

OpenGL ES profile version string: OpenGL ES 3.1 Mesa 18.0.5
OpenGL ES profile shading language version string: OpenGL ES GLSL ES 3.10


#10

Well, since you’re using nvidia with mesa YMMV. Frankly I’m surprised you even get to a graphical desktop with 1070. With my GT1030, depending on the versions kernel and mesa, it’s either black screen, hard lockup or really slow UI.

AFAICT, snapd does not do anything special for non-nvidia hardware. WIth nvidia though, the relevant code paths are only active iff the nvidia kernel module is already loaded, which we have an explicit check for. Otherwise it’s like any other GPU.


#11

I think the issue here is that whatever launcher electron-builder uses does not get the order of either LD_LIBRARY_PATH= or LIBGL_DRIVERS_PATH= entries right

if nvidia drivers are used “/var/lib/snapd/lib/gl” needs to be prepended, not appended to LD_LIBRARY_PATH so the nvidia shipped libGL is always found first, else the nvidia driver will be used with the mesa libGL.

alternatively it could also do a full switch and only put one or the other into the *_PATH vars like:

# Tell libGL where to find the drivers
if [ -e "/var/lib/snapd/lib/gl/xorg/nvidia_drv.so" ]; then
    # special case for nvidia
    export LIBGL_DRIVERS_PATH=/var/lib/snapd/lib/gl/xorg
    export LD_LIBRARY_PATH=/var/lib/snapd/lib/gl:$LD_LIBRARY_PATH
else
    export LIBGL_DRIVERS_PATH=$SNAP/usr/lib/$ARCH/dri
fi

#12

That looks promising, though I don’t know how to get that script run with electron-builder? Currently I have

    "snap": {
      "confinement": "strict",
      "summary": "Powerful and easy-to-use photo editor.",
      "grade": "stable",
      "stagePackages": [
        "default",
        "libcanberra-gtk-module",
        "libgail-3-0",
        "libatk1.0-0",
        "unity-gtk-module-common"
      ],
      "plugs": [
        "default",
        "removable-media"
      ],
      "environment": {
        "LD_LIBRARY_PATH": "$SNAP/usr/lib:$SNAP/usr/lib/x86_64-linux-gnu:$SNAP/app/resources/node_modules/sharp/vendor/lib"
      }
    }

I tried daniel’s suggestion to add libglu1-mesa to stagePackages on Ubuntu and it broke the app on Ubuntu so I didn’t try running it on Debian. If I were to add libglu1-mesa to stagePackages (knowing it would break systems with Nvidia drivers) and run it in a VBox with just mesa, would that be a valid test of whether your suggestion would work?


#13

This won’t work. Things that are wrong with this approach:

  • nvidia_drv.so is a part of proprietary driver, so LIBGL_DRIVERS_PATH has no effect, it’s not MESA (besides MESA drivers are under $(libdir)/dri and follow a specific naming pattern foo_dri.so)
  • we do not pick up the Xorg drivers from the host system, i.e. /var/lib/snapd/lib/gl/xorg does not exist in snap mount namespace

My guess is that polarr snap should use whatever wrappers are generated by snapcraft. Those already prepend SNAP_LIBRARY_PATH to LD_LIBRARY_PATH, while snap-confine populates that with right pieces of nvidia userland. If nvidia driver isn’t loaded, none of the nvidia libraries are present in SNAP_LIBRARY_PATH and thus libGL.so from MESA will be picked up by the linker.

IMO the snap should deliver the libGL mesa package and relevant drivers if it needs to use any of GL functionality. A potential issue I see is that it uses mesa from 16.04 which is old and may or may not work properly with recent hardware.


#14

I did try adding libglu1-mesa to the stagePackages and tested in VirtualBox and the app also didn’t get a WebGL context in the guest machine (Chromium gets WebGL). I tried appending all the paths from ldconfig -v to LD_LIBRARY_PATH and that didn’t do anything for me. I tried setting app.commandLine.appendSwitch("ignore-gpu-blacklist", "true") at the beginning of the main entry point and that didn’t work. I tried setting BrowserWindow.webPreferences.offscreen: true and that made everything white. I tried some combinations of the above but not all of them.

Next I tried adding "libgl1-mesa-glx" back to stagePackages and that made the app work in the VirtualBox guest, but it broke the app on my computer with the Nvidia graphics:

libGL error: No matching fbConfigs or visuals found
libGL error: failed to load driver: swrast
libGL error: No matching fbConfigs or visuals found
libGL error: failed to load driver: swrast
Unhandled rejection: TypeError: Cannot set property 'HALF_FLOAT_OES' of null

I didn’t want to ship 2 versions, so I kept messing with @ogra’s suggestion and ended up with this that works both in my VirtualBox guest and my host:

      "environment": {
        "LD_LIBRARY_PATH": "/var/lib/snapd/lib/gl:$SNAP/usr/lib:$SNAP/usr/lib/x86_64-linux-gnu:$SNAP/app/resources/node_modules/sharp/vendor/lib"
      }

It’s weird that I have to prepend /var/lib/snapd/lib/gl to LD_LIBRARY_PATH, but my guess is that I incurred the wrath of the library path by setting it from a non-default value in order to get raw image files to load. I do get some weird visual artifacts when I drag the app window on top of gnome-terminal, but those glitches existed in the previous version snap as well. Being able to upgrade from snap core 16 to snap core 18 would probably solve some of the graphical weirdness but my understanding is that snap core 18 doesn’t really exist yet.

Thanks for the help here, it’s unlikely that I would have figured out how to make the Polarr snap work on Intel graphics without it.


#15

When you override default environment variables for paths it’s advisable to add their old value onto the end:

export LD_LIBRARY_PATH="$SNAP/my/override/example:$LD_LIBRARY_PATH"

Snapcraft builds default values for LD_LIBRARY_PATH that you will need to either reimplement (hard), or just reuse as above (easy).