Public Access
Two things a desktop application is expected to do and this one did not. ◆ THREE SECONDS OF NOTHING. Measured on a debug build against a cold profile: the main window arrives 3.1 seconds after the executable does. Nothing was on screen for any of it — the icon had been double-clicked and the desktop looked unchanged. The main window cannot come sooner. It needs a view model, and the view model needs composition to have opened the SQLite cache, bound the terminal's loopback socket, asked the platform about a TPM and read the install layout off disk. Its own IsStarting card already narrates what happens after it appears; this is the part before, which no arrangement of that window can cover. So SplashWindow, and it is measurably the point: 668 ms to the splash, 3.1 s to the window that replaces it. Two mechanics are load-bearing rather than incidental. The splash *is* desktop.MainWindow for a moment. The lifetime shows whatever that property holds once OnFrameworkInitializationCompleted returns; a window merely Show()n there would have no lifetime attached, and under ShutdownMode.OnLastWindowClose the first close of anything would end the process. Handing the property over is one assignment and Avalonia reads it lazily. And composition is posted at DispatcherPriority.Background rather than called. It is synchronous and slow — which is the entire argument for a splash — so running it inline would block the very dispatcher turn that has to paint the thing. The window is SizeToContent="Height", which is about the failure and not the splash: CouldNotStart carries an exception's own message, and inside a fixed height a long one would wrap and be clipped at exactly the moment that text is all the window is for. A composition that throws is caught rather than left to the dispatcher, for the same reason — before this there was nothing on screen to abandon, and now there is, so an escaping exception would leave a window saying "Starting…" over a process that had stopped. Escape closes it, and only then. ◆ AND ONE INSTANCE. Claimed in Main before Avalonia is configured, so a second launch starts nothing at all: no toolkit, no window, no splash flashing up before it thinks better of it. Exclusion is an exclusive handle on instance.lock inside the profile directory, and that location settles two questions at once. A nightly and a release build do not exclude each other — separate profiles, ADR 0013 — and two people signed in to one machine each get their own instance. A global mutex would have had to re-derive both from somewhere. A file handle rather than a named mutex because the kernel releases it however the process ends. There is no such thing as a stale lock here, which is a state a named mutex makes both platforms model differently and neither model simply. The second launch is not silent. Somebody who double-clicks an icon and sees nothing has been told the application is broken, so it rings a named pipe — named from a digest of the profile path, so it is scoped exactly as the lock is — and the running instance un-minimises and activates. Activate is a request and not a guarantee: Windows refuses the foreground to a process that did not receive the input, and the flashing taskbar button that results is still an answer. Three seconds of retrying when the lock is held by something that does not answer its pipe, and that window has one job. Velopack's apply ends this process and its updater starts the new build; the two are ordered, but a lock held a moment too long would make the successor refuse itself and vanish — an update that looked like an uninstall. The doorbell is disposed before Shutdown for the same reason, so the pipe name is free before the process is. ◆ VERIFIED BY RUNNING IT, WHICH IS THE ONLY WAY EITHER OF THESE COULD BE. Two launches of the built executable: the first stayed up with instance.lock in the profile, the second exited. Window sizes over time are where the two timings above come from — 420x160 then 1196x776. SingleInstanceTests covers what a single process can reach: the lock, its release by disposal, the doorbell answering more than once, and two profiles not excluding each other. SplashCardTests measures the one thing the splash can get wrong, which is a failure message long enough to need the height the window is willing to give it. Checks 1.12 and 16.11 are what needs a second executable and a real screen. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
50 lines
2.5 KiB
XML
50 lines
2.5 KiB
XML
<UserControl xmlns="https://github.com/avaloniaui"
|
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
|
x:Class="DodoSSH.Client.App.Views.SplashCard">
|
|
|
|
<!--
|
|
What is on screen while the application composes itself.
|
|
|
|
── WHY THIS IS ITS OWN CONTROL ────────────────────────────────────────────────────────────────────────
|
|
|
|
The same reason UpdateBanner is: a Window cannot be laid out by the headless suite when it contains a
|
|
WebView, and while this one does not, a UserControl is what LayoutHarness can host and measure. See
|
|
SplashCardTests. It also keeps the window itself down to a frame and a size.
|
|
|
|
── AND WHY THERE IS NO VIEW MODEL ─────────────────────────────────────────────────────────────────────
|
|
|
|
There is nothing to observe. Composition is one synchronous block — see DodoSshApp.ComposeBehind — so
|
|
this control has exactly two states, both of them set by the one caller: starting, and could not. Two
|
|
methods on the code-behind is the whole of it, and a view model would be an observable object with a
|
|
lifetime and a test of its own standing in for two assignments.
|
|
-->
|
|
<Border Background="{StaticResource Chrome}"
|
|
BorderBrush="{StaticResource Border}"
|
|
BorderThickness="1">
|
|
|
|
<StackPanel Margin="28" Spacing="12" VerticalAlignment="Center">
|
|
|
|
<TextBlock Classes="heading" Text="DodoSSH" />
|
|
|
|
<TextBlock x:Name="Line" Classes="hint" Text="Starting…" />
|
|
|
|
<!--
|
|
Indeterminate, because there is nothing honest to measure. Composition opens a SQLite file, binds a
|
|
loopback socket, asks the platform about a TPM and reads an install layout off disk; none of them
|
|
reports progress and inventing a bar that crawled to 90% and waited would be a worse lie than a bar
|
|
that only says "still going".
|
|
|
|
Four pixels, matching the update banner's own and the transfers screen's, so the one moving thing in
|
|
this application looks like itself wherever it appears.
|
|
-->
|
|
<ProgressBar x:Name="Bar" Height="4" Margin="0,4,0,0"
|
|
IsIndeterminate="True"
|
|
Foreground="{StaticResource Accent}"
|
|
Background="{StaticResource Chip}" />
|
|
|
|
</StackPanel>
|
|
|
|
</Border>
|
|
|
|
</UserControl>
|