Flutter

about the nightmare of cross platform development targetting Linux mobile

Hej, I'm The one with the braid

  • alleged Flutter toucher since 2018
  • working in healthcare IT for a couple of years
  • healthcare be like : [matrix]
  • I use arm btw.
  • @braid:alsace.hair (oops, location leaked)
  • Yes, I'm from France btw.

Flutter, but why ?

  • Decent cross-platform ecosystem
  • Native plugin system
  • Advanced mobile UI optimization
  • Fancy animation
  • Fast rendering
  • No JS, no XML

Linux (mobile) as a Flutter target

  • Adopting existing software
  • Less development effort
  • Biiiig players into it

Keys in targetting mobile

  • Runtime issues
  • Debugging
  • Redistribution

Flutter redistribution

  • Building the Flutter toolchain
  • Packaging (let's check this first)

The Flutter tool

A nightmare for packaging

Downloading Linux x64 Dart SDK from Flutter engine f40e976bedff57e69e1b3d89a7c2a3c617a03dad...
# [...]
Building flutter tool...
Resolving dependencies... (1.8s)
Got dependencies.
Downloading Material fonts...                                      296ms
Downloading Gradle Wrapper...                                       18ms
Downloading android-arm-profile/linux-x64 tools...                 237ms
Downloading android-arm-release/linux-x64 tools...                 213ms
Downloading android-arm64-profile/linux-x64 tools...               247ms
Downloading android-arm64-release/linux-x64 tools...               217ms
Downloading android-x64-profile/linux-x64 tools...                 238ms
Downloading android-x64-release/linux-x64 tools...                 215ms
Downloading android-x86 tools...                                 1,807ms
Downloading android-x64 tools...                                 1,919ms
Downloading android-arm tools...                                 1,750ms
Downloading android-arm-profile tools...                           607ms
Downloading android-arm-release tools...                           416ms
Downloading android-arm64 tools...                                  6.9s
Downloading android-arm64-profile tools...                         732ms
Downloading android-arm64-release tools...                         482ms
Downloading android-x64-profile tools...                           679ms
Downloading android-x64-release tools...                           489ms
Downloading android-x86-jit-release tools...                       852ms
Downloading Web SDK...                                              5.4s
Downloading package sky_engine...                                  116ms
Downloading flutter_patched_sdk tools...                           326ms
Downloading flutter_patched_sdk_product tools...                   326ms
Downloading linux-x64 tools...                                      3.9s
Downloading linux-x64-debug/linux-x64-flutter-gtk tools...       1,998ms
Downloading linux-x64-profile/linux-x64-flutter-gtk tools...        845ms
Downloading linux-x64-release/linux-x64-flutter-gtk tools...        713ms
Downloading linux-x64/font-subset tools...                         164ms

Likely to some user directory ?

Even better : to the installation directory - hardcoded location

Step by step

  • get Flutter tool sources
  • downloads Dart SDK snapshot
  • builds Flutter tool snapshot
  • downloads Flutter engine
  • download platform dependencies
  • fonts (Material Icons, Roboto)
  • android
    • profile, jit and release toolchain
    • all per architecture
  • web SDK
    • skia
  • Flutter SDK tools
  • platform compiler
    • Windows / Linux / macOS
    • font renderer
    • platform embedding
      • (e.g. GTK on Linux)

Platform dependencies

Origin of these downloads

  • GitHub releases ?
  • Some package registry ?
  • Even better : Chromium CI !

This is not very open source of you !

Back to topic :
How to package this bloat ?

Packaging these downloads

  • From Chromium CI
    • pre-cache at package time
    • patch : user directory - rejected in upstream
  • Even better - let's build them ourselves

Building Flutter

Special thanks to lauren n. liberda !

Issues on FLOSS builds

  • Vendored packages
  • Chromium CI ✨
  • Unhappy musl and *BSD noises

Toolchain for Flutter builds

  • gclient solution + generate ninja
  • blobs downloaded from Chromium CI

Alpine's patch set

Waaaaiiiit ?

What's about upstream work ?

Mostly rejected.

Getting Flutter to build FOSS

  1. Buildroot patches
    • use local libraries
  2. Engine
    • make build e.g. with musl
  3. Flutter tool
    • use local artifacts, engine and Dart SDK

Cross-compiling

The moment I wished Flutter was written in go.

But wait a second ?

$ flutter build linux --target-platform linux-arm64 \
		--target-sysroot ~/flutter-aarch64-sysroot
> Cross-build from Linux x64 host to Linux arm64 target is
> not currently supported.
docker run --privileged --rm tonistiigi/binfmt --install all
> [...]

docker run -ti --rm --platform linux/arm64 -v "$(pwd):/build" -w /build \
	registry.gitlab.com/theonewiththebraid/flutter-dockerimages:3.16.8 \
    flutter build linux --target-platform linux-arm64

> [...]

file build/linux/arm64/release/bundle/test_project
> build/linux/arm64/release/bundle/test_project: ELF 64-bit LSB pie executa
ble, ARM aarch64, version 1 (SYSV), dynamically linked, interpreter /lib/ld
-linux-aarch64.so.1, BuildID[sha1]=759d1251987321485b7f93787a32312871e7c618
, for GNU/Linux 3.7.0, not stripped

Flutter cross-compiling

  • No built-in way
  • Compiler toolchain goes QEMU
  • Standalone aarch64 build server
  • custom-devices
    • flutter-elinux or flutter-pi
    • no built-in way again

 

-> Dev environment on target device way easier

You should hopefully see an image^w

Notable runtime issues

  • Linux embedder considers touch as mouse
  • Scaling
  • gtk_header_bar
  • Multi window

But there

is the momentum.

Let's get Linux

mobile ready as a

cross-platform target !

All Rosahaj emojis based on the works of heatherhorns, CC BY-SA.

<- these slides

Flutter on Linux mobile

By The one with the braid

Flutter on Linux mobile

Flutter - about the nightmare of cross platform development targetting Linux mobile

  • 380