Skip to content

Commit 3f41572

Browse files
PorthorionKhalifaAlzarooniclaude
authored
fix(a11y): stop sliders from freezing the desktop accessibility tree (#279)
Material's Slider always wraps its value indicator in an OverlayPortal. In a pushed route Flutter 3.47 then sends the engine a semantics node that no parent lists as a child (flutter/flutter#190357). The macOS and Windows accessibility bridges reject it, stay failed, and freeze their native tree on stale nodes; a later pointer move can then read a freed node and crash (flutter/flutter#193588). Part of #267. NavisSlider wraps Slider in its own Overlay.wrap(alwaysSizeToContent, Clip.none), which keeps the portal's semantics inside the slider. All 17 Slider sites use it and an architecture test forbids a bare Slider in lib. The wrap goes away once a stable Flutter ships flutter/flutter#193372. Co-authored-by: khalifa <[email protected]> Co-authored-by: Claude Sonnet <[email protected]>
1 parent 5241e04 commit 3f41572

19 files changed

Lines changed: 431 additions & 23 deletions
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
import 'package:material_ui/material_ui.dart';
2+
3+
/// A material [Slider] that keeps the desktop accessibility tree intact.
4+
///
5+
/// `Slider` always wraps its value indicator in an `OverlayPortal`. In a
6+
/// pushed route, Flutter 3.47 then sends the engine a semantics node that no
7+
/// parent lists as a child (flutter/flutter#190357). The macOS and Windows
8+
/// accessibility bridges reject it, stay failed, and freeze their native tree
9+
/// on stale nodes, which can later crash on a pointer move
10+
/// (flutter/flutter#193588). Giving the slider its own [Overlay] keeps the
11+
/// portal's semantics inside the slider, so use this instead of a bare
12+
/// `Slider` (an architecture test enforces it).
13+
///
14+
/// ponytail: workaround for flutter/flutter#193372 (fixed on master
15+
/// 2026-10-19, not in 3.47.9). Replace the `Overlay.wrap` with the bare
16+
/// `Slider` once a stable Flutter release ships that fix.
17+
///
18+
/// Takes the `Slider` parameters Navis uses. [sliderKey] is the inner
19+
/// `Slider`'s key, so `find.byKey` still resolves to a `Slider`.
20+
class NavisSlider extends StatelessWidget {
21+
const new({
22+
required this.value,
23+
required this.onChanged,
24+
super.key,
25+
this.sliderKey,
26+
this.secondaryTrackValue,
27+
this.onChangeStart,
28+
this.onChangeEnd,
29+
this.min = 0.0,
30+
this.max = 1.0,
31+
this.divisions,
32+
this.label,
33+
this.activeColor,
34+
this.inactiveColor,
35+
this.secondaryActiveColor,
36+
this.thumbColor,
37+
this.overlayColor,
38+
this.mouseCursor,
39+
this.semanticFormatterCallback,
40+
this.focusNode,
41+
this.autofocus = false,
42+
this.allowedInteraction,
43+
this.padding,
44+
this.showValueIndicator,
45+
});
46+
47+
final Key? sliderKey;
48+
final double value;
49+
final double? secondaryTrackValue;
50+
final ValueChanged<double>? onChanged;
51+
final ValueChanged<double>? onChangeStart;
52+
final ValueChanged<double>? onChangeEnd;
53+
final double min;
54+
final double max;
55+
final int? divisions;
56+
final String? label;
57+
final Color? activeColor;
58+
final Color? inactiveColor;
59+
final Color? secondaryActiveColor;
60+
final Color? thumbColor;
61+
final WidgetStateProperty<Color?>? overlayColor;
62+
final MouseCursor? mouseCursor;
63+
final SemanticFormatterCallback? semanticFormatterCallback;
64+
final FocusNode? focusNode;
65+
final bool autofocus;
66+
final SliderInteraction? allowedInteraction;
67+
final EdgeInsetsGeometry? padding;
68+
final ShowValueIndicator? showValueIndicator;
69+
70+
@override
71+
Widget build(BuildContext context) {
72+
return Overlay.wrap(
73+
// The overlay takes the slider's size, and the value indicator may
74+
// paint outside it.
75+
alwaysSizeToContent: true,
76+
clipBehavior: Clip.none,
77+
child: Slider(
78+
key: sliderKey,
79+
value: value,
80+
secondaryTrackValue: secondaryTrackValue,
81+
onChanged: onChanged,
82+
onChangeStart: onChangeStart,
83+
onChangeEnd: onChangeEnd,
84+
min: min,
85+
max: max,
86+
divisions: divisions,
87+
label: label,
88+
activeColor: activeColor,
89+
inactiveColor: inactiveColor,
90+
secondaryActiveColor: secondaryActiveColor,
91+
thumbColor: thumbColor,
92+
overlayColor: overlayColor,
93+
mouseCursor: mouseCursor,
94+
semanticFormatterCallback: semanticFormatterCallback,
95+
focusNode: focusNode,
96+
autofocus: autofocus,
97+
allowedInteraction: allowedInteraction,
98+
padding: padding,
99+
showValueIndicator: showValueIndicator,
100+
),
101+
);
102+
}
103+
}

‎lib/src/features/changelog/changelog_data.dart‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,12 @@ const List<ChangelogVersion> changelogs = [
139139
'EQ presets) works again',
140140
type: ChangelogEntryType.fix,
141141
),
142+
ChangelogEntry(
143+
'Fixed a crash on macOS, and frozen screen-reader output on '
144+
'Windows, when an accessibility tool such as VoiceOver or Narrator '
145+
'is running',
146+
type: ChangelogEntryType.fix,
147+
),
142148
],
143149
),
144150
ChangelogVersion(

‎lib/src/features/downloads/presentation/downloads_screen.dart‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import 'dart:io';
44
import 'package:android_file_picker/android_file_picker.dart';
55
import 'package:file_picker/file_picker.dart';
66
import 'package:material_ui/material_ui.dart';
7+
import 'package:navis/src/common_widgets/navis_slider.dart';
78
import 'package:navis/src/features/downloads/presentation/custom_download_folder_controller.dart';
89
import 'package:navis/src/theme/navis_color_style_data.dart';
910
import 'package:navis/src/utils/app_logger.dart';
@@ -1523,8 +1524,8 @@ class _ConcurrentDownloadsTileState
15231524
? description
15241525
: l10n.downloadsSettingsConcurrentCellular(description),
15251526
),
1526-
Slider(
1527-
key: const ValueKey<String>('downloadsConcurrentSlider'),
1527+
NavisSlider(
1528+
sliderKey: const ValueKey<String>('downloadsConcurrentSlider'),
15281529
min: 1,
15291530
max: kMaxConcurrentDownloads.toDouble(),
15301531
divisions: kMaxConcurrentDownloads - 1,

‎lib/src/features/equalizer/presentation/eq_band_inspector.dart‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import 'package:flutter/gestures.dart';
22
import 'package:material_ui/material_ui.dart';
33
import 'package:flutter/services.dart';
44
import 'package:navis/l10n/app_localizations.dart';
5+
import 'package:navis/src/common_widgets/navis_slider.dart';
56
import 'package:navis/src/common_widgets/navis_tooltip.dart';
67
import 'package:navis/src/features/equalizer/domain/eq_configuration.dart';
78
import 'package:navis/src/features/equalizer/domain/eq_workspace.dart';
@@ -396,8 +397,8 @@ class EqQControl extends StatelessWidget {
396397
Expanded(
397398
child: Listener(
398399
onPointerCancel: enabled ? (_) => onCancel() : null,
399-
child: Slider(
400-
key: const ValueKey('eq-graph-q'),
400+
child: NavisSlider(
401+
sliderKey: const ValueKey('eq-graph-q'),
401402
value: EqGraphGeometry.qPosition(q).clamp(0, 1),
402403
label: 'Q ${eqNumber(q, decimals: 3)}',
403404
semanticFormatterCallback: (value) =>

‎lib/src/features/equalizer/presentation/eq_graph_editor.dart‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import 'package:material_ui/material_ui.dart';
77
import 'package:flutter/services.dart';
88
import 'package:flutter/scheduler.dart';
99
import 'package:navis/l10n/app_localizations.dart';
10+
import 'package:navis/src/common_widgets/navis_slider.dart';
1011
import 'package:navis/src/features/equalizer/domain/eq_configuration.dart';
1112
import 'package:navis/src/features/equalizer/domain/eq_response.dart';
1213
import 'package:navis/src/features/equalizer/domain/eq_workspace.dart';
@@ -527,8 +528,8 @@ class EqGraphEditorState extends State<EqGraphEditor> {
527528
width: 150,
528529
child: Listener(
529530
onPointerCancel: widget.enabled ? (_) => widget.onCancel() : null,
530-
child: Slider(
531-
key: const ValueKey('eq-graph-preamp'),
531+
child: NavisSlider(
532+
sliderKey: const ValueKey('eq-graph-preamp'),
532533
value: current.preampDb,
533534
min: -60,
534535
max: 24,

‎lib/src/features/onboarding/presentation/onboarding_screen.dart‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import 'package:flutter/foundation.dart';
55
import 'package:material_ui/material_ui.dart';
66
import 'package:flutter_riverpod/flutter_riverpod.dart';
77
import 'package:go_router/go_router.dart';
8+
import 'package:navis/src/common_widgets/navis_slider.dart';
89
import 'package:navis/src/routing/desktop_layout.dart';
910
import 'package:navis/l10n/app_localizations.dart';
1011
import 'package:navis/src/common_widgets/confirm_dialog.dart';
@@ -1140,7 +1141,7 @@ class OnboardingScreenState extends ConsumerState<OnboardingScreen> {
11401141
l10n.onboardingCrossfadeDuration(draft.crossfadeDurationSeconds),
11411142
style: Theme.of(context).textTheme.titleSmall,
11421143
),
1143-
Slider(
1144+
NavisSlider(
11441145
value: draft.crossfadeDurationSeconds.toDouble(),
11451146
min: 1,
11461147
max: 12,

‎lib/src/features/player/presentation/desktop_volume_slider.dart‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import 'package:material_ui/material_ui.dart';
2+
import 'package:navis/src/common_widgets/navis_slider.dart';
23
import 'package:navis/src/theme/navis_shape_data.dart';
34

45
/// A desktop volume slider with a floating percentage tooltip that tracks the
@@ -160,7 +161,7 @@ class _DesktopVolumeSliderState extends State<DesktopVolumeSlider>
160161
child: Semantics(
161162
label: widget.semanticLabel,
162163
value: '$percent%',
163-
child: Slider(
164+
child: NavisSlider(
164165
value: displayVolume,
165166
min: 0,
166167
max: 1,

‎lib/src/features/player/presentation/now_playing_screen.dart‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ library;
44
export 'now_playing_artwork_background.dart'
55
show nowPlayingShowsArtworkLayer, nowPlayingSurfaceDecoration;
66

7+
import 'package:navis/src/common_widgets/navis_slider.dart';
78
import 'package:navis/src/features/equalizer/presentation/eq_controller.dart';
89
import 'package:navis/src/features/equalizer/presentation/eq_entry.dart';
910
import 'package:navis/src/features/equalizer/presentation/eq_quick_panel.dart';
@@ -624,7 +625,7 @@ void _showNowPlayingSettingsSheet(
624625
),
625626
const SizedBox(width: 8),
626627
Expanded(
627-
child: Slider(
628+
child: NavisSlider(
628629
value: sheetVolume,
629630
min: 0,
630631
max: 1,

‎lib/src/features/player/presentation/now_playing_seek_bar.dart‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,8 @@ class _SeekBarState extends ConsumerState<_SeekBar> {
115115
unawaited(handler.seek(Duration(milliseconds: targetMs)));
116116
},
117117
child: ExcludeSemantics(
118-
child: Slider(
119-
key: const ValueKey('nowPlayingSeekSlider'),
118+
child: NavisSlider(
119+
sliderKey: const ValueKey('nowPlayingSeekSlider'),
120120
value: sliderValue.clamp(0, sliderMax),
121121
secondaryTrackValue: bufferedValue,
122122
secondaryActiveColor: resolveBufferedSeekColor(context),

‎lib/src/features/settings/presentation/appearance_settings_screen.dart‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import 'dart:async';
22
import 'dart:convert';
33
import 'dart:math';
44

5+
import 'package:navis/src/common_widgets/navis_slider.dart';
56
import 'package:navis/src/features/settings/domain/color_namer.dart';
67
import 'package:material_ui/material_ui.dart';
78
import 'package:flutter/services.dart';
@@ -1619,7 +1620,7 @@ class _ColorPickerDialogState extends State<_ColorPickerDialog> {
16191620
children: <Widget>[
16201621
const Icon(Icons.water_drop_outlined, size: 18),
16211622
Expanded(
1622-
child: Slider(
1623+
child: NavisSlider(
16231624
value: _saturation,
16241625
onChanged: (value) {
16251626
setState(() => _saturation = value);
@@ -1634,7 +1635,7 @@ class _ColorPickerDialogState extends State<_ColorPickerDialog> {
16341635
children: <Widget>[
16351636
const Icon(Icons.brightness_6_outlined, size: 18),
16361637
Expanded(
1637-
child: Slider(
1638+
child: NavisSlider(
16381639
value: _value,
16391640
onChanged: (value) {
16401641
setState(() => _value = value);
@@ -1699,7 +1700,7 @@ class _HueSlider extends StatelessWidget {
16991700
),
17001701
),
17011702
),
1702-
Slider(value: hue, max: 359, onChanged: onChanged),
1703+
NavisSlider(value: hue, max: 359, onChanged: onChanged),
17031704
],
17041705
);
17051706
}

0 commit comments

Comments
 (0)