Fix the v0.3.0 launch crash: attach the input node before prepare() - #73
Merged
Merged
Conversation
…launch
v0.3.0 died about a second after every launch: the menu-bar icon appeared and
vanished.
required condition is false: inputNode != nullptr || outputNode != nullptr
AVAudioEngineGraph::Initialize -> -[AVAudioEngine prepare]
AudioHub.prepareFormat()
AVAudioEngine initializes its graph inside prepare() and asserts that at least
one node is attached. A freshly constructed engine has none — inputNode is
created lazily on first access, and touching the property is what attaches it.
The per-start engine rebuild from #59 replaced the engine and called prepare()
with nothing in between. The single-engine code had satisfied this by accident:
requestListening()'s stop() reaches engine.inputNode.removeTap(onBus: 0), which
materialized the node on the long-lived engine well before any prepare().
Rebuilding after that call removed the accident without replacing it.
So makeEngine() materializes the input node as part of building an engine, used
by both init() and renewEngine() — no call ordering elsewhere can get it wrong.
Also traps engine.prepare(). #59 wrapped only installTapOnBus, which is why the
trap was not in this path at all. The trap itself remains unexercised: nothing
has yet shown it catching a raise that unwinds through the intervening Swift
closure frame.
Bumps to 0.3.1 so the crashing build stays distinguishable.
Closes #72
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JDYgSqFgDXf6BXWZFUTi8d
missingbulb
added a commit
that referenced
this pull request
Aug 7, 2026
Three lessons from the 2026-07-26..08-02 window, into the laughcounter local pack as prose. #74/#75: diagnosing the installTap crash stalled on "which binary is installed?" — the menu said only "LaughCounter", and several distinct builds all reported 0.2.1, because the release workflow keys its Release on v<version> from Info.plist, so a merge that leaves CFBundleShortVersionString alone refreshes the same Release behind the latest/download link. Durable part: show version and build from Bundle.main (not a source constant that could disagree with the DMG), and bump per distinguishable build. #56: the scheduler ran green nightly while silently skipping baselining ("no vendored mount (no stamp)") because the vendored loadConfig dropped the `claudinite` key it had just validated. Durable part: a job whose success and whose no-op look identical from outside is telling you nothing — read the skip line; and a bug inside the mechanism that updates itself has to be fixed out of band. #34: claudinite-isolation fired on CLAUDE.md's mount path, which carried nothing a reader could act on. Durable part: before adding an `accept`, delete the flagged text and see whether anything actionable went with it — an accept is for a crossing that must exist. Nothing new from the mac window (#59, #73, #77, #78, #87, #100, #101, #108): dev/procedures/mac-audio-lifecycle.md already records the engine-per-start rule, the inputFormat-vs-outputFormat trap, the aggregate churn, the three-state health reporting, the witnessed-arrival settle rule and the observation-gap rule in full. #55, #69, #84 and #99 are already carried by this pack's existing prose and the on-device-privacy checks. #32's "prove the check is live" is the see-it-fail discipline the canon owns. Conversation-logs half: the 2026-08-01 logs are the #108 session (fully covered above) and unattended task runs; no new friction lesson. No retention_days configured, so no prune. Refs #113. Claude-Session: https://claude.ai/code/session_01G52dxZvLCxyZJJnvLrYcQs Co-authored-by: Claude <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.
Closes #72.
v0.3.0 crashes about a second after every launch — menu-bar icon appears, then vanishes. Regression from #59. Reported from the owner's Mac mini, crash report
LaughCounter-2026-07-29-111329.ips.Cause
AVAudioEngineinitializes its graph insideprepare()and asserts that at least one node is attached. A freshly constructed engine has none —inputNodeis created lazily on first access, and touching the property is what attaches it.#59's per-start rebuild replaced the engine and called
prepare()with nothing in between. The single-engine code had satisfied the precondition by accident:requestListening()callsaudio.stop(), which reachesengine.inputNode.removeTap(onBus: 0)and materialized the node on the long-lived engine well before anyprepare()ran. Rebuilding the engine after that call removed the accident without replacing it with anything deliberate — so it failed on the very first start, every time.Fix
makeEngine()materializes the input node as part of building an engine, and bothinit()andrenewEngine()go through it. The precondition is satisfied by construction rather than by a call order somewhere else that a later edit can quietly break.engine.prepare()is now trapped too. Fix the installTap crash on every audio device change, and reactivate the counter on return from standby #59 wrapped onlyinstallTapOnBus, which is why the trap was not in this path at all. This crash provesprepare()raises as well, and a raise there is equally fatal.The trap remains unexercised: nothing has yet demonstrated it catching an
NSExceptionthat unwinds through the intervening Swift closure frame, which is not guaranteed to work. It is a hoped-for backstop, not a proven one — the two structural fixes (#61's fresh engine, this one's attached node) are what actually keep these paths off the exception route.Testing
CI compiles it. That is not a meaningful gate for this file — compile-green passed two crash-on-launch builds in a row, because every raise-vs-throw bug in
AudioHubis invisible to the compiler and reachable in the first second of a run. The real check is launching 0.3.1 on the Mac mini and seeing the icon stay up, thenlistening startedin the activity log.A unit-test target calling
AudioHub().prepareFormat()would have caught this exact class of bug — it either throws or returns, and must never raise. Noted as follow-up in #72 rather than bundled here, since it needs a test target and aswift teststep in both DMG workflows, and this fix should ship on its own.dev/procedures/mac-audio-lifecycle.mdrecords both the node-attachment rule and the "compile-green is not a gate for this file" lesson.Generated by Claude Code