You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Auto-download liked songs: enabling it can crash the app; confirm with a song count first #267
Owner hands-on (macOS release build, 2026-11-05): turning on auto-download for liked songs (easy to tap by accident) queued a large number of downloads and the app crashed shortly after.
Two parts:
Defect: find why a large liked-songs download batch crashes the app (memory, too many concurrent tasks, DB lock?). Prove the cause at runtime, failing test, fix. Check all platforms.
Feature: before enabling, show a confirmation that says how many songs (and roughly how much space) will be downloaded.
The owner's crash report (Navis 1.5.1 (10501), macOS release build, launched from Finder at 01:10 and crashed at 01:26) shows EXC_BAD_ACCESS / SIGSEGV, KERN_INVALID_ADDRESS at 0x6573003a74655489, on the main thread. I symbolicated it with the dSYM of the same Flutter engine (FlutterMacOS UUID 4C4C4467-5555-3144-A1C5-597D1D3B01CC, Flutter 3.47.5, engine ab598368):
0 ui::AXTree::RelativeToTreeBoundsInternal(...) ax_tree.cc:762
1 ui::AXTree::RelativeToTreeBoundsInternal(...) ax_tree.cc:774 (recursing into a child)
2 ui::AXTree::RelativeToTreeBoundsInternal(...)
3 flutter::FlutterTextPlatformNode::GetFrame() FlutterTextInputSemanticsObject.mm
4 -[FlutterTextField frame]
5 AppKit ___collectTrackingAreasForTargetAndWinLoc_block_invoke
... -[_NSTrackingAreaAKManager _mouseMoved:] ... NSApplication run
The address is ASCII bytes, so a freed AXNode had been reused for string data. A mouse move asked the native text-field view backing a Flutter text field for its frame, and the Flutter macOS accessibility bridge walked a freed AXNode child. The crash is not in Dart code. Memory was not high: the report's writable regions total about 700 MB virtual and 385 MB malloc, with nothing near a limit.
I ran a loopback fixture server with 600 liked songs and an isolated diagnostics profile. I turned Auto-Download Liked on through the real switch, then opened the Queue tab.
Downloads themselves are healthy. All 600 rows were queued within 1 s. 2 transfers ran at a time, the configured limit. Open files went from 101–102 to 107 and stayed flat. Physical footprint peaked at 471 MB without the accessibility probe and 538 MB with it, then settled at 270–315 MB. There were no Dart exceptions, no "database is locked", and the app was still alive after 120 s. The memory, too-many-tasks, file-handle and DB-lock hypotheses do not hold at this scale.
The accessibility bridge is active on this Mac without any probe. The control run (no in-process probe) logged 180 lines of [ERROR:flutter/shell/platform/common/accessibility_bridge.cc(114)] Failed to update ui::AXTree, error: 87 will not be in the tree and is not the new root from startup onwards. With the probe there were 754 such lines in about 2.5 minutes, roughly 5 per second. The rate was the same before and after the toggle, and on Home, Settings and the Queue tab. Something on this machine turns on macOS accessibility for apps (VoiceOver or another assistive or automation app), and Navis then sends semantics updates that ui::AXTree rejects.
When AXTree::Unserialize fails, the bridge can keep pointers to nodes it already deleted. The next frame query on a text field (Downloads has a search field on the Queue and Downloaded tabs) then reads freed memory. That matches the crash stack. Upstream reports what appears to be the same stack and mechanism: [macOS] Accessibility bridge keeps freed AXNodes after a failed AXTree update and crashes on the next AX query flutter/flutter#193588, "[macOS] Accessibility bridge keeps freed AXNodes after a failed AXTree update and crashes on the next AX query".
I did not reproduce the SIGSEGV itself in about 10 minutes of in-process probing. The probe walked the accessibility tree and called frame on every Flutter text-field view 60 times a second. After the failed updates the bridge tree stopped changing (58 nodes), so the probe never got a text-field view attached.
Cause
Crash (macOS): a Flutter engine use-after-free in the macOS accessibility bridge. It is reachable whenever an accessibility client is active, and the trigger is that Navis's semantics updates fail continuously ("N will not be in the tree and is not the new root"). The large liked batch is not required for the crash. Its part is to keep the Downloads screen, which has a text field, redrawing for a long time while the user moves the pointer. The crash can happen on any screen that has a text field.
Dispatch defects (all platforms, not the crash):
AutoDownloadStarredDispatchController._triggerIfEligible starts one unawaited enqueueSong per liked song. Each one runs about 5 DB queries, a folder check and a single-row insert, so N queue-stream emissions each re-query the whole queue for every watcher.
_isDispatching is cleared before those futures finish, so a reachability or network change can dispatch again concurrently. download_queue has no unique song_id, and enqueueSong checks and then inserts, so this can create duplicate rows.
Fix plan (Sonnet, high)
Change 1: stop the invalid semantics updates (macOS crash; risky, do first)
Find which widgets produce the rejected updates. Use the macOS diagnostics scaffolding below with the bridge on. For each id in Failed to update ui::AXTree, error: <id> ..., find the matching SemanticsNode with debugDumpSemanticsTree or the SemanticsNode.id from RendererBinding.instance.pipelineOwner.semanticsOwner. Check Home, Settings → Downloads, the Queue tab and the player bar. Likely causes: a node moved to another parent in one frame (a GlobalKey reparent, OverlayPortal, AnimatedSwitcher or Hero with a keyed child, or a MergeSemantics/ExcludeSemantics change during an animation).
Fix it in the widget: stable parentage, or a single Semantics container.
Failing test first: a widget test for the offending widget with tester.ensureSemantics(). It drives the same animation or update and asserts that no semantics node id changes parent without being removed first. Compare SemanticsNode.parent across two tester.pump() calls, collected through semanticsOwner.rootSemanticsNode.visitChildren.
Verify with the same isolated macOS run: zero Failed to update ui::AXTree lines over 2 minutes on Home, Downloads Queue and Settings.
Edge case: Windows uses the same shell/platform/common/accessibility_bridge.cc, so check Windows with Narrator on for the same log line. The FlutterTextField crash path itself is macOS only. Linux (ATK) and Android use other accessibility paths.
Change 2: one batched enqueue for liked songs (all platforms)
Reuse DownloadService._batchEnqueue, the path enqueueAlbum and enqueuePlaylist already use: one active-ids query, one cache query, one songs query, one space check and one enqueueBatch insert. Add a public enqueueSongs(List<String> songIds, {String? quality, String? format}) that calls it with no album or playlist id.
Bring _batchEnqueue up to enqueueSong's rules:
skip rows with serverDeletedAt != null;
remove stale failed rows for the ids being queued (add DownloadQueueDao.removeFailedForSongIds, one DELETE);
de-duplicate the input ids.
In _triggerIfEligible, replace the per-song loop with await service.enqueueSongs([...ids]). Leave enqueueAlbum per liked album as it is, since it is already batched. Keep _isDispatching true until everything is awaited.
Failing tests first:
Dispatch test: 500 liked songs → enqueueSongs is called once with 500 ids and enqueueSong is never called. A second eligibility flip during dispatch does not enqueue again.
DownloadService test on the test DB: 300 ids give 300 rows with at most 2 watchQueue emissions. It skips compatible permanent downloads and server-deleted songs, replaces failed rows, and ignores duplicate ids.
Update the two existing tests in auto_download_starred_dispatch_provider_test.dart.
Change 3: confirm before enabling (issue part 2)
Song size is already stored in songs.size (Subsonic size, bytes, nullable). DownloadService._expectedBytes already estimates sizes: size for originals, otherwise duration × bitrate × 125. Move it to a top-level expectedDownloadBytes(SongsTableData, String? quality) and reuse it.
LibraryDao.getLikedDownloadCandidates(): one query for the union of liked songs (_selectableForBulkUse) and the songs of liked albums (_likedAlbumPredicate). Exclude songs that have a permanent cached_tracks row or an active queue row, and count each song once.
Load the candidates and the saved quality the dispatcher would use (getDownloadQualityPreference().savedChoice).
If there are no candidates, enable without asking.
Otherwise call showConfirmDialog with:
title "Download N liked songs?" (ICU plural);
message "About X will be downloaded …", using formatBytes;
when Wi-Fi-only is off, the mobile-data warning merged into this one dialog instead of a second dialog;
confirm label "Download" and confirmKey: ValueKey('downloadsAutoDownloadLikedConfirm').
Turning the setting off never asks.
Keep the switch key downloadsAutoDownloadLikedSwitch.
New strings go in lib/l10n/app_en.arb (English only); then run flutter gen-l10n.
Failing tests first:
Widget test: 3 liked songs (1 MB, 2 MB and one with no size and 200 s at 320 kbps) show "3 songs" and the summed size. Cancel leaves the setting off; confirm turns it on. With 0 candidates the setting turns on without a dialog.
DAO test: songs that are both liked and in a liked album count once, and downloaded or queued songs are excluded.
Change 4: version and changelog
pubspec.yaml is 1.5.1+10501 and v1.5.1 is tagged, so bump to 1.5.2+10502 unless another batch-152 item already has. Add or extend ChangelogVersion('1.5.2') in lib/src/features/changelog/changelog_data.dart:
"Turning on Auto-Download Liked now asks first and shows how many songs and roughly how much space it will download"
"Fixed a crash on macOS when an accessibility app is running" (only if Change 1 lands)
"Large liked libraries queue for download in one step"
macOS diagnostics scaffolding (uncommitted in the investigation worktree)
lib/main.dart: let sync diagnostics run on macOS profile builds.
DebugProfile.entitlements: sandbox off, so the profile can write to the run root.
MainFlutterWindow.swift: NAVIS_I267_AX_PROBE=1 posts the enhanced-UI notification and walks the AX tree.
Fixture server: a --star-all flag.
Downloads switch: a key.
Launch the app with open -n --env .... A binary launched directly from a background shell never renders frames, so the presentation API hangs.
Open questions for the owner
Was VoiceOver, or an app with Accessibility permission (window manager, launcher, automation, screen reader), running? It is active on this Mac now: the bridge comes up for a fresh Navis profile with no probe.
Did it crash on the Downloads screen, Queue or Downloaded tab, while moving the pointer over the window?
Should Change 1 (finding the widget behind the rejected semantics updates) be a separate risky item with an Opus review, ahead of the dialog work?
AI disclosure: Harness: Claude Code · Tool(s): none · Model(s): claude-opus-5-5 · Involvement: Fully AI-generated, human verified pending (owner to review) · Adversarial review: n/a (investigation only; the implementation PR gets an independent review).
#267 Change 1: the widget behind the rejected accessibility updates (proven)
Trigger: the volume slider in the desktop player bar (DesktopVolumeSlider). material_ui's Slider always wraps itself in an OverlayPortal for its value indicator. On Flutter 3.47.5 the framework then sends the engine an empty semantics node for that portal child that no parent lists as a child: empty label, no traversal parent, no children, sized to the root overlay. The engine's ui::AXTree rejects it: 87 will not be in the tree and is not the new root. The tree error is never cleared, so every later update fails too. That is the stream of about 5 log lines per second, and the ids after the first are knock-on failures. The native tree stays frozen with stale nodes, which is the state that crashes in FlutterTextPlatformNode::GetFrame (flutter/flutter#193588). Upstream, the orphan is flutter/flutter#190357. Its framework fix (flutter/flutter#193372) is merged on master but not in any stable or beta yet (checked against 3.47.9 and 3.48.0-0.5.pre).
Evidence (macOS profile build, accessibility active, about 2 minutes across Home, Settings, Downloads with the Queue tab, Playback, Appearance, Library and Search):
An in-app recorder of the semantics updates sent to the engine found exactly one orphan, node 87, and the engine's first error was for that same node 87. After that, 93 knock-on error lines followed.
Wrapping only the volume slider's Slider in Overlay.wrap(alwaysSizeToContent: true, clipBehavior: Clip.none, ...) gave 0 orphans and 0 AXTree errors, with the semantics tree still updating. Wrapping only the seek slider left the error in place. Wrapping the whole player bar in one overlay only moved the orphan.
Widget test with a recording semantics binding: a bare DesktopVolumeSlider in a pushed route sends 1 orphan; at the initial route it sends 0; with the wrap it sends 0. A plain Slider in a pushed route also sends 1, including when disabled, with the value indicator off, or inside Semantics(container: true). Tooltip icon buttons, popup menus and text fields send none.
Platforms: Windows uses the same bridge code (shell/platform/common/accessibility_bridge.cc). With a screen reader running it gets the same rejection and a frozen tree, and its own null-delegate crash path (flutter/flutter#192180). Linux (ATK) and Android don't use this tree.
Fix plan (app side; no Flutter upgrade needed):
Add a NavisSlider that wraps Slider in its own Overlay.wrap.
Use it at all 17 Slider sites.
Add an architecture test that forbids a bare Slider(.
Add a widget test, using the recording binding, that asserts no orphan semantics nodes for the volume slider in a pushed route.
Runtime check: zero Failed to update ui::AXTree lines over 2 minutes across the main screens, while playing, on Now Playing and on the Equalizer.
Owner answers (2026-11-05): not sure whether another accessibility app was running. The crash happened while setting up a custom downloads folder, right after turning on Auto-Download Liked (Downloads › Settings). That screen has the concurrency slider, so it fits the slider orphan-semantics cause fixed in #279 (no AXTree errors in the release/1.5 runtime pass). Batching and the confirmation shipped in #280.
Activity
Porthorion commentedon Nov 4, 2026
#267: root cause and fix plan
What crashed
The owner's crash report (Navis 1.5.1 (10501), macOS release build, launched from Finder at 01:10 and crashed at 01:26) shows
EXC_BAD_ACCESS / SIGSEGV,KERN_INVALID_ADDRESS at 0x6573003a74655489, on the main thread. I symbolicated it with the dSYM of the same Flutter engine (FlutterMacOS UUID4C4C4467-5555-3144-A1C5-597D1D3B01CC, Flutter 3.47.5, engineab598368):The address is ASCII bytes, so a freed
AXNodehad been reused for string data. A mouse move asked the native text-field view backing a Flutter text field for its frame, and the Flutter macOS accessibility bridge walked a freedAXNodechild. The crash is not in Dart code. Memory was not high: the report's writable regions total about 700 MB virtual and 385 MB malloc, with nothing near a limit.Runtime evidence (isolated macOS profile build, 600 liked songs)
I ran a loopback fixture server with 600 liked songs and an isolated diagnostics profile. I turned Auto-Download Liked on through the real switch, then opened the Queue tab.
[ERROR:flutter/shell/platform/common/accessibility_bridge.cc(114)] Failed to update ui::AXTree, error: 87 will not be in the tree and is not the new rootfrom startup onwards. With the probe there were 754 such lines in about 2.5 minutes, roughly 5 per second. The rate was the same before and after the toggle, and on Home, Settings and the Queue tab. Something on this machine turns on macOS accessibility for apps (VoiceOver or another assistive or automation app), and Navis then sends semantics updates thatui::AXTreerejects.AXTree::Unserializefails, the bridge can keep pointers to nodes it already deleted. The next frame query on a text field (Downloads has a search field on the Queue and Downloaded tabs) then reads freed memory. That matches the crash stack. Upstream reports what appears to be the same stack and mechanism: [macOS] Accessibility bridge keeps freed AXNodes after a failed AXTree update and crashes on the next AX query flutter/flutter#193588, "[macOS] Accessibility bridge keeps freed AXNodes after a failed AXTree update and crashes on the next AX query".frameon every Flutter text-field view 60 times a second. After the failed updates the bridge tree stopped changing (58 nodes), so the probe never got a text-field view attached.Cause
AutoDownloadStarredDispatchController._triggerIfEligiblestarts one unawaitedenqueueSongper liked song. Each one runs about 5 DB queries, a folder check and a single-row insert, so N queue-stream emissions each re-query the whole queue for every watcher._isDispatchingis cleared before those futures finish, so a reachability or network change can dispatch again concurrently.download_queuehas no uniquesong_id, andenqueueSongchecks and then inserts, so this can create duplicate rows.Fix plan (Sonnet, high)
Change 1: stop the invalid semantics updates (macOS crash; risky, do first)
Failed to update ui::AXTree, error: <id> ..., find the matchingSemanticsNodewithdebugDumpSemanticsTreeor theSemanticsNode.idfromRendererBinding.instance.pipelineOwner.semanticsOwner. Check Home, Settings → Downloads, the Queue tab and the player bar. Likely causes: a node moved to another parent in one frame (aGlobalKeyreparent,OverlayPortal,AnimatedSwitcherorHerowith a keyed child, or aMergeSemantics/ExcludeSemanticschange during an animation).Semanticscontainer.tester.ensureSemantics(). It drives the same animation or update and asserts that no semantics node id changes parent without being removed first. CompareSemanticsNode.parentacross twotester.pump()calls, collected throughsemanticsOwner.rootSemanticsNode.visitChildren.Failed to update ui::AXTreelines over 2 minutes on Home, Downloads Queue and Settings.shell/platform/common/accessibility_bridge.cc, so check Windows with Narrator on for the same log line. TheFlutterTextFieldcrash path itself is macOS only. Linux (ATK) and Android use other accessibility paths.Change 2: one batched enqueue for liked songs (all platforms)
DownloadService._batchEnqueue, the pathenqueueAlbumandenqueuePlaylistalready use: one active-ids query, one cache query, one songs query, one space check and oneenqueueBatchinsert. Add a publicenqueueSongs(List<String> songIds, {String? quality, String? format})that calls it with no album or playlist id._batchEnqueueup toenqueueSong's rules:serverDeletedAt != null;DownloadQueueDao.removeFailedForSongIds, one DELETE);_triggerIfEligible, replace the per-song loop withawait service.enqueueSongs([...ids]). LeaveenqueueAlbumper liked album as it is, since it is already batched. Keep_isDispatchingtrue until everything is awaited.enqueueSongsis called once with 500 ids andenqueueSongis never called. A second eligibility flip during dispatch does not enqueue again.DownloadServicetest on the test DB: 300 ids give 300 rows with at most 2watchQueueemissions. It skips compatible permanent downloads and server-deleted songs, replaces failed rows, and ignores duplicate ids.auto_download_starred_dispatch_provider_test.dart.Change 3: confirm before enabling (issue part 2)
songs.size(Subsonicsize, bytes, nullable).DownloadService._expectedBytesalready estimates sizes:sizefor originals, otherwise duration × bitrate × 125. Move it to a top-levelexpectedDownloadBytes(SongsTableData, String? quality)and reuse it.LibraryDao.getLikedDownloadCandidates(): one query for the union of liked songs (_selectableForBulkUse) and the songs of liked albums (_likedAlbumPredicate). Exclude songs that have a permanentcached_tracksrow or an active queue row, and count each song once.downloads_screen.dart_updateAutoDownloadLiked(true):getDownloadQualityPreference().savedChoice).showConfirmDialogwith:formatBytes;confirmKey: ValueKey('downloadsAutoDownloadLikedConfirm').downloadsAutoDownloadLikedSwitch.lib/l10n/app_en.arb(English only); then runflutter gen-l10n.Change 4: version and changelog
pubspec.yamlis1.5.1+10501andv1.5.1is tagged, so bump to1.5.2+10502unless another batch-152 item already has. Add or extendChangelogVersion('1.5.2')inlib/src/features/changelog/changelog_data.dart:macOS diagnostics scaffolding (uncommitted in the investigation worktree)
lib/main.dart: let sync diagnostics run on macOS profile builds.DebugProfile.entitlements: sandbox off, so the profile can write to the run root.MainFlutterWindow.swift:NAVIS_I267_AX_PROBE=1posts the enhanced-UI notification and walks the AX tree.--star-allflag.Launch the app with
open -n --env .... A binary launched directly from a background shell never renders frames, so the presentation API hangs.Open questions for the owner
AI disclosure: Harness: Claude Code · Tool(s): none · Model(s): claude-opus-5-5 · Involvement: Fully AI-generated, human verified pending (owner to review) · Adversarial review: n/a (investigation only; the implementation PR gets an independent review).
Porthorion commentedon Nov 4, 2026
#267 Change 1: the widget behind the rejected accessibility updates (proven)
Trigger: the volume slider in the desktop player bar (
DesktopVolumeSlider). material_ui'sSlideralways wraps itself in anOverlayPortalfor its value indicator. On Flutter 3.47.5 the framework then sends the engine an empty semantics node for that portal child that no parent lists as a child: empty label, no traversal parent, no children, sized to the root overlay. The engine'sui::AXTreerejects it:87 will not be in the tree and is not the new root. The tree error is never cleared, so every later update fails too. That is the stream of about 5 log lines per second, and the ids after the first are knock-on failures. The native tree stays frozen with stale nodes, which is the state that crashes inFlutterTextPlatformNode::GetFrame(flutter/flutter#193588). Upstream, the orphan is flutter/flutter#190357. Its framework fix (flutter/flutter#193372) is merged on master but not in any stable or beta yet (checked against 3.47.9 and 3.48.0-0.5.pre).Evidence (macOS profile build, accessibility active, about 2 minutes across Home, Settings, Downloads with the Queue tab, Playback, Appearance, Library and Search):
SliderinOverlay.wrap(alwaysSizeToContent: true, clipBehavior: Clip.none, ...)gave 0 orphans and 0 AXTree errors, with the semantics tree still updating. Wrapping only the seek slider left the error in place. Wrapping the whole player bar in one overlay only moved the orphan.DesktopVolumeSliderin a pushed route sends 1 orphan; at the initial route it sends 0; with the wrap it sends 0. A plainSliderin a pushed route also sends 1, including when disabled, with the value indicator off, or insideSemantics(container: true). Tooltip icon buttons, popup menus and text fields send none.Platforms: Windows uses the same bridge code (
shell/platform/common/accessibility_bridge.cc). With a screen reader running it gets the same rejection and a frozen tree, and its own null-delegate crash path (flutter/flutter#192180). Linux (ATK) and Android don't use this tree.Fix plan (app side; no Flutter upgrade needed):
NavisSliderthat wrapsSliderin its ownOverlay.wrap.Slidersites.Slider(.Failed to update ui::AXTreelines over 2 minutes across the main screens, while playing, on Now Playing and on the Equalizer.AI disclosure: Harness: Claude Code · Tool(s): none · Model(s): claude-opus-5-5 · Involvement: Fully AI-generated, human verified pending (owner to review) · Adversarial review: n/a (investigation only; the implementation PR gets an independent review).
fix(a11y): stop sliders from freezing the desktop accessibility tree (#…
fix(downloads): queue liked songs in one batch and confirm before Aut…
Porthorion commentedon Nov 5, 2026
Owner answers (2026-11-05): not sure whether another accessibility app was running. The crash happened while setting up a custom downloads folder, right after turning on Auto-Download Liked (Downloads › Settings). That screen has the concurrency slider, so it fits the slider orphan-semantics cause fixed in #279 (no AXTree errors in the release/1.5 runtime pass). Batching and the confirmation shipped in #280.
Porthorion commentedon Nov 9, 2026
Merged to release/1.5 for 1.5.2 (dev build v1.5.2-dev.37489838). Owner spot-checked on the phone; automated tests cover the rest (owner, 2026-11-09).