Snaps built with the latest flutter version fail to render. The observed error:
Failed to compile fragment shader: 0:2(1): error: No precision specified in this scope for type `vec2'
Failed to link program: error: linking with uncompiled/unspecialized shader
The error happens when trying to run the flutterdemo, see this reported issue (built with the flutter snap), but also when I try to run my own flutter application (built with flutter downloaded from git).
I need the latest flutter version for my flutter application to build…
Where to I start debugging this? I suspect some library is missing in mesa-core22, but I don’t know how to figure out whether this is true.
One issue here is that I cannot run the snap with snap run --shell, because the application is wrapped by bin/graphics-core22-wrapper and bin/wayland-launch, and I don’t actually enter the shell when trying to run with --shell.
I have seen the bug report on the snap (which has a workaround). I’ve not had time to try reproducing or investigating.
But if this isn’t an issue with the snap, but with Flutter (" also when I try to run my own flutter application (built with flutter downloaded from git)"), I doubt I can help
still happens with Flutter 3.24, blocking me from updating my app to the next version.
I tried to build with the master channel but that threw me into dependency hell once again.
Then I tried to migrate to core24 which now seems to be possible as I’m using the gnome extension and that is now available under core24 (wasn’t some months ago iirc) but that also didn’t help
Update: With Flutter 3.24.1 my app FluffyChat can render again but … the colors are inverted now. I have not installed the handy_window package (which caused inverted colors for me in the past) so… no idea what causes this now
edit: Migrating from core22 to core24 fixed the problem for me so this seems to be fixed now when using core24.
Do you know if there was any bug report done anywhere for inverted colors with flutter 3.24.1 on Ubuntu Core 22?
I am still facing this problem and prefer not to bump Ubuntu Core version (I tried and after fixing some build issues I am facing a crash as soon as the application starts; maybe you can share me your changes from core22 to core24?)
@krille I actually cannot reproduce what you report. When I use core24 as a base I still get inverted colors. Here is the snapcraft for core24 for the flutter demo:
Click to see code
name: iot-example-graphical-snap # you probably want to 'snapcraft register <name>'
version: git # just for humans, typically '1.2+git' or '1.3.2'
summary: IoT example using Flutter # 79 char long summary
description: IoT example using Flutter
confinement: strict
compression: lzo
grade: stable
base: core24
apps:
iot-example-graphical-snap:
command-chain: &_command-chain
- bin/gpu-2404-wrapper
- bin/wayland-launch
command: &_command bin/flutterdemo
plugs: &_plugs
- opengl
- wayland
environment: &_environment
XDG_DATA_HOME: $SNAP_USER_DATA
XDG_DATA_DIRS: $SNAP/usr/share
GDK_GL: gles
daemon:
daemon: simple
restart-delay: 3s
restart-condition: always
command-chain: *_command-chain
command: *_command
plugs: *_plugs
environment: *_environment
# This is one of four snippets that relate to providing the userspace graphics needed by your application.
# You can treat this as "magic" so long as you don't need to make changes.
# On the Mir website there's a lot more detail on [the graphics-core22 Snap interface](https://mir-server.io/docs/the-graphics-core22-snap-interface) and it's use.
plugs:
gpu-2404:
interface: content
target: $SNAP/gpu-2404
default-provider: mesa-2404
environment:
# Other, generally useful environment settings...
# XDG config
XDG_CACHE_HOME: $SNAP_USER_COMMON/.cache
XDG_CONFIG_HOME: $SNAP_USER_DATA/.config
XDG_CONFIG_DIRS: $SNAP/etc/xdg
XDG_DATA_DIRS: $SNAP/usr/local/share:$SNAP/usr/share
# XKB config
XKB_CONFIG_ROOT: $SNAP/usr/share/X11/xkb
# The `layout` ensures that files can be found by applications where they are expected by the toolkit or application.
layout:
/usr/share/libdrm:
bind: $SNAP/gpu-2404/libdrm
/usr/share/drirc.d:
symlink: $SNAP/gpu-2404/drirc.d
# Other, generally useful paths
/usr/share/fonts:
bind: $SNAP/usr/share/fonts
/usr/share/icons:
bind: $SNAP/usr/share/icons
/usr/share/sounds:
bind: $SNAP/usr/share/sounds
/etc/fonts:
bind: $SNAP/etc/fonts
# GTK
/usr/lib/$CRAFT_ARCH_TRIPLET/gdk-pixbuf-2.0:
bind: $SNAP/usr/lib/$CRAFT_ARCH_TRIPLET/gdk-pixbuf-2.0
/usr/lib/${CRAFT_ARCH_TRIPLET}/gtk-3.0:
bind: $SNAP/usr/lib/${CRAFT_ARCH_TRIPLET}/gtk-3.0
/usr/share/mime:
bind: $SNAP/usr/share/mime
/etc/gtk-3.0:
bind: $SNAP/etc/gtk-3.0
parts:
flutterdemo:
plugin: nil
source: flutterdemo
build-snaps:
- flutter/latest/stable
build-environment:
- C_INCLUDE_PATH: /snap/flutter/current/usr/include
- LD_LIBRARY_PATH: ${LD_LIBRARY_PATH:+$LD_LIBRARY_PATH:}/snap/flutter/current/usr/lib/$CRAFT_ARCH_TRIPLET
- PKG_CONFIG_PATH: ${PKG_CONFIG_PATH:+$PKG_CONFIG_PATH:}/snap/flutter/current/usr/lib/$CRAFT_ARCH_TRIPLET/pkgconfig
- XDG_DATA_DIRS: /snap/flutter/current/usr/share${XDG_DATA_DIRS:+:$XDG_DATA_DIRS}
override-build: |
set -eux
mkdir -p $CRAFT_PART_INSTALL/bin/lib
flutter channel stable
flutter upgrade
flutter config --enable-linux-desktop
flutter doctor
flutter pub get
flutter build linux --release -v
cp -r build/linux/*/release/bundle/* $CRAFT_PART_INSTALL/bin/
build-packages:
- libmpv-dev
stage-packages:
# Flutter applications are based on GTK and libgl
- libgtk-3-0
- libgl1
# gsettings, pixbuf and immodules are not needed by all snaps,
# but they are so common a requirement include them here
gsettings+pixbuf+immodules:
plugin: nil
build-packages:
- libgdk-pixbuf2.0-0
- librsvg2-common
- shared-mime-info
- libgtk-3-0
override-build: |
craftctl default
# Update mime database
update-mime-database ${CRAFT_PART_INSTALL}/usr/share/mime
# build immodules cache
mkdir -p ${CRAFT_PART_INSTALL}/usr/lib/${CRAFT_ARCH_TRIPLET}/gtk-3.0t64/3.0.0/
/usr/lib/${CRAFT_ARCH_TRIPLET}/libgtk-3-0t64/gtk-query-immodules-3.0 > ${CRAFT_PART_INSTALL}/usr/lib/${CRAFT_ARCH_TRIPLET}/gtk-3.0t64/3.0.0/immodules.cache
stage-packages:
- librsvg2-common
- gsettings-desktop-schemas
- libglib2.0-bin
override-prime: |
craftctl default
# Compile the gsettings schemas
/usr/lib/${CRAFT_ARCH_TRIPLET}/glib-2.0/glib-compile-schemas "$CRAFT_PRIME/usr/share/glib-2.0/schemas"
# Index the pixbuf loaders
LOADERS_PATH=$(echo ${CRAFT_PRIME}/usr/lib/${CRAFT_ARCH_TRIPLET}/gdk-pixbuf-2.0/*/loaders)
QUERY_LOADERS=/usr/lib/${CRAFT_ARCH_TRIPLET}/gdk-pixbuf-2.0/gdk-pixbuf-query-loaders
GDK_PIXBUF_MODULEDIR=${LOADERS_PATH} ${QUERY_LOADERS} > ${LOADERS_PATH}/../loaders.cache
sed s!$CRAFT_PRIME!!g --in-place ${LOADERS_PATH}/../loaders.cache
# Some utility scripts for setting up the Wayland environment
setup:
plugin: dump
source: wayland-launch
override-build: |
# The plugs needed to run Wayland. (wayland-launch checks them, setup.sh connects them)
# You may add further plugs here if you want these options
PLUGS="opengl wayland gpu-2404"
sed --in-place "s/%PLUGS%/$PLUGS/g" $CRAFT_PART_BUILD/bin/wayland-launch
sed --in-place "s/%PLUGS%/$PLUGS/g" $CRAFT_PART_BUILD/bin/setup.sh
craftctl default
stage-packages:
- inotify-tools
graphics-core22:
after:
- flutterdemo
- gsettings+pixbuf+immodules
- setup
source: https://github.com/MirServer/graphics-core22.git
plugin: dump
override-prime: |
craftctl default
${CRAFT_PART_SRC}/bin/gpu-2404-cleanup
prime:
- bin/gpu-2404-wrapper
Does your snapcraft.yaml look similar? Any significant differences that I could try?