Introducing a new way to review your PRs.

Read the announcement

crmne / spotifast

Spotify, native and fast. One lightweight Rust app for your whole library, local playback, and Spotify Connect on Linux, macOS, and Windows.

View on GitHub

19 documents · Updated Nov 18, 2026

docs / application-entrypoints

Executable entrypoints and startup diagnostics

Spotifast has one desktop executable and one shared application crate. The executable classifies the launch, prepares the process environment, selects the running-instance role, and then hands a long-lived application state to the native window shell. Its startup path also makes failures visible through logs, panic records, native dialogs, and focused integration tests.

Entry point model

Crate boundary

The Rust package builds the spotifast library and the spotifast executable. The executable entrypoint in src/spotifast.rs is intentionally small: it delegates to entrypoint::run, while the library exposes the application systems that the executable and diagnostics use. This boundary keeps process startup separate from the application state described in application runtime.

References: Cargo.toml• L1-19 src/spotifast.rs• L1-9 src/lib.rs• L1-69

Launch roles

Every process launch first decides which role it must perform. A normal launch becomes the running desktop application, a control launch becomes a short-lived client of that application, an update launch becomes an update helper, and a MilkDrop child launch becomes a separate visualizer process when that feature is enabled.

The command-line interface also accepts a Spotify link, playback and device commands, verbosity, hidden startup, and demo-only capture controls. These inputs are classified before normal application state is created, so helper and client processes do not create competing logs, windows, services, or profiles.

References: src/entrypoint.rs• L6-102 src/entrypoint.rs• L104-180 src/entrypoint.rs• L354-402

Startup sequence

The startup sequence transforms process arguments into either an early exit or a configured native application. The main path follows this order:

flowchart TD
    A[Process starts] --> B[Intercept update helper arguments]
    B --> C{MilkDrop child?}
    C -->|yes| D[Run visualizer child and exit]
    C -->|no| E[Parse launch arguments]
    E --> F{Control command?}
    F -->|yes| G[Send request to running instance and exit]
    F -->|no| H[Parse optional Spotify link]
    H --> I[Claim the single-instance role]
    I -->|existing instance| J[Surface or hand over link and exit]
    I -->|new instance| K[Discover paths and start diagnostics]
    K --> L[Build application state]
    L --> M[Create native window shell]
    M --> N[Run frames and persist state on exit]

Early launch handling

The update helper runs before argument parsing and before application setup. This lets an older updater restart the new binary with update-specific arguments, while an apply-update launch can install the update and exit without touching the user's profile or startup log.

The executable then handles the optional MilkDrop child before the normal command-line parser. A child is only a visualizer window, so it must not claim the main instance or initialize the main application's state.

References: src/entrypoint.rs• L354-370 tests/update_launch.rs• L1-64

Instance selection

A normal launch claims one per-user running-instance slot. If another copy owns the slot, the new process sends a request to that copy and exits instead of creating a second Spotify Connect device, tray item, or media-control service. A Spotify link asks the existing copy to open the link, while a hidden launch leaves that copy hidden.

Once the process owns the slot, the guard remains part of the application's lifetime. Remote commands enter the application's action path, and read commands use published snapshots rather than direct access to application state. The related application state orchestration page describes how that state continues after startup.

References: src/entrypoint.rs• L386-429 src/single_instance.rs• L1-25 src/single_instance.rs• L198-247

Path preparation

After instance selection, the process chooses the folders for configuration, durable state, and caches. Installed copies use the user's standard folders. Portable Windows copies use their own data folder and keep their window state and instance scope separate from installed copies. Demo runs use an isolated folder so sample data cannot change the real profile.

The process creates the three main folders before it starts the application. If folder creation fails, startup continues when possible and records the failure in the log. The chosen paths also determine where the current-run log, panic log, settings, session state, and window state are found.

References: src/entrypoint.rs• L372-385 src/entrypoint.rs• L440-473 src/paths.rs• L1-7 src/paths.rs• L37-109 src/paths.rs• L259-264

Application handoff

Runtime construction

The entrypoint loads settings, applies launch-only values such as the device name, and creates app::App with options for sign-in restore, media controls, tray behavior, and login startup. The application constructor restores session-facing state and starts the backend and desktop services that must outlive any one window.

The entrypoint attaches the remote-control guard, update receipt, update error, link, and demo actions before opening the window. This makes startup requests part of the same state flow as actions received after the first frame.

References: src/entrypoint.rs• L482-551 src/app.rs• L294-317 src/app.rs• L1124-1181 src/app.rs• L1554-1560

Window handoff

The shell owns the current native window while the application state remains available for later windows. It attaches fonts, themes, image loaders, and platform window services each time a window is created. When the window closes, the shell returns to its headless runtime so tray, media, and playback behavior can continue.

The first window may be the main window or the Winamp mini player. Main-window geometry belongs to the normal profile, while the mini player uses its own geometry and storage. A hidden startup waits in the tray only when there is no link, demo capture, or update receipt that needs a visible window.

References: src/entrypoint.rs• L604-739 src/entrypoint.rs• L742-784 src/entrypoint.rs• L833-950 src/entrypoint.rs• L1291-1430

Startup diagnostics

Run records

The process initializes logging after it knows the selected folders and before it creates the application. The current run replaces the normal log file, while panics are written to a separate file. Panic messages remove links before they are stored, which keeps tokens and other link-carried secrets out of diagnostics.

Normal startup uses a compact warning filter. Verbose startup enables more detail from the Spotify client and web client. The startup record also includes the selected portable paths and the graphics layer records the renderer that actually opened the window.

References: src/entrypoint.rs• L433-439 src/entrypoint.rs• L456-481 src/entrypoint.rs• L647-666 src/paths.rs• L176-184 src/paths.rs• L296-329

Visible failure reports

Window creation is treated as a user-facing failure rather than a silent process exit. The graphics wrapper receives a help page and a native trouble dialog, while the final error is also logged as Native window failed. Update failures are passed into application state so the running UI can show them as an error notice.

This split gives each failure a suitable channel: the log supports bug reports, the dialog explains a display or graphics problem when no window exists, and the UI reports failures that occur after the application has started.

References: src/entrypoint.rs• L731-739 src/app.rs• L14252-14262

Startup-facing tests

Process boundary coverage

The startup integration tests run the built executable as a separate process. They verify that update arguments are removed before the normal parser sees them, that the update helper exits before profile creation, and that an unavailable Linux display leaves a useful log even when no console is available.

The entrypoint unit tests cover the contracts that are easy to break without opening a desktop window. They check launch classification, hidden-start visibility, link and command separation, window persistence separation, and the quiet handling of a closed output pipe.

References: tests/update_launch.rs• L1-64 tests/startup_diagnostics.rs• L1-35 src/entrypoint.rs• L953-1051 src/entrypoint.rs• L1612-1674

Change checklist

When these files or sections are changed, remember to consider these:

  • Keep update-helper interception before normal argument parsing and before profile or log setup.
  • Keep control launches and second-instance launches from creating a second application, tray service, media service, or log writer.
  • Keep portable, installed, and demo path choices aligned with window-state persistence and single-instance scope.
  • Keep the startup log and panic-log paths usable when the native window cannot be created.
  • Keep hidden-start rules aligned with link handoff, update receipts, demo capture, and tray availability.
  • Keep the executable-level diagnostics tests pointed at the same scratch paths and display failure modes that startup uses.

Important failure modes

TriggerConsequenceGuard
Update flags reach the normal command parserA relaunch is rejected or starts the app instead of handling the updateIntercept update arguments before parsing; covered by tests/update_launch.rs
A second process skips the instance claimDuplicate Spotify Connect, tray, or media-control surfaces can appearClaim and hold the single-instance slot before application construction
Demo data uses the real profileSample state can overwrite or resemble the user's settings and historyAssign an isolated demo folder before path discovery
The display or graphics layer cannot create a windowThe app could appear to quit with no useful causeWrite the startup log and report the native-window error through the graphics failure path
Folder creation failsSettings, logs, or state may not be savedContinue only when possible and record the directory error as a startup warning

Key files

FileWhy to read it
src/spotifast.rsShows the executable's minimal process boundary.
src/entrypoint.rsDefines launch classification, startup order, diagnostics, window handoff, and exit persistence.
src/paths.rsExplains installed, portable, demo, log, panic, and window-state locations.
src/single_instance.rsDefines the running-instance contract used by normal, link, and control launches.
src/app.rsShows the application options and the handoff from startup into long-lived runtime state.
tests/update_launch.rsVerifies updater compatibility and the no-profile helper path.
tests/startup_diagnostics.rsVerifies useful diagnostics when native display startup fails.