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
+8
View File
@@ -24,10 +24,18 @@ COPY --chmod=0755 build.sh /usr/local/bin/pipelines-app-build
WORKDIR /tmp
FROM web AS linux
# Flutter's CMake backend passes `-dTreeShakeIcons="true"` with the quotes
# kept (no shell parses them), so `flutter build linux` never tree-shakes the
# icon fonts and ships the full 1.6 MB MaterialIcons font. Pass the plain value
# in this image's copy; the grep fails the build if the line ever changes.
RUN apt-get update \
&& apt-get install -y --no-install-recommends clang cmake ninja-build pkg-config libgtk-3-dev libstdc++-12-dev liblzma-dev \
&& rm -rf /var/lib/apt/lists/* \
&& flutter precache --linux \
&& backend=/opt/flutter/packages/flutter_tools/bin/tool_backend.dart \
&& grep -q "'-dTreeShakeIcons=\"\$treeShakeIcons\"'," "$backend" \
&& sed -i "s/'-dTreeShakeIcons=\"\$treeShakeIcons\"',/'-dTreeShakeIcons=\$treeShakeIcons',/" "$backend" \
&& grep -q "'-dTreeShakeIcons=\$treeShakeIcons'," "$backend" \
&& chmod -R a+rwX /opt/flutter /home/builder
FROM web AS android
+5 -1
View File
@@ -42,8 +42,12 @@ PROPERTIES
/tmp/apk-certificates.txt > /out/signing-certificate-sha256.txt
;;
linux)
flutter build linux --release "$@"
# Dart symbols go beside the bundle, not into libapp.so (about 18%
# smaller); `flutter symbolize -i <trace> -d .debug-info/app.linux-x64.symbols`
# reads a release stack trace. Icon fonts are tree-shaken (see Dockerfile).
flutter build linux --release --split-debug-info=/tmp/debug-info "$@"
cp -a build/linux/x64/release/bundle/. /out/
cp -a /tmp/debug-info /out/.debug-info
;;
*)
echo "unknown build: $kind" >&2
@@ -1,18 +1,25 @@
import 'package:file_picker/file_picker.dart';
import 'package:flutter/foundation.dart';
import 'package:share_plus/share_plus.dart';
import 'artifact_file.dart';
import 'artifact_transfer.dart';
/// Phones and desktops: Download asks where to save the exact bytes (the
/// system "Save as"), Share hands the named file to the share sheet.
/// system "Save as"; on Linux the desktop portal's file chooser), Share hands
/// the named file to the share sheet. Linux has no share sheet for files
/// (share_plus throws), so Share is not offered there.
bool get artifactDownloadSupported => true;
bool get artifactShareSupported => true;
bool get artifactShareSupported =>
defaultTargetPlatform != TargetPlatform.linux;
String get artifactDownloadUnsupportedMessage => '';
String get artifactShareUnsupportedMessage => '';
String get artifactShareUnsupportedMessage =>
defaultTargetPlatform == TargetPlatform.linux
? 'Sharing files is not available on Linux; use Download.'
: '';
Future<ArtifactTransferResult> saveArtifactFile(ArtifactFile file) async {
try {
@@ -12,6 +12,18 @@ import 'artifact_external_open.dart';
/// the full-screen view needs no zoom buttons.
const bool inertHtmlZoomButtons = false;
/// The webview plugin has Android, iOS and macOS implementations only; the
/// Linux and Windows apps say so instead of failing to create a web view.
bool inertHtmlViewSupported([TargetPlatform? platform]) => switch (platform ??
defaultTargetPlatform) {
TargetPlatform.android || TargetPlatform.iOS || TargetPlatform.macOS => true,
_ => false,
};
const String inertHtmlUnsupportedMessage =
'This app cannot preview HTML on this platform: it has no web view. '
'Download the file to open it in a browser.';
/// A web view with JavaScript disabled that refuses every navigation after the
/// recorded document itself loads.
///
@@ -99,6 +111,7 @@ class _InertHtmlViewState extends State<InertHtmlView> {
@override
void didUpdateWidget(covariant InertHtmlView oldWidget) {
super.didUpdateWidget(oldWidget);
if (!inertHtmlViewSupported()) return;
if (oldWidget.html != widget.html || oldWidget.dark != widget.dark) {
_loaded = false;
_controller.loadHtmlString(_document);
@@ -106,8 +119,20 @@ class _InertHtmlViewState extends State<InertHtmlView> {
}
@override
Widget build(BuildContext context) => WebViewWidget(
controller: _controller,
gestureRecognizers: widget.interactive ? _allGestures : _inlineGestures,
);
Widget build(BuildContext context) => inertHtmlViewSupported()
? WebViewWidget(
controller: _controller,
gestureRecognizers: widget.interactive
? _allGestures
: _inlineGestures,
)
: const Center(
child: Padding(
padding: EdgeInsets.all(16),
child: Text(
inertHtmlUnsupportedMessage,
textAlign: TextAlign.center,
),
),
);
}
@@ -1,5 +1,6 @@
import 'dart:io';
import 'package:flutter/foundation.dart';
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
import 'notification_bridge.dart';
@@ -7,8 +8,10 @@ import 'notification_models.dart';
/// System notifications from the native app: Android's notification shade (when
/// its background notification service is off), iOS's and macOS's
/// notification centre. [close] removes a delivered one by its tag. The permission is cached so [environment] stays synchronous; it
/// is refreshed when the bridge starts and after every request.
/// notification centre, and the Linux desktop's notification daemon (the
/// freedesktop D-Bus service: mako, dunst, GNOME Shell, Plasma). [close]
/// removes a delivered one by its tag. The permission is cached so
/// [environment] stays synchronous; it is refreshed when the bridge starts and after every request.
class NativeNotificationBridge implements NotificationBridge {
NativeNotificationBridge() {
_ready = _start();
@@ -40,13 +43,27 @@ class NativeNotificationBridge implements NotificationBridge {
requestSoundPermission: false,
);
/// The bundle's icon (installed by the Linux runner's CMake beside
/// `flutter_assets`), so a portable, uninstalled bundle has one too.
static final _linuxSettings = LinuxInitializationSettings(
defaultActionName: 'Open',
defaultIcon: FilePathLinuxIcon(
'${File(Platform.resolvedExecutable).parent.path}/data/app_icon.png',
),
);
/// The Linux app, by its target platform rather than the host's, so a test
/// on a Linux machine still sees the (Android) test platform.
static bool get _linux => defaultTargetPlatform == TargetPlatform.linux;
Future<void> _start() async {
try {
await _plugin.initialize(
settings: const InitializationSettings(
settings: InitializationSettings(
android: AndroidInitializationSettings('@mipmap/ic_launcher'),
iOS: _darwin,
macOS: _darwin,
linux: _linuxSettings,
),
onDidReceiveNotificationResponse: (response) {
final id = response.id;
@@ -63,7 +80,10 @@ class NativeNotificationBridge implements NotificationBridge {
}
Future<void> _refresh() async {
if (Platform.isAndroid) {
if (_linux) {
// A notification daemon asks no permission.
_permission = 'granted';
} else if (Platform.isAndroid) {
final enabled = await _plugin
.resolvePlatformSpecificImplementation<
AndroidFlutterLocalNotificationsPlugin
@@ -82,7 +102,8 @@ class NativeNotificationBridge implements NotificationBridge {
@override
NotificationEnvironment environment() => NotificationEnvironment(
supported: Platform.isAndroid || Platform.isIOS || Platform.isMacOS,
supported:
Platform.isAndroid || Platform.isIOS || Platform.isMacOS || _linux,
// A native app needs no secure origin.
secureContext: true,
permission: _permission,
@@ -7,7 +7,9 @@ import 'package:flutter/widgets.dart';
import 'chat_attachment_picker.dart';
import 'chat_clipboard_paste.dart';
/// The macOS Runner's pasteboard reader (macos/Runner/MainFlutterWindow.swift).
/// The desktop Runners' clipboard reader: macOS's
/// (macos/Runner/MainFlutterWindow.swift) and Linux's
/// (linux/runner/clipboard_files.cc).
const MethodChannel chatClipboardFilesChannel = MethodChannel(
'pipelines/clipboard_files',
);
@@ -17,7 +19,7 @@ const MethodChannel chatClipboardFilesChannel = MethodChannel(
///
/// Flutter's own [Clipboard] carries text only, so a native host reads the
/// pasteboard through the Runner. Each subscription watches for the platform
/// paste shortcut (Cmd+V). When its composer may take the paste it consumes
/// paste shortcut (Cmd+V on macOS, Ctrl+V on Linux). When its composer may take the paste it consumes
/// the key, asks the Runner for the pasteboard's files (Finder file URLs, else
/// a copied or screenshot image) and hands them over; a pasteboard without
/// files pastes its text into the composer instead, so the consumed key never
@@ -46,13 +48,14 @@ ChatClipboardPaste nativeChatClipboardPaste({
);
/// Whether the held modifiers make V the host's paste shortcut: Cmd alone on
/// macOS.
bool chatIsNativePasteShortcut() {
/// macOS; Ctrl on Linux, also with Super held (Omarchy's universal Super+V
/// sends Ctrl+V while Super is down).
bool chatIsNativePasteShortcut([TargetPlatform? platform]) {
final keys = HardwareKeyboard.instance;
return keys.isMetaPressed &&
!keys.isControlPressed &&
!keys.isAltPressed &&
!keys.isShiftPressed;
if (keys.isAltPressed || keys.isShiftPressed) return false;
return (platform ?? defaultTargetPlatform) == TargetPlatform.linux
? keys.isControlPressed
: keys.isMetaPressed && !keys.isControlPressed;
}
Future<void> _readPasteboard(
@@ -121,4 +124,5 @@ String chatNothingToPasteMessage(List<String> types) => types.isEmpty
/// Whether [platform] has a Runner that answers [chatClipboardFilesChannel].
bool chatHostReadsClipboardFiles(TargetPlatform platform) =>
!kIsWeb && platform == TargetPlatform.macOS;
!kIsWeb &&
(platform == TargetPlatform.macOS || platform == TargetPlatform.linux);
@@ -5,7 +5,7 @@ import 'chat_clipboard_paste_native.dart';
/// Native clipboard-file paste.
///
/// macOS reads the pasteboard through its Runner
/// macOS and Linux read the clipboard through their Runners
/// ([nativeChatClipboardPaste]). Other native hosts have no pasteboard reader
/// yet: they report that missing capability rather than pretending no paste
/// happened, and the composer keeps the host field's own text paste.
+5
View File
@@ -97,6 +97,11 @@ install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}"
install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}"
COMPONENT Runtime)
# The window icon (runner/my_application.cc); the installer also puts it in
# the icon theme for the desktop entry.
install(FILES "runner/resources/app_icon.png" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}"
COMPONENT Runtime)
install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
COMPONENT Runtime)
+1
View File
@@ -9,6 +9,7 @@ project(runner LANGUAGES CXX)
add_executable(${BINARY_NAME}
"main.cc"
"my_application.cc"
"clipboard_files.cc"
"${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc"
)
+135
View File
@@ -0,0 +1,135 @@
#include "clipboard_files.h"
#include <gio/gio.h>
#include <gtk/gtk.h>
namespace {
FlMethodChannel* channel = nullptr;
// The MIME type of [path] from its name and contents, or "".
gchar* mime_of(const gchar* path, const guchar* data, gsize length) {
gboolean uncertain = FALSE;
g_autofree gchar* type =
g_content_type_guess(path, data, MIN(length, (gsize)4096), &uncertain);
gchar* mime = type == nullptr ? nullptr : g_content_type_get_mime_type(type);
return mime == nullptr ? g_strdup("") : mime;
}
FlValue* file_entry(const gchar* name, const gchar* mime, const guchar* data,
gsize length) {
FlValue* entry = fl_value_new_map();
fl_value_set_string_take(entry, "name", fl_value_new_string(name));
fl_value_set_string_take(entry, "mime", fl_value_new_string(mime));
fl_value_set_string_take(entry, "bytes",
fl_value_new_uint8_list(data, length));
return entry;
}
// Adds each copied local file; folders and unreadable files become errors.
gboolean add_uris(GtkClipboard* clipboard, FlValue* files, FlValue* errors) {
g_auto(GStrv) uris = gtk_clipboard_wait_for_uris(clipboard);
if (uris == nullptr || uris[0] == nullptr) return FALSE;
gboolean any = FALSE;
for (gchar** uri = uris; *uri != nullptr; uri++) {
g_autofree gchar* path = g_filename_from_uri(*uri, nullptr, nullptr);
if (path == nullptr) continue;
any = TRUE;
g_autofree gchar* name = g_path_get_basename(path);
if (g_file_test(path, G_FILE_TEST_IS_DIR)) {
g_autofree gchar* message =
g_strdup_printf("%s is a folder; paste its files instead.", name);
fl_value_append_take(errors, fl_value_new_string(message));
continue;
}
g_autofree gchar* contents = nullptr;
gsize length = 0;
g_autoptr(GError) error = nullptr;
if (!g_file_get_contents(path, &contents, &length, &error)) {
g_autofree gchar* message =
g_strdup_printf("Could not read %s: %s", name, error->message);
fl_value_append_take(errors, fl_value_new_string(message));
continue;
}
g_autofree gchar* mime =
mime_of(path, reinterpret_cast<const guchar*>(contents), length);
fl_value_append_take(
files, file_entry(name, mime,
reinterpret_cast<const guchar*>(contents), length));
}
return any;
}
// The clipboard's own PNG (a screenshot tool's), else any image GTK can read
// converted to PNG.
void add_image(GtkClipboard* clipboard, FlValue* files) {
g_autoptr(GtkSelectionData) png = gtk_clipboard_wait_for_contents(
clipboard, gdk_atom_intern_static_string("image/png"));
if (png != nullptr && gtk_selection_data_get_length(png) > 0) {
fl_value_append_take(
files, file_entry("", "image/png", gtk_selection_data_get_data(png),
gtk_selection_data_get_length(png)));
return;
}
g_autoptr(GdkPixbuf) image = gtk_clipboard_wait_for_image(clipboard);
if (image == nullptr) return;
g_autofree gchar* buffer = nullptr;
gsize length = 0;
if (gdk_pixbuf_save_to_buffer(image, &buffer, &length, "png", nullptr,
nullptr)) {
fl_value_append_take(
files, file_entry("", "image/png",
reinterpret_cast<const guchar*>(buffer), length));
}
}
FlValue* read_clipboard() {
GtkClipboard* clipboard = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD);
FlValue* files = fl_value_new_list();
FlValue* errors = fl_value_new_list();
FlValue* types = fl_value_new_list();
GdkAtom* targets = nullptr;
gint count = 0;
if (gtk_clipboard_wait_for_targets(clipboard, &targets, &count)) {
for (gint i = 0; i < count; i++) {
g_autofree gchar* name = gdk_atom_name(targets[i]);
fl_value_append_take(types, fl_value_new_string(name));
}
g_free(targets);
}
if (!add_uris(clipboard, files, errors)) add_image(clipboard, files);
FlValue* reply = fl_value_new_map();
fl_value_set_string_take(reply, "files", files);
fl_value_set_string_take(reply, "errors", errors);
fl_value_set_string_take(reply, "types", types);
return reply;
}
void method_call_cb(FlMethodChannel* channel, FlMethodCall* call,
gpointer user_data) {
g_autoptr(FlMethodResponse) response = nullptr;
if (g_strcmp0(fl_method_call_get_name(call), "read") == 0) {
g_autoptr(FlValue) reply = read_clipboard();
response = FL_METHOD_RESPONSE(fl_method_success_response_new(reply));
} else {
response = FL_METHOD_RESPONSE(fl_method_not_implemented_response_new());
}
g_autoptr(GError) error = nullptr;
if (!fl_method_call_respond(call, response, &error)) {
g_warning("Failed to answer a clipboard read: %s", error->message);
}
}
} // namespace
void clipboard_files_register(FlPluginRegistry* registry) {
g_autoptr(FlPluginRegistrar) registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "ClipboardFiles");
g_autoptr(FlStandardMethodCodec) codec = fl_standard_method_codec_new();
g_clear_object(&channel);
channel = fl_method_channel_new(fl_plugin_registrar_get_messenger(registrar),
"pipelines/clipboard_files",
FL_METHOD_CODEC(codec));
fl_method_channel_set_method_call_handler(channel, method_call_cb, nullptr,
nullptr);
}
+12
View File
@@ -0,0 +1,12 @@
#ifndef RUNNER_CLIPBOARD_FILES_H_
#define RUNNER_CLIPBOARD_FILES_H_
#include <flutter_linux/flutter_linux.h>
// Answers `read` on the `pipelines/clipboard_files` channel with the
// clipboard's files (a file manager's copied URIs), else its image as PNG,
// plus the clipboard's target names; the same reply shape as the macOS
// Runner (lib/features/chat/domain/chat_clipboard_paste_native.dart).
void clipboard_files_register(FlPluginRegistry* registry);
#endif // RUNNER_CLIPBOARD_FILES_H_
+23 -11
View File
@@ -5,6 +5,7 @@
#include <gdk/gdkx.h>
#endif
#include "clipboard_files.h"
#include "flutter/generated_plugin_registrant.h"
struct _MyApplication {
@@ -14,6 +15,18 @@ struct _MyApplication {
G_DEFINE_TYPE(MyApplication, my_application, GTK_TYPE_APPLICATION)
// The bundle's icon (data/app_icon.png beside the executable) for X11 window
// managers and task bars. Wayland compositors take the icon from the desktop
// entry named by the application id instead.
static void set_window_icon(GtkWindow* window) {
g_autofree gchar* executable = g_file_read_link("/proc/self/exe", nullptr);
if (executable == nullptr) return;
g_autofree gchar* directory = g_path_get_dirname(executable);
g_autofree gchar* icon =
g_build_filename(directory, "data", "app_icon.png", nullptr);
gtk_window_set_icon_from_file(window, icon, nullptr);
}
// Called when first Flutter frame received.
static void first_frame_cb(MyApplication* self, FlView* view) {
gtk_widget_show(gtk_widget_get_toplevel(GTK_WIDGET(view)));
@@ -25,21 +38,18 @@ static void my_application_activate(GApplication* application) {
GtkWindow* window =
GTK_WINDOW(gtk_application_window_new(GTK_APPLICATION(application)));
// Use a header bar when running in GNOME as this is the common style used
// by applications and is the setup most users will be using (e.g. Ubuntu
// desktop).
// If running on X and not using GNOME then just use a traditional title bar
// in case the window manager does more exotic layout, e.g. tiling.
// If running on Wayland assume the header bar will work (may need changing
// if future cases occur).
gboolean use_header_bar = TRUE;
// A GTK header bar only on GNOME, whose shell expects client-side title
// bars. Elsewhere (Hyprland, Sway, KDE, any X11 window manager) the window
// takes the compositor's own decorations, or none on a tiling compositor,
// instead of drawing a second title bar inside the tile.
const gchar* desktop = g_getenv("XDG_CURRENT_DESKTOP");
gboolean use_header_bar =
desktop != nullptr && g_strrstr(desktop, "GNOME") != nullptr;
#ifdef GDK_WINDOWING_X11
GdkScreen* screen = gtk_window_get_screen(window);
if (GDK_IS_X11_SCREEN(screen)) {
const gchar* wm_name = gdk_x11_screen_get_window_manager_name(screen);
if (g_strcmp0(wm_name, "GNOME Shell") != 0) {
use_header_bar = FALSE;
}
use_header_bar = g_strcmp0(wm_name, "GNOME Shell") == 0;
}
#endif
if (use_header_bar) {
@@ -51,6 +61,7 @@ static void my_application_activate(GApplication* application) {
} else {
gtk_window_set_title(window, "Pipelines");
}
set_window_icon(window);
gtk_window_set_default_size(window, 1280, 720);
@@ -74,6 +85,7 @@ static void my_application_activate(GApplication* application) {
gtk_widget_realize(GTK_WIDGET(view));
fl_register_plugins(FL_PLUGIN_REGISTRY(view));
clipboard_files_register(FL_PLUGIN_REGISTRY(view));
gtk_widget_grab_focus(GTK_WIDGET(view));
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 72 KiB

+69
View File
@@ -0,0 +1,69 @@
# Linux desktop: optimized build, Linux gaps, bench
Flutter 3.44.6, Docker build image (`app/docker`), tank (Ryzen, RTX 2080 Ti,
Omarchy/Hyprland). Measured 2026-12-03.
## Build flags
- `flutter build linux --release --split-debug-info` (symbols kept in the
build cache as `.debug-info/`, not archived): libapp.so 13.96 MB -> 11.27 MB.
- Icon tree shaking was silently off: Flutter's CMake backend
(`tool_backend.dart`) passes `-dTreeShakeIcons="true"` with literal quotes.
The Linux build image patches its own SDK copy (grep-guarded).
MaterialIcons-Regular.otf 1,645,184 -> 24,952 bytes.
- Bundle 37.1 MiB -> 33.1 MiB; archive 16.1 MB -> 14.3 MB.
- Not used: `--obfuscate` (no speed gain, breaks symbol names in errors);
Impeller (below).
## Impeller
The Linux release engine ignores engine switches (`FLUTTER_ENGINE_SWITCHES`
is read only in debug/profile builds) and `FlDartProject` has no Impeller
setter, so a release Linux build cannot opt in. Measured in a profile build
on Xvfb/llvmpipe (`tool/perf/linux_desktop_bench.py`, 3 runs, medians):
| renderer | startup | scroll frames | raster sum | raster median | worst frame |
|---|---|---|---|---|---|
| Skia (default) | 1553 ms | 31 | 1141 ms | 29.4 ms | 168 ms |
| Impeller GL | 1919 ms | 14 | 1600 ms | 103.5 ms | 302 ms |
Impeller was slower and dropped frames on the CPU rasteriser; no GPU numbers
(see below). Skia stays.
## Linux vs web (same fixture, same 30-notch wheel scroll of a rich chat)
| build | startup / first frame | frames | build sum | build max | raster sum | raster max |
|---|---|---|---|---|---|---|
| Linux release, Xvfb + llvmpipe (CPU), 1280x720 | 1241 ms (process launch) | 43 | 59 ms | 11.0 ms | 1031 ms | 105 ms |
| Web wasm, headless Chromium, no GPU, 1280x800 | 896 ms (navigation) | 57 | 126 ms | 18.3 ms | 2485 ms | 130 ms |
| Web wasm, headless Chromium, GPU, 1280x800 | 278 ms (navigation) | 69 | 128 ms | 10.6 ms | 174 ms | 8.9 ms |
Medians of 5 runs. Build (UI thread) time is GPU-independent: native
~1.4 ms/frame vs web ~1.9-2.2 ms/frame. Raster on the CPU: native 21 ms median
vs web ~44 ms mean. Native startup counts process launch, GTK, engine and
llvmpipe shader setup; the web figure starts at navigation in a running
browser, so the two are not like for like.
No Linux GPU raster or Wayland numbers: nothing here runs a GPU-backed
headless Wayland or X server (no cage/weston; Xvfb is software only), and the
operator's Hyprland session was not used.
## Linux gaps fixed
- Notifications: the bridge reported Linux unsupported; now uses
flutter_local_notifications' D-Bus implementation with the bundle icon.
- HTML artifacts: `WebViewController()` throws on Linux (no webview
implementation); the view now explains and points at Download.
- Share: share_plus throws for files on Linux; Share is no longer offered.
- Clipboard paste of files/screenshots: new GTK reader
(`linux/runner/clipboard_files.cc`) answers `pipelines/clipboard_files`;
Ctrl+V (also Omarchy's Super+V) in the composer. Compiled and contract-
tested in Dart; not exercised against a real clipboard here.
- Window: GTK header bar only on GNOME (no second title bar in a Hyprland
tile); window icon on X11; installer desktop entry `com.pipelines.app.desktop`
= GTK application id = Wayland app id.
Unchanged and already native: url_launcher (xdg-open plugin), file_picker
(xdg-desktop-portal FileChooser), keyboard shortcuts (Ctrl on non-Apple),
terminal (Dart xterm). The session cookie is stored by shared_preferences
(`~/.local/share/com.pipelines.app/shared_preferences.json`) as on the other
native platforms; there is no keyring-backed storage in the app.
@@ -0,0 +1,53 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/features/artifacts/actions/artifact_transfer_io.dart'
as transfer;
import 'package:pipelines_app/features/artifacts/ui/artifact_html_view_native.dart';
final _linux = TargetPlatformVariant.only(TargetPlatform.linux);
/// The Linux app has no web view and no file share sheet: it says so rather
/// than failing to create the web view or throwing from Share.
void main() {
test('only Android, iOS and macOS have the HTML web view', () {
for (final platform in TargetPlatform.values) {
expect(
inertHtmlViewSupported(platform),
platform == TargetPlatform.android ||
platform == TargetPlatform.iOS ||
platform == TargetPlatform.macOS,
reason: '$platform',
);
}
});
testWidgets('an HTML artifact on Linux explains why it is not previewed', (
tester,
) async {
await tester.pumpWidget(
const MaterialApp(
home: Scaffold(body: InertHtmlView(html: '<p>report</p>')),
),
);
expect(find.text(inertHtmlUnsupportedMessage), findsOneWidget);
expect(tester.takeException(), isNull);
// A new document does not reach for a web view either.
await tester.pumpWidget(
const MaterialApp(
home: Scaffold(body: InertHtmlView(html: '<p>next</p>')),
),
);
expect(tester.takeException(), isNull);
}, variant: _linux);
testWidgets('Linux offers Download but not Share', (tester) async {
expect(transfer.artifactDownloadSupported, isTrue);
expect(transfer.artifactShareSupported, isFalse);
expect(transfer.artifactShareUnsupportedMessage, contains('Download'));
}, variant: _linux);
test('other native platforms keep Share', () {
expect(transfer.artifactShareSupported, isTrue);
expect(transfer.artifactShareUnsupportedMessage, isEmpty);
});
}
@@ -4,6 +4,7 @@ import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/features/chat/conversation/chat_composer_bar.dart';
import 'package:pipelines_app/features/chat/conversation/chat_composer_controller.dart';
import 'package:pipelines_app/features/chat/conversation/chat_draft_store.dart';
import 'package:pipelines_app/features/chat/domain/chat_clipboard_paste_native.dart';
import '../../../core/keyboard/browser_keys.dart';
import 'chat_composer_bar_fixtures.dart';
@@ -32,6 +33,12 @@ void main() {
if (call.method == 'Clipboard.hasStrings') return {'value': true};
return null;
});
// The Linux Runner's clipboard reader: no files, so the text is pasted.
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
.setMockMethodCallHandler(
chatClipboardFilesChannel,
(call) async => {'files': const [], 'errors': const []},
);
});
tearDown(() {
@@ -39,6 +46,8 @@ void main() {
gateway.close();
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
.setMockMethodCallHandler(SystemChannels.platform, null);
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
.setMockMethodCallHandler(chatClipboardFilesChannel, null);
});
for (final merged in [false, true]) {
@@ -10,6 +10,7 @@ import 'package:pipelines_app/features/chat/domain/chat_clipboard_paste_native.d
import '../conversation/chat_composer_bar_fixtures.dart';
final _macOS = TargetPlatformVariant.only(TargetPlatform.macOS);
final _linux = TargetPlatformVariant.only(TargetPlatform.linux);
Finder get _field => find.byKey(const Key('chat-composer-field'));
@@ -77,10 +78,10 @@ void main() {
Future<void> done(WidgetTester tester) => tester.pumpWidget(const SizedBox());
test('only the macOS host reads clipboard files natively', () {
test('the macOS and Linux hosts read clipboard files natively', () {
expect(chatHostReadsClipboardFiles(TargetPlatform.macOS), isTrue);
expect(chatHostReadsClipboardFiles(TargetPlatform.linux), isTrue);
for (final platform in [
TargetPlatform.linux,
TargetPlatform.windows,
TargetPlatform.android,
TargetPlatform.iOS,
@@ -228,4 +229,47 @@ void main() {
expect(composer.draft, isEmpty);
await done(tester);
}, variant: _macOS);
testWidgets('Ctrl+V attaches a copied screenshot on Linux', (tester) async {
pasteboard = {
'files': [
{
'name': '',
'mime': 'image/png',
'bytes': Uint8List.fromList([3]),
},
],
'errors': const [],
};
expect(hostChatClipboardPaste.isSupported, isTrue);
await mount(tester);
await tester.showKeyboard(_field);
await tester.pump();
await paste(tester, modifier: LogicalKeyboardKey.controlLeft);
expect(fileReads, 1);
expect(find.text('pasted-1.png'), findsOneWidget);
expect(textReads, 0);
await done(tester);
}, variant: _linux);
testWidgets('Ctrl+V of plain text on Linux pastes it once', (tester) async {
await mount(tester);
await tester.showKeyboard(_field);
await paste(tester, modifier: LogicalKeyboardKey.controlLeft);
expect(fileReads, 1);
expect(composer.draft, 'copied text');
await done(tester);
}, variant: _linux);
testWidgets('the Super key is not the Linux paste shortcut', (tester) async {
await mount(tester);
FocusManager.instance.primaryFocus?.unfocus();
await tester.pump();
await paste(tester);
expect(fileReads, 0);
await done(tester);
}, variant: _linux);
}
@@ -4,6 +4,7 @@ import 'package:flutter/services.dart';
import 'package:flutter/widgets.dart';
import 'package:pipelines_app/application/server_endpoint.dart';
import '../perf/frame_log_native.dart';
import 'fixture_steps.dart';
import 'narrow_view.dart';
@@ -31,8 +32,10 @@ Map<String, String> fixtureParams() {
return raw.isEmpty ? const {} : Uri.splitQueryString(raw);
}
/// The DevTools probes are browser-only.
void installHostProbes(Map<String, String> params) {}
/// The DevTools probes are browser-only; `perf=1` prints frame timings to
/// stdout (tool/perf/frame_log_native.dart).
void installHostProbes(Map<String, String> params) =>
installNativeFrameLog(params);
/// The route goes through [fixtureRouteProvider] instead.
void openFixtureRoute(String route) {}
+24 -1
View File
@@ -9,7 +9,10 @@ import 'package:flutter/services.dart';
/// [script] is `;`-separated steps run after the first frame, 700 ms apart:
/// `wait:<ms>`, `tap:<label>` (a Text, Tooltip, Semantics label or field
/// hint; `tap:<label>#<n>` picks the n-th match), `tapxy:<x>,<y>`,
/// `drag:<x>,<y>,<dx>,<dy>`, `type:<text>` (into the focused field; `\n`
/// `drag:<x>,<y>,<dx>,<dy>`, `wheel:<x>,<y>,<dy>,<count>` (mouse-wheel
/// notches 16 ms apart, as the web interaction bench sends), `mark:<name>`
/// (prints `FIXTURE_MARK <name>`, so a bench can tell its phases apart),
/// `type:<text>` (into the focused field; `\n`
/// is a newline), `orient:landscape|portrait` and `labels` (prints the
/// visible labels with their centres to the device log).
void runFixtureSteps(String script) {
@@ -54,6 +57,12 @@ Future<void> _run(String verb, String value) async {
case 'drag':
final p = value.split(',').map(double.parse).toList();
await _drag(Offset(p[0], p[1]), Offset(p[2], p[3]));
case 'mark':
// ignore: avoid_print
print('FIXTURE_MARK $value');
case 'wheel':
final p = value.split(',').map(double.parse).toList();
await _wheel(Offset(p[0], p[1]), p[2], p[3].toInt());
case 'type':
_type(value.replaceAll(r'\n', '\n'));
case 'orient':
@@ -141,6 +150,20 @@ Future<void> _drag(Offset from, Offset by) async {
);
}
Future<void> _wheel(Offset at, double dy, int count) async {
final binding = GestureBinding.instance;
for (var i = 0; i < count; i++) {
binding.handlePointerEvent(
PointerScrollEvent(
kind: PointerDeviceKind.mouse,
position: at,
scrollDelta: Offset(0, dy),
),
);
await Future<void>.delayed(const Duration(milliseconds: 16));
}
}
void _type(String text) {
EditableTextState? focused;
void visit(Element element) {
+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()