Flutter SNAP app on RP4 with Unable to create a GL context

Hi,

Not sure this is the best place for this query.

I am starting the process of working with flutter and using to build IOT apps to run on Ubuntu Core. I have got the basic code running on the desktop and within a Core20 (with Core18 added), withMir-kiosk. The app works when run on a KVM-QEMU Core20/18 VM. When I build the code for arm64 and load it to a Raspberry Pi 4 with the pi display the app will start, display the application name main window but will not display the flutter context.

The journalctl output on the test RaspberryPi systems is as follows:

-- The job identifier is 44818.
Jul 06 08:08:07 ubuntu sannox-super-cool-app.daemon[20890]: + snapctl get daemon
Jul 06 08:08:07 ubuntu sannox-super-cool-app.daemon[20792]: + [ true = true ]
Jul 06 08:08:07 ubuntu sannox-super-cool-app.daemon[20792]: + exec /snap/sannox-super-cool-app/x2/bin/wayland-launch /snap/sannox-super-cool-app/x2/bin/flutterdemo
Jul 06 08:08:07 ubuntu sannox-super-cool-app.daemon[20792]: + snapctl is-connected wayland
Jul 06 08:08:07 ubuntu sannox-super-cool-app.daemon[20901]: + dirname /run/user/0/snap.sannox-super-cool-app
Jul 06 08:08:07 ubuntu sannox-super-cool-app.daemon[20792]: + real_xdg_runtime_dir=/run/user/0
Jul 06 08:08:07 ubuntu sannox-super-cool-app.daemon[20792]: + real_wayland=/run/user/0/wayland-0
Jul 06 08:08:07 ubuntu sannox-super-cool-app.daemon[20792]: + [ ! -O /run/user/0/wayland-0 ]
Jul 06 08:08:07 ubuntu sannox-super-cool-app.daemon[20792]: + mkdir -p /run/user/0/snap.sannox-super-cool-app -m 700
Jul 06 08:08:07 ubuntu sannox-super-cool-app.daemon[20792]: + ln -sf /run/user/0/wayland-0 /run/user/0/snap.sannox-super-cool-app
Jul 06 08:08:07 ubuntu sannox-super-cool-app.daemon[20792]: + ln -sf /run/user/0/wayland-0.lock /run/user/0/snap.sannox-super-cool-app
Jul 06 08:08:07 ubuntu sannox-super-cool-app.daemon[20792]: + unset DISPLAY
Jul 06 08:08:07 ubuntu sannox-super-cool-app.daemon[20792]: + exec /snap/sannox-super-cool-app/x2/bin/flutterdemo
Jul 06 08:08:08 ubuntu run-daemon[20792]: g_dbus_proxy_new_sync: assertion 'G_IS_DBUS_CONNECTION (connection)' failed
Jul 06 08:08:08 ubuntu audit[20792]: AVC apparmor="DENIED" operation="open" profile="snap.sannox-super-cool-app.daemon" name="/usr/local/share/fonts/" pid=20792 comm="flutterdemo" requested_mas>
Jul 06 08:08:08 ubuntu audit[20792]: AVC apparmor="DENIED" operation="open" profile="snap.sannox-super-cool-app.daemon" name="/usr/local/share/fonts/" pid=20792 comm="flutterdemo" requested_mas>
Jul 06 08:08:08 ubuntu kernel: kauditd_printk_skb: 3 callbacks suppressed
Jul 06 08:08:08 ubuntu kernel: audit: type=1400 audit(1625558888.170:268): apparmor="DENIED" operation="open" profile="snap.sannox-super-cool-app.daemon" name="/usr/local/share/fonts/" pid=2079>
Jul 06 08:08:08 ubuntu kernel: audit: type=1400 audit(1625558888.170:269): apparmor="DENIED" operation="open" profile="snap.sannox-super-cool-app.daemon" name="/usr/local/share/fonts/" pid=2079>
Jul 06 08:08:08 ubuntu kernel: audit: type=1400 audit(1625558888.170:270): apparmor="DENIED" operation="open" profile="snap.sannox-super-cool-app.daemon" name="/usr/local/share/fonts/" pid=2079>
Jul 06 08:08:08 ubuntu audit[20792]: AVC apparmor="DENIED" operation="open" profile="snap.sannox-super-cool-app.daemon" name="/usr/local/share/fonts/" pid=20792 comm="flutterdemo" requested_mas>
Jul 06 08:08:17 ubuntu audit[20792]: AVC apparmor="DENIED" operation="capable" profile="snap.sannox-super-cool-app.daemon" pid=20792 comm="flutterdemo" capability=21  capname="sys_admin"
Jul 06 08:08:17 ubuntu kernel: audit: type=1400 audit(1625558897.162:271): apparmor="DENIED" operation="capable" profile="snap.sannox-super-cool-app.daemon" pid=20792 comm="flutterdemo" capabil>
Jul 06 08:08:17 ubuntu audit[20792]: AVC apparmor="DENIED" operation="capable" profile="snap.sannox-super-cool-app.daemon" pid=20792 comm="flutterdemo" capability=21  capname="sys_admin"
Jul 06 08:08:17 ubuntu kernel: audit: type=1400 audit(1625558897.310:272): apparmor="DENIED" operation="capable" profile="snap.sannox-super-cool-app.daemon" pid=20792 comm="flutterdemo" capabil>
Jul 06 08:08:17 ubuntu flutterdemo[20792]: Failed to start Flutter renderer: Unable to create a GL context
Jul 06 08:08:30 ubuntu sudo[20909]: jimham57 : TTY=pts/0 ; PWD=/home/jimham57 ; USER=root ; COMMAND=/usr/bin/journalctl -xe
Jul 06 08:08:30 ubuntu sudo[20909]: pam_unix(sudo:session): session opened for user root by jimham57(uid=0)```

The error appears to be related to:

> Failed to start Flutter renderer: Unable to create a GL context

The example I am using as a base comes from this example:

> https://medium.com/nerd-for-tech/running-flutter-apps-on-ubuntu-core-31453d4fed2a

YAML is as follows:

'''name: sannox-super-cool-app
version: 0.1.0
summary: Super Cool App
description: Super Cool App that does everything!
confinement: strict
base: core18
grade: stable
architectures:
  - build-on: [ amd64 ]
  - build-on: [ arm64 ]

apps:
  daemon:
    daemon: simple
    restart-condition: always
    command-chain:
      - bin/run-daemon
      - bin/wayland-launch
    command: bin/flutterdemo
    extensions: [flutter-master] # Where "master" defines which Flutter channel to use for the build

  super-cool-app:
    command-chain:
      - bin/wayland-launch
    command: flutterdemo
    extensions: [flutter-master] # Where "master" defines which Flutter channel to use for the build

parts:
  super-cool-app:
    source: .
    plugin: flutter
    flutter-target: lib/main.dart # The main entry-point file of the application

  mir-kiosk-snap-launch:
    plugin: dump
    source: https://github.com/MirServer/mir-kiosk-snap-launch.git
    override-build:  $SNAPCRAFT_PART_BUILD/build-with-plugs.sh opengl pulseaudio wayland
    stage-packages:
      - inotify-tools

  assets:
    plugin: nil
    stage-packages:
    - dmz-cursor-theme
    - fonts-dejavu
    - fonts-freefont-ttf
    - fonts-ubuntu

layout:
  /usr/share/fonts:
    bind: $SNAP/usr/share/fonts
  /etc/fonts:
    bind: $SNAP/etc/fonts
  /usr/share/icons:
    bind: $SNAP/usr/share/icons'''

Any ideas on where to look for the error source?

I have also built the glmark2 / wayland snap example and this works fine on the Raspberry Pi with the same arm64 Core environment.