Repository navigation
Description
Context
On the mobile targets, every Go change under nsgo dev rebuilds, reinstalls and relaunches the whole app (main at 30a5b8b):
- Android (
androidSession,cmd/nsgo/android.go:360):buildAndroidAPKpacks a complete APK (android.go:378:classes.dex,lib/<abi>/libnsgo.so, every resource underassets/, the icon, signed), thenadb install -r(:392), thenam start -S(:400), which stops the process. - iOS simulator (
iosSession,cmd/nsgo/ios.go:246):buildIOSAppbuilds the whole bundle (:252), thensimctl install(:274), thensimctl launch --terminate-running-process(:278).
A Go change only changes one file of all that: the Go binary (libnsgo.so on Android, the executable in the .app on iOS). Packaging, signing and installing a full app on each save multiplies the restart cost that #658 measures on the desktop, where only the binary is rebuilt. I have not timed the mobile loop separately.
Why it matters
iOS and Android are where an NSGo app looks and behaves most differently from the desktop it is written on, so they are where a developer most needs a short loop. Installing takes seconds on its own, before the app starts, and grows with the app's resources.
Proposal
After the first install of a dev session, replace only the Go binary:
- Android: the Go side is not a library the app loads but an executable the runtime starts:
NsgoViewrunslibnsgo.sofromnativeLibraryDirwith aProcessBuilder(internal/platform/android/java/dev/oneo/nsgo/NsgoView.java:643-644) and talks to it over its stdin and stdout (NsgoEngine.java). WithtargetSdkVersion34 (internal/platform/android/runtime/AndroidManifest.xml:15), Android does not let an appexecfiles in its own writable storage (apps targeting API 29 or later), so a new binary cannot be pushed beside the installed one; only an install writesnativeLibraryDir. What the two-process design allows instead is an opt-in dev mode in which the Go process runs on the development machine and speaks the same protocol to the device's runtime over a socketadbforwards, in place of the pipe. A Go change then rebuilds and restarts a host process and reconnects: nothing is packaged or installed, and the Activity, its window and the Java side stay as they are, which is nsgo dev: a Go change closes the app's window and opens a new one, losing its place on screen (tiling, Split View) and the page it was on #658's "keep the window" for free on Android. The cost is fidelity: the Go code runs as the host'sGOOS, so_android.gocode and whatever Go does directly with files, the network or the system behave as on the host. It suits UI work; platform code still needs the full install, which stays the default. - iOS simulator: the installed app's container is on the Mac (
xcrun simctl get_app_container <udid> <id>), sonsgo devcan write the new executable into it, sign it ad hoc as the simulator requires, and relaunch, skippingsimctl installunless something besides the executable changed. - Physical devices need a signed reinstall and stay as they are.
Acceptance
- In the opt-in mode, on an Android device or emulator, a Go-only change under
nsgo devruns the new code withoutadb install, and the Activity is not restarted. - In the iOS simulator, a Go-only change restarts the app without
simctl install. - A change to resources, the icon, the manifest or
nsgo.yamlstill reinstalls. - Release builds (
nsgo build) are unchanged.
- Platforms: Android, iOS simulator (
nsgo dev) - NSGo: main at 30a5b8b (2026-11-18)
- Development machine: macOS 27.2 (Apple M4 Pro), Go 1.27.3
Activity
houko commentedon Nov 18, 2026
Corrected the Android part of the proposal. It first suggested pushing a new
libnsgo.sointo the app's private storage and loading it from there, butlibnsgo.sois an executable thatNsgoViewstarts withProcessBuilder(NsgoView.java:643-644), and an app targeting API 29+ (targetSdkVersion34 here) cannotexecfiles in its own writable storage, so that would not run. The proposal now uses the two-process design instead: an opt-in dev mode in which the Go process runs on the development machine and talks to the device's runtime over anadb-forwarded socket, which also keeps the Activity and its window across Go changes (#658). The iOS simulator part is unchanged.houko commentedon Nov 20, 2026
I audited the current mobile dev sessions. Android still rebuilds/signs/installs an APK on every build, and iOS simulator still installs the full app bundle. The proposed Android host-process mode changes execution fidelity and needs a new socket protocol, while simulator executable replacement needs signing/container handling and resource-change invalidation. This is a broad toolchain feature rather than a safe local fix, so I left the issue open without a partial implementation.