Repository navigation
Conversation
At a cold logon the UI launches the daemon as soon as its services are resolved, and the other bootloaders run on the same dispatcher as the daemon's events. A daemon that connected and reported Stopped before MainBootloader built the layout got no answer: the Stopped was dropped because MonitorsLayout was still null, and nothing asked again, so the engine stayed stopped until a manual Start. That Stopped is now kept pending, and the first layout build answers it when the daemon still reports Stopped and the layout is enabled. Later rebuilds keep going through the display-change path. MainService's post to the UI thread can be swapped in tests: Avalonia's UI dispatcher belongs to whichever thread touched it first. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Problem
On Windows, with "load at startup" on, the engine sometimes stays stopped after logon: the UI and the hook are both running, but the mouse is not hooked until a manual Start.
The rolling daemon event trace (
daemon-events.log) shows the pattern across several logons on one machine:ConnectedStopped8 s later, thenLoaded,RunningStopped8 ms later, then nothingStopped2.6 s later, thenLoadedonly at the manual Start ~90 min laterStopped0.5 s later, thenLoadedonly at the manual Start ~80 min laterOn the bad logons
Current.xmlwas not written either, so noLoad/Runwas sent at all.Cause
The UI answers a daemon's first
StoppedafterConnectedby sending it the layout, but onlyif (MonitorsLayout is not null && …). At a cold logon the daemon is launched as soon as the services are resolved (MainBootloaderconstruction →MainService→LittleBigMouseClientService.Listen), while the bootloaders are still running on the same dispatcher as the daemon's events. A daemon that connects and reportsStoppedbeforeMainBootloader.LoadAsyncreachesUpdateLayout()gets no answer, and nothing asks again.The logs fit this: the logon that worked is the one where
Stoppedcame late. I could not prove it outright, because the 5.6.0 build on that machine logs handler failures withDebug.WriteLine, so nothing reachesui.login Release.Fix
Stoppedis kept pending while there is no layout yet (StartIfJustConnectedAsync).UpdateLayout()answers it, on the dispatcher, when the daemon still reportsStoppedand the layout is enabled. Later rebuilds keep going through the display-change path (ReconcileFreshLayoutAsync), so nothing gets started twice.MainService's post to the UI thread can be swapped (internal PostToUi) so tests can run the handlers inline: Avalonia's UI dispatcher belongs to whichever thread touched it first, which made aDispatcher.UIThread.RunJobs()-based test order-dependent.Testing
MainServiceLifecycleTests:LittleBigMouse.Ui.Avalonia.Testssuite passes. One unrelated test,LocationControlViewModelTests.AfterDisposalTheLayoutNoLongerReachesTheViewModel, fails intermittently onmastertoo (2 runs in 10 without this change).🤖 Generated with Claude Code