Repository navigation
feat: Linux port - #12
Open
BenAuerDev wants to merge 44 commits into
Open
BenAuerDev wants to merge 44 commits into
BenAuerDev wants to merge 44 commits into
Conversation
Plans App Studio on Linux as agreed with Serverpod: five PRs (app runs, setup works, preview works, packaging, polish), Tuesday as PRs 1–3 plus an AppImage running on Ubuntu and Arch, and CI, releases and auto-updates owned by Serverpod with build scripts delivered from here. Records what already works through the host seam, where Linux falls through to macOS behaviour, the CEF spike findings and the open questions.
The runner calls initCEFProcesses before GTK starts, so CEF's helper processes return instead of booting App Studio again, and hands the view's key events to the preview. The plugin's own script for this patches linux/main.cc, which current Flutter no longer generates. Window title App Studio, 1280x800, minimum 670x600 as on Windows.
App Studio's data goes in $XDG_DATA_HOME/dev.serverpod.appstudio, the folder shared_preferences already uses on Linux. The Windows menu strip is mounted on Linux too, with Quit on Ctrl+Q and no Uninstall until the uninstaller knows Linux. Inter for the UI and fontconfig's monospace, Ctrl in shortcut hints and in the terminal, xdg-open for links, and a linux-x64 platform key.
Only macOS builds ever shipped a private toolchain, so these tests already skipped on Windows; on a Linux host they failed.
feat: Linux PR 1, App Studio builds and starts on Linux
…o install them. Linux's tool set is system packages, Flutter and the Serverpod CLI. git, curl, unzip and xz are probed on PATH; App Studio never runs sudo, so missing ones are a manual step: setup shows the apt, pacman, dnf or zypper command read from /etc/os-release, or the package names for a distro it does not know, with Check again, before anything else is installed.
… instructions put them. Flutter comes from releases_linux.json and its .tar.xz is unpacked with tar. dart install puts the CLI in $XDG_STATE_HOME/Dart/install/bin. PATH lines go in the files Flutter's Linux instructions name: ~/.zshenv (or $ZDOTDIR/.zshenv), ~/.bashrc, or ~/.profile for sh and ksh. A Linux terminal starts a non-login shell, which reads neither of the macOS files.
feat: Linux PR 2, setup installs Flutter and the Serverpod CLI
On Linux CEF runs its own message loop thread, so script results and page events arrived there, while Flutter's Linux embedder only takes method channel responses and calls on the main thread. From CEF's thread they were lost: evaluateJavascript never answered and the preview waited on "Waking Flutter" forever. Responses and events now hop to the main thread with g_main_context_invoke_full, as Windows does with PostMessage. The encoded response is also released after use; it leaked before.
… thread. CEF paints on its own thread on Linux while Flutter reads frames on its render thread and the app closes previews on GTK's. The texture freed each frame with delete instead of delete[] and swapped the buffer while the render thread could still read it; it now copies each frame under a GMutex into a buffer only the render thread touches, and hands Flutter a transparent pixel until the first frame arrives. The renderer map in common/webview_plugin.cc is guarded by a Linux-only lock, and a paint holds its own reference to the renderer, so a close can no longer free a texture mid-frame. A renderer's last reference may now go on CEF's thread, so its texture is unregistered and freed on GTK's. The texture used to leak; it is freed now. macOS and Windows keep their behaviour: the lock compiles to nothing there.
…gure time. target_modifier/modify_target.sh patched linux/main.cc and linux/my_application.cc, which current Flutter no longer generates: they live in linux/runner/. It patched nothing, printed a warning on every configure, and left every CEF helper booting a full copy of the app. App Studio wires initCEFProcesses and the key handlers into its runner by hand since PR 1, so the plugin's CMake no longer runs the script.
…n Linux. Without a root_cache_path CEF used ~/.config/cef_user_data, one folder and one singleton lock for every CEF app on the machine that also left it unset, so a killed run could block the next start. This is the bug the macOS and Windows ports already fixed. The Linux plugin now exports setCEFRootCachePath, and the runner sets it to $XDG_DATA_HOME/dev.serverpod.appstudio/CEF before CEF starts, inside the data folder App Studio already uses (L5), so uninstall removes it with the rest. A path that is not valid UTF-8 logs a warning and leaves CEF's default.
…focus. With a page focused the plugin sent every key to CEF and reported it handled, so Flutter never saw Ctrl+R, Ctrl+L or any other app shortcut. Ctrl on a character key now goes to App Studio, except Ctrl+A/C/V/X/Y/Z, which stay the page's editing keys, as do Ctrl+Backspace, Ctrl+Enter and the other non-character keys. Keys are classified by their Windows key code, as Chromium does, so this holds on layouts without Latin letters. Modifiers go to both, a shortcut's release follows its press, and keys Flutter puts back unhandled are recognised and not sent to the page a second time. A modifier's own press now carries its own flag: GDK reports the state from before the event, and Flutter web asserted on a Ctrl press without Ctrl down. The xclip paste workaround is gone: it failed silently and xclip is not installed by default.
…gh GTK.
On Wayland a client may only set or read the clipboard while one of its surfaces has keyboard focus. CEF talks to the compositor over its own connection and draws off-screen, so it never has focus: copies stayed inside the page ("No serial found for selection" in CEF's log), and text copied elsewhere never arrived. GTK's window has the focus, so the plugin moves the text across. On Ctrl+C or Ctrl+X it puts the page's selection, which CEF reports through OnTextSelectionChanged, on the clipboard; on Ctrl+V or Shift+Insert it reads the clipboard and inserts the text the way an input method commits it. The page sees typing rather than a paste event, which is what a text field needs; a page that reads paste events, such as one pasting images, gets nothing. Running CEF on X11 through XWayland was tried first: Hyprland does not pass an unfocused X client's clipboard across.
Linux PR 3: the preview works
Chromium keeps the key that encrypts cookies and saved passwords in the desktop's keyring. On a desktop without an unlocked one, such as a fresh Ubuntu 26.04 or one with automatic login, GNOME asked the user to create a "Default keyring" as soon as the preview loaded. CEF now gets password-store=basic on Linux, as macOS already gets use-mock-keychain: the preview shows a local development app and stores nothing that needs the keyring.
Linux PR 3b: no keyring prompt from the preview
Flutter's quit on Linux (quit_application in fl_platform_handler.cc) stops the main loop but leaves the window, and the engine inside, alive: nothing shuts the engine down, and its raster thread may still be drawing the preview's last frame. exit() then ran Mesa's teardown underneath it, and App Studio crashed on quit after its own teardown had already stopped the server. Flutter only quits once Dart has answered the exit request, so that teardown is done by the time the main loop returns: main() now flushes stdio and ends the process with _exit. Measured by opening a project and closing the window the way the close button does: 2 crashes in 8 quits before, none in 12 after.
…Linux. Dart answered every exit request after the first with "exit" at once, so on Linux a second one during the teardown quit App Studio before the server was stopped: the close button twice, or File → Quit (Ctrl+Q) and then the close button, which reach Dart by different routes. A repeat request on Linux now waits for the running teardown, at most 15 s, since the CEF quit inside it has no timeout of its own and a hung teardown must not make the app impossible to close. macOS and Windows keep answering a repeat at once; Windows already drops a second close in window_close.dart.
Linux PR 1b: quit without crashing, and without cutting the teardown short
tool/linux/build_appimage.sh makes a release build and packs it into dist/linux/AppStudio-<version>-x86_64.AppImage; make appimage runs it. The bundle keeps its layout under usr/lib/appstudio, so the executable finds its libraries through its RPATH and CEF's helpers start from inside the mounted image. Libraries that still carry a symbol table are stripped, which takes libcef.so from 1.37 GB to 256 MB and the AppImage to 138 MB. The icons come from the Windows .ico, whose frames run edge to edge as Linux icons do. The desktop entry's StartupWMClass is the GTK application id, so docks match the window to it, and its X-AppImage-Version is the one version the AppImage carries: VERSION is unset for appimagetool, which would otherwise stamp whatever the caller's environment holds. The release build drops Widgetbook's url_launcher from the generated plugin files, so the script restores them, as build_release.ps1 does on Windows. Before packing, it checks the tools it needs, the bundle's files, and that the bundle was built from pubspec's version, so SKIP_BUILD cannot ship an old build under a new number. appimagetool and its runtime are pinned and checked against their sha256. With APPIMAGE_UPDATE_INFO set, the AppImage carries zsync update information for AppImageUpdate and Gear Lever, and a .zsync is written beside it; APPIMAGE_FILE_URL puts an absolute download URL in the .zsync, so each release can keep its own path. Hosting both is Serverpod's. Running it needs glibc 2.38 or newer (Ubuntu 24.04 and later).
Launcher search matches the start of each word of a desktop entry's Name, so "app" and "studio" found App Studio but "appstudio" found nothing (seen in GNOME on Ubuntu). The desktop entry now carries Keywords for its one-word name and for Serverpod, Flutter and Dart.
Linux PR 4: an AppImage, built with make appimage
… it. On a system that cannot load App Studio, with a glibc or C++ runtime too old or a system library such as GTK missing, the executable failed before any of App Studio ran, so a double-click did nothing visible and only a terminal showed the loader's error. AppRun now asks the loader first (LD_TRACE_LOADED_OBJECTS, which lists what the app needs without running it) and, when something is missing, says what: a newer Linux with glibc 2.38 or later and distributions that have it, no glibc at all, or the libraries to install. The message goes to the terminal and, when there is a display, to a window through zenity, kdialog or notify-send, falling through to the next tool when one cannot show it. The glibc version is read from the build, as the highest GLIBC_ version any ELF file in the bundle references, and a build that needs another version stops until the distributions the message names are updated. Tested with the packed AppImage on Debian 11 (glibc 2.31), Alpine (no glibc) and Ubuntu 24.04.
Without Gear Lever or AppImageLauncher, the AppImage never appears in the app menu and the dock shows a generic icon. The plan has App Studio offer to add itself on first start: it moves the file to ~/AppImages/AppStudio-x86_64.AppImage, copies its icons and writes a desktop entry with a marker, so Remove from Applications (and the uninstall in PR 5) takes away only what App Studio wrote. It asks only when no tool has added it yet. When someone starts a second copy, it offers to replace the copy in the app menu with a newer one, or to open the newer one instead of an older one. The spec also records the AppRun check that is already built, text for the download page, and that updates from inside the app come later.
Without Gear Lever, AppImageLauncher or appimaged, a downloaded AppImage never appears in the app menu and the dock shows a generic icon. App Studio now asks once it reaches the start page, as long as no desktop entry names it. Add moves the file to ~/AppImages/AppStudio-x86_64.AppImage, copies the icons and writes dev.serverpod.appstudio.desktop with an X-AppStudio-AddedBy marker and the version it added. Help gets Add to Applications or Remove from Applications, whichever applies. Remove deletes only an entry carrying the marker and leaves the file where it is. Starting another copy while App Studio's own entry exists asks whether to Replace it with a newer build, or offers to Open the newer one from an older build. The same build says nothing. After a failed Replace the entry no longer records a version, so a later download is never offered in place of a newer copy.
macOS updates through Sparkle and Windows through WinSparkle; Linux had no updater, so Check for Updates stayed greyed out. App Studio now does the same job in Dart, with the same Sparkle appcast and the same rules: Help -> Check for Updates, and a daily check (on by default, over the start page only, so it never interrupts a running server). An update downloads beside the AppImage, is checked against its length and an Ed25519 signature, and is renamed over the running file. The running copy stays mounted, quits through the usual teardown, and the new file starts once it is gone. App Studio's menu entry records the new version. Feeds and downloads must be https; plain http is accepted only to this machine or a private address, for a local test feed. The feed URL and public key live in linux/release.json, as on Windows, and are empty until a feed exists: such a build reports updates as unavailable. build_appimage.sh compiles them in, and tool/linux/appcast.sh signs an AppImage and adds it to a feed. Adds cryptography for the signature check and makes xml a direct dependency.
Add copies the icons into ~/.local/share/icons/hicolor/<size>/apps, but GTK rescans a theme, and judges an icon cache stale, only when the hicolor folder itself changes. When those folders were already there (any app that puts icons there, or an earlier Remove), the app menu showed a generic icon until the next login. Add and Remove now add a file to the hicolor folder and take it away again before rebuilding an icon cache, as xdg-icon-resource does. Remove no longer creates the folder where there was none.
Linux PR 4b: the AppImage adds itself to the app menu and updates itself
…er lines. The feed is not signed, only the file is, and its shortVersionString was written into App Studio's desktop entry as it came. A version carrying a line break (&serverpod#10; in the XML) would have added a line of its own, such as an Exec= key, which the signature never covered. An item whose version is not letters, digits, '.', '+' and '-' (64 at most) is now left out of the feed, and every value written to the entry has its line breaks, tabs and carriage returns escaped as the Desktop Entry spec says.
The hourly update check only asked whether a project was open, so once a check was due its offer could open over the New Project screen or the Settings dialog, both routes over the start page. Its Install button quits App Studio, which would have left serverpod create or a tool install half-done. The start page now counts as showing only when nothing is pushed over it. The Add to Applications question reads the same check.
Cancel was only read when the next chunk arrived. With a server that had stopped sending, the dialog waited out the 60 s timeout and then reported "The download stopped answering." instead of going back. UpdateCancellation now completes a future when it is cancelled, and the download stops waiting on the connection or the next chunk as soon as it does. One listener serves the whole download. A response that arrives after Cancel has its body let go, so its connection does not stay open. The new tests stall the server, once while connecting and once mid-download, and fail on the old code.
When Add to Applications cannot take the AppImage out of its folder (a root-owned one such as /opt), it copies it to ~/AppImages and leaves the original. The updater still preferred $APPIMAGE because the original existed, so the download failed in a folder it cannot write to. The updater now replaces the app menu's copy whenever App Studio's entry names it and records the running build, and the started file otherwise. A second copy of the same build, run from ~/Downloads say, therefore updates the menu's copy and restarts that one. A download an interrupted run left behind is cleared beside both.
Closing a webview keeps its entry in m_renderers with a null renderer. The Ctrl+F12 loop that opens DevTools dereferenced every entry, so the shortcut crashed after any preview had been closed. It now skips null entries, as getAnyBrowserFocused already does.
build_appimage.sh accepted a release config with only one of appcastUrl and eddsaPublicKey, said "In-app updates off" and built an AppImage that would never check for updates. It now refuses unless both or neither are set. appcast.sh only works on Linux (it runs the AppImage to read its version, and uses GNU stat and base64), but on macOS it failed with an exec format error. It now says so up front, and its header lists OpenSSL 3, python3 and GNU coreutils.
"There is nothing to add on another OS" passed no executable, so the running file was not inside APPDIR and the status was unavailable even on Linux. It now runs in the same AppImage environment as the Linux tests, so only the OS check can make it unavailable. The line break test for a recorded version now also reads the version back, so it pins the escaping in both directions.
CLAUDE.md (AGENTS.md) gets a Linux section: the dev machine, where things are, quitting and the _exit() it ends with, CEF, keys and the GTK clipboard bridge, the AppImage, Add to Applications and in-app updates. Its first line no longer calls App Studio a macOS IDE. specs/linux_port.md keeps the plan agreed with Serverpod and says where the build differs: the AppImage updates itself and .deb and .rpm follow only if asked, how quitting was fixed, the clipboard and its limits, the 670x600 minimum, and the checklist ticked for what is done. specs/linux_appimage.md marks parts A and B done and records the review fixes: which copy an update replaces, why nothing in the feed is trusted beyond the file's signature, no offer over New Project or Settings, and Cancel.
Linux PR 4c: fixes from a full review of the port
Started from a terminal with `&`, App Studio froze before showing its window. To find Flutter it runs the user's login shell as an interactive shell, and an interactive bash opens the terminal it shares with App Studio to set up job control. As a background job, the terminal answers with SIGTTIN and stops the whole process group, App Studio included, so not even the probe's own timeout fired: "Stopped (tty input)". On Linux the shell now runs in a session of its own with no terminal (ProcessStartMode.detachedWithStdio). Its output still comes back through the pipes, and the kill after the answer still reaches it. macOS keeps the normal start.
Started from a folder App Studio may not take the file out of (a root-owned /opt, a read-only file system, or a shared sticky folder such as /tmp holding someone else's file), Add copies the AppImage to ~/AppImages and the original stays. The question still said the file moves. The Add and Replace questions now say a copy goes to ~/AppImages and the original stays. Whether that is the case is read from the folder's permissions with test -w, -x and, for a sticky folder, -O, so nothing is written there before the user answers.
Linux PR 4d: start from a terminal, and say when Add copies
BenAuerDev
marked this pull request as ready for review
November 28, 2026 16:53
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Brings App Studio to Linux. The plan is in specs/linux_port.md; the AppImage's own parts (Add to Applications, in-app updates, the message on systems that cannot run it) are in specs/linux_appimage.md.
Four PRs, each merged into linux/port on my fork after I've tested it, so this is the one PR to review. The fifth (polish) follows as its own PR after this one.
CI/release runs on your infra, so that stays with you; I deliver the build scripts and the in-app updater.
make appimagebuilds the AppImage (tool/linux/build_appimage.sh), andtool/linux/appcast.shsigns one and adds it to an update feed. What your release workflows need for Linux is in a separate brief I sent along. CLAUDE.md now has a Linux section.macOS and Windows behaviour stays unchanged; every Linux change is a Linux-only branch or file (one exception, a null check in the webview_cef plugin, see open question 4).
Tested on
Not tested yet: an X11 session on an Intel GPU.
Getting it running
Polish
~/AppImages, app menu entry with icon), and Help has Add/Remove.linux/release.jsonnames your feed and key.&) no longer freezes App Studio, and the Add question says when the AppImage is copied rather than moved.Not done yet: the release pipeline (yours), PR 5.
Known open points
Found in the review or in testing, not fixed yet:
Open questions
asdl.serverpod.dev/appcast/linux/…) only follows the macOS/Windows pattern; your call.packages/webview_cef/common/, all behind__linux__or compiled to nothing elsewhere, except a null check in the Ctrl+F12 loop (Blue cloud-hero loading backdrop; open streams no longer hold the status spinner #8) that applies on every platform. I have no Mac and CI does not build macOS natively, so could one of you run a quickmake build_debugand check the preview?testfails inserverpod create, because the name collides with the template'stestdependency. Neither the CLI nor App Studio's form refuses names of the template's dependencies, on any platform.Recordings
The first run on Ubuntu 24.04 (bare metal), long waits sped up: download, system packages, Flutter and the Serverpod CLI, Add to Applications, an update from 0.4.1 to 0.4.2, the icon in the app menu, a new project, the app in the preview, a restart, closing.
app-studio-linux-ubuntu-24.04.mp4
The first run on Fedora 45 with KDE Plasma (bare metal), long waits sped up: setup without a system-packages step, Add to Applications, a new project, the app in the preview, Hot Restart, closing.
app-studio-linux-fedora-45-kde.mp4