Linux desktop: optimized release build, installer, Linux gaps

Build: split Dart debug info out of libapp.so (13.96 -> 11.27 MB, symbols
kept in the cache) and fix icon tree shaking, which Flutter 3.44's Linux
CMake backend silently disables by quoting the define; the build image
patches its SDK copy (MaterialIcons 1.6 MB -> 25 KB). Impeller cannot be
enabled in a Linux release build and was slower in a profile-build bench.

Install: `./install --linux --install` installs the bundle into
<prefix>/lib/app-linux with com.pipelines.app.desktop (the GTK/Wayland
app id), its icon and a ~/.local/bin/pipelines-app link, through
scripts/install-linux-app.sh.

Linux gaps: notifications through the freedesktop daemon; HTML artifacts
explain the missing web view instead of throwing; no Share for files;
a GTK clipboard reader for pasting files and screenshots (Ctrl+V and
Omarchy's Super+V); GTK header bar only on GNOME; window icon.

Bench: native fixture frame log, wheel/mark steps and
tool/perf/linux_desktop_bench.py (private Xvfb); results in
app/notes/linux-desktop-optimized.md.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-12-03 12:54:18 +00:00
parent c4de1de27b
commit 8138cdc3d9
26 changed files with 722 additions and 60 deletions
+28
View File
@@ -0,0 +1,28 @@
// Frame report for native fixture builds (the Linux desktop bench,
// tool/perf/linux_desktop_bench.py), the native twin of frame_log.dart.
//
// With `perf=1` in FIXTURE_QUERY it prints every frame's Flutter timings as
// `PERF_FRAME <build us> <raster us> <total us>`, and the first rasterised
// frame as `PERF_FIRST_FRAME_EPOCH <ms since the Unix epoch>`, which the
// bench subtracts from its own launch time. Without the flag nothing is
// installed.
import 'package:flutter/widgets.dart';
void installNativeFrameLog(Map<String, String> params) {
if (params['perf'] != '1') return;
final binding = WidgetsFlutterBinding.ensureInitialized();
binding.addTimingsCallback((timings) {
for (final timing in timings) {
// ignore: avoid_print
print(
'PERF_FRAME ${timing.buildDuration.inMicroseconds} '
'${timing.rasterDuration.inMicroseconds} '
'${timing.totalSpan.inMicroseconds}',
);
}
});
binding.waitUntilFirstFrameRasterized.then((_) {
// ignore: avoid_print
print('PERF_FIRST_FRAME_EPOCH ${DateTime.now().millisecondsSinceEpoch}');
});
}
+102
View File
@@ -0,0 +1,102 @@
#!/usr/bin/env python3
"""Startup and chat-scroll bench for the Linux desktop build of the full-app
fixture, the native counterpart of interaction_bench.mjs's `startup` and
`desktop: scroll a rich chat` scenarios.
Build the fixture as a Linux bundle (release, or profile for engine switches):
docker run ... pipelines-app-build linux --target tool/search_selection_probe_entry.dart
then:
python3 tool/perf/linux_desktop_bench.py --bundle <bundle dir> [--repeat 5]
[--switch enable-impeller=true] # profile builds only
Each run starts the bundle on a private Xvfb display (never the desktop
session) with an isolated HOME and its own D-Bus session, with FIXTURE_QUERY
`perf=1` (tool/perf/frame_log_native.dart). Startup is launch to the first
rasterised frame; the scroll is 30 mouse-wheel notches of -240 px over the
open rich chat. Xvfb has no GPU: Mesa's llvmpipe rasterises on the CPU, as
headless Chrome without --gpu does, so compare builds and engines with each
other rather than predicting a desktop with a GPU.
"""
import argparse
import json
import os
from pathlib import Path
import shutil
import statistics
import subprocess
import tempfile
import time
QUERY = ("route=/chat/perf-chat-0&chats=2&header=1&rich=1&perf=1"
"&do=wait:500;tap:Later;wait:800;mark:scroll;wheel:860,400,-240,30;wait:1500;mark:end")
def run_once(bundle, display, switches, timeout, extra_env=()):
root = Path(tempfile.mkdtemp(prefix="linux-bench-"))
runtime = root / "run"
runtime.mkdir(mode=0o700)
env = {"HOME": str(root / "home"), "XDG_RUNTIME_DIR": str(runtime), "DISPLAY": f":{display}",
"GDK_BACKEND": "x11", "PATH": "/usr/bin:/bin", "FIXTURE_QUERY": QUERY,
**dict(e.split("=", 1) for e in extra_env)}
if switches:
env["FLUTTER_ENGINE_SWITCHES"] = str(len(switches))
for index, switch in enumerate(switches, 1):
env[f"FLUTTER_ENGINE_SWITCH_{index}"] = switch
xvfb = subprocess.Popen(["Xvfb", f":{display}", "-screen", "0", "1280x800x24", "-nolisten", "tcp"],
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
lines = []
try:
time.sleep(1)
launched = time.time() * 1000
app = subprocess.Popen(["dbus-run-session", "--", str(Path(bundle) / "pipelines-app")], env=env,
stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True,
start_new_session=True)
deadline = time.time() + timeout
try:
for line in app.stdout:
lines.append(line.strip())
if line.startswith("FIXTURE_MARK end") or time.time() > deadline:
break
finally:
os.killpg(app.pid, 15)
app.wait(timeout=10)
finally:
xvfb.terminate()
xvfb.wait(timeout=10)
shutil.rmtree(root, ignore_errors=True)
first = next((int(l.split()[1]) for l in lines if l.startswith("PERF_FIRST_FRAME_EPOCH ")), None)
phase, scroll = None, []
for line in lines:
if line.startswith("FIXTURE_MARK "):
phase = line.split()[1]
elif line.startswith("PERF_FRAME ") and phase == "scroll":
build, raster, total = (int(v) for v in line.split()[1:4])
scroll.append((build, raster, total))
if first is None or not scroll:
raise RuntimeError("the run reported no first frame or no scroll frames:\n" + "\n".join(lines[-20:]))
return {"startupMs": first - launched, "frames": len(scroll),
"buildSumMs": sum(f[0] for f in scroll) / 1000, "buildMaxMs": max(f[0] for f in scroll) / 1000,
"rasterSumMs": sum(f[1] for f in scroll) / 1000, "rasterMaxMs": max(f[1] for f in scroll) / 1000,
"rasterMedianMs": statistics.median(f[1] for f in scroll) / 1000,
"worstFrameMs": max(f[2] for f in scroll) / 1000}
def main():
parser = argparse.ArgumentParser(description=__doc__.splitlines()[0])
parser.add_argument("--bundle", required=True)
parser.add_argument("--repeat", type=int, default=5)
parser.add_argument("--display", type=int, default=97)
parser.add_argument("--switch", action="append", default=[], help="engine switch (profile builds)")
parser.add_argument("--timeout", type=float, default=60)
parser.add_argument("--env", action="append", default=[], help="extra VAR=value for the app")
args = parser.parse_args()
runs = [run_once(args.bundle, args.display, args.switch, args.timeout, args.env) for _ in range(args.repeat)]
median = {key: round(statistics.median(r[key] for r in runs), 1) for key in runs[0]}
print(json.dumps({"bundle": args.bundle, "switches": args.switch, "runs": len(runs), "median": median}, indent=2))
if __name__ == "__main__":
main()