Repository navigation
Description
Internal: b/308890939
On iOS, SemanticsService.announce easily gets interrupted by VoiceOver when calling SemanticsService.announce('This is an announcement', TextDirection.ltr); in a button (any widget that has its own or child semantic hints for the VoiceOver to read).
This affects widgets that need to announce their states such as ExpansionTile.
Take this simple button that makes an announcement when pressing the button. On Android, the Semantic announcement is read when pressing the button but on iOS, VoiceOver reads the "'Announce now!'" button text, which interrupts the Semantic announcement.
FilledButton(
onPressed: () async {
SemanticsService.announce('This is an announcement', TextDirection.ltr);
},
child: const Text('Announce now!'),
),On iOS, you can add delay to the announcement so it can be played after VoiceOver is done reading "'Announce now!'" button text.
FilledButton(
onPressed: () async {
await Future<void>.delayed(const Duration(seconds: 2), () {
SemanticsService.announce(
'This is an announcement', TextDirection.ltr);
});
},
child: const Text('Announce 2sec later!'),
),code sample
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
void main() => runApp(const MyApp());
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
theme: ThemeData(useMaterial3: true),
home: const Example(),
);
}
}
class Example extends StatelessWidget {
const Example({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Sample'),
),
body: Align(
alignment: Alignment.bottomCenter,
child: Column(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
FilledButton(
onPressed: () async {
SemanticsService.announce('This is an announcement', TextDirection.ltr);
},
child: const Text('Announce now!'),
),
FilledButton(
onPressed: () async {
await Future<void>.delayed(const Duration(seconds: 2), () {
SemanticsService.announce(
'This is an announcement', TextDirection.ltr);
});
},
child: const Text('Announce 2sec later!'),
),
const SizedBox(height: 150)
],
),
),
);
}
}iOS
IMG_2302.MP4
Android
VID_20230307171655.mp4
Found this explanation on SO.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsNo status
Activity
TahaTesser commentedon Mar 7, 2023
cc: @chunhtai
wunderbrick commentedon Apr 13, 2023
I can reproduce this. The issue is not present on Android.
Toolenaar commentedon Jul 3, 2023
I am having the same issue. It also looks like the async function to announce the message does not resolve
await SemanticsService.announce(msg, TextDirection.ltr);LHaanappel commentedon Feb 1, 2024
This is still a pretty limiting issue which makes SemanticsService.announce very unreliable on iOS. :(
ash2moon commentedon Mar 14, 2025
FYI: Using announce is deprecated on Android as of >=API 36. I opened a PR to make devs aware.
Instead of using the semantics service, I would recommend trying the Semantics widget instead to see if this helps.
TahaTesser commentedon Mar 14, 2025
Could we make semantic announcement on callback using
Semanticswidget?ash2moon commentedon Mar 14, 2025
Could you please clarify what you mean by semantic announcement on callback? With
Semanticsthere's many ways of composing the semantics tree. TheSemanticsDebuggercould also help with composing the tree in a way that makes sense.TahaTesser commentedon Mar 14, 2025
From the original post #122101 (comment). You can see the announcement is made when button is called. Similarly, this is required for
ExpansionTileto announce updated toggle state when the expanded callback is triggered.Is there a way such announcement when the button is pressed using
Semanticswidget?ash2moon commentedon Apr 8, 2025
I looked into some ways we could remove the
.announcecall and replace it with an idiomatic use ofSemanticsand it seems like the best option would be to create a wrapperSemanticswidget over the ExpansionTile with a liveRegion mentioning the state of the tile. However there is one issue: #165857 is needed, otherwise thisSemanticswidget will capture focus. I'll let you know here once that blocker is resolved.zywek123 commentedon May 9, 2025
Modifying announce for iOS is not necessary in my opinion. Some apps, e.g. A new Navigation by Transition Technologies uses it when User wants to receive tts messages via VoiceOver. The main issue which could be fixed is, the Future never Ends.
await SemanticsService.announce("xxx", TextDirection.ltr);
await someInstruction(); // will never execute
For Android, some functions here
https://developer.android.com/about/versions/16/behavior-changes-all?hl=en#disruptive-a11y
probably may be used.
T-Davis commentedon Oct 7, 2026
Hit this in a chat UI on iOS: VoiceOver reads the just-cleared text field, and the reply's announcement is sometimes clipped and sometimes lost. A fixed delay doesn't help when the announcement's timing is unpredictable.
The engine already solves this for live regions.
accessibility_bridge.mmposts a live region change withUIAccessibilitySpeechAttributeQueueAnnouncement, so it waits for VoiceOver. Theannouncehandler posts a plain string and ignoresassertiveness. Queueing polite announcements there would fix this without per-widget delays.Workaround until then: announce through a live region on iOS. Confirmed on an iPhone 11 with iOS 18.3 and Flutter 3.41.8.