Skip to content

SemanticsService.announce gets interrupted by VoiceOver #122101

Open

Description

@TahaTesser

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.

Activity

  1. added
    platform-iosiOS applications specifically
    engineflutter/engine related. See also e: labels.
    a: accessibilityAccessibility, e.g. VoiceOver or TalkBack. (aka a11y)
    on Mar 7, 2023
  2. TahaTesser commented on Mar 7, 2023

    @TahaTesser
    ContributorAuthor
  3. added
    P2Important issues not at the top of the work list
    on Mar 20, 2023
  4. wunderbrick commented on Apr 13, 2023

    @wunderbrick

    I can reproduce this. The issue is not present on Android.

  5. Toolenaar commented on Jul 3, 2023

    @Toolenaar

    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);

  6. LHaanappel commented on Feb 1, 2024

    @LHaanappel

    This is still a pretty limiting issue which makes SemanticsService.announce very unreliable on iOS. :(

  7. ash2moon commented on Mar 14, 2025

    @ash2moon
    Contributor

    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.

  8. TahaTesser commented on Mar 14, 2025

    @TahaTesser
    ContributorAuthor

    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.

    Could we make semantic announcement on callback using Semantics widget?

  9. ash2moon commented on Mar 14, 2025

    @ash2moon
    Contributor

    Could you please clarify what you mean by semantic announcement on callback? With Semantics there's many ways of composing the semantics tree. The SemanticsDebugger could also help with composing the tree in a way that makes sense.

  10. TahaTesser commented on Mar 14, 2025

    @TahaTesser
    ContributorAuthor

    From the original post #122101 (comment). You can see the announcement is made when button is called. Similarly, this is required for ExpansionTile to announce updated toggle state when the expanded callback is triggered.

                FilledButton(
                  onPressed: () async {
                    SemanticsService.announce('This is an announcement', TextDirection.ltr);
                  },
                  child: const Text('Announce now!'),
                ),
    
    

    Is there a way such announcement when the button is pressed using Semantics widget?

  11. ash2moon commented on Apr 8, 2025

    @ash2moon
    Contributor

    I looked into some ways we could remove the .announce call and replace it with an idiomatic use of Semantics and it seems like the best option would be to create a wrapper Semantics widget over the ExpansionTile with a liveRegion mentioning the state of the tile. However there is one issue: #165857 is needed, otherwise this Semantics widget will capture focus. I'll let you know here once that blocker is resolved.

  12. zywek123 commented on May 9, 2025

    @zywek123

    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.

  13. T-Davis commented on Oct 7, 2026

    @T-Davis

    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.mm posts a live region change with UIAccessibilitySpeechAttributeQueueAnnouncement, so it waits for VoiceOver. The announce handler posts a plain string and ignores assertiveness. 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work lista: accessibilityAccessibility, e.g. VoiceOver or TalkBack. (aka a11y)customer: money (g3)engineflutter/engine related. See also e: labels.platform-iosiOS applications specificallyteam-iosOwned by iOS platform teamtriaged-iosTriaged by iOS platform team

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions