Skip to content

[Android] Semantics live region announces when a dialog is closed (even if the content is unchanged) #166258

Open

Description

@math1man

Steps to reproduce

Internal bug b/366026080 (original context) and b/410014109 (outstanding work).

  1. Open a dialog while a live region is on screen
  2. Close the dialog

Expected results

Live region should only announce if its contents changed

Actual results

Live region announces every time, regardless of whether its content changed

Code sample

Code sample
import 'package:flutter/material.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      theme: ThemeData(useMaterial3: false),
      title: 'Flutter Demo',
      home: MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key? key, required this.title}) : super(key: key);

  final String title;

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  int _counter = 0;

  void _incrementCounter() async {
    final value = await showDialog<bool>(
      context: context,
      builder:
          (context) => AlertDialog(
            content: const Text('Are you sure?'),
            actions: [
              TextButton(
                onPressed: () {
                  Navigator.of(context).pop(true);
                },
                child: const Text('Yes'),
              ),
              TextButton(
                onPressed: () {
                  Navigator.of(context).pop(false);
                },
                child: const Text('No'),
              ),
            ],
          ),
    );
    if (mounted && value != null && value) {
      setState(() {
        _counter++;
      });
    }
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title, style: TextStyle(fontFamily: 'ProductSans')),
      ),
      body: Center(
        child: Semantics(
          liveRegion: true,
          child: Text(
            'Button tapped $_counter time${_counter == 1 ? '' : 's'}.',
            key: Key('CountText'),
          ),
        ),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: _incrementCounter,
        tooltip: 'Increment',
        child: const Icon(Icons.add),
      ),
    );
  }
}

Screenshots or Video

Screenshots / Video demonstration

https://drive.google.com/file/d/12j3ppTHzd_LrmU3MqsDU0xIfXP1nWZfO/view

When I click "yes", the text view increments and correctly announces. But when I click "no" or the dialog scrim, it announces even though the text hasn't changed.

Logs

N/A, google internal client

Flutter Doctor output

N/A, google internal client

Activity

  1. math1man commented on Mar 31, 2025

    @math1man
    ContributorAuthor
  2. maheshj01 commented on Mar 31, 2025

    @maheshj01
    Member

    Reproducible on latest stable and the master channel. The main Screen content is always announced on dialog close

    Unmute for Audio

    Screen.Recording.2025-03-31.at.18.19.48.mov
    flutter doctor -v

    master

    ✓] Flutter (Channel master, 3.31.0-1.0.pre.345, on macOS 15.1.1 24B2091 darwin-arm64, locale en-US) [2.6s]
        • Flutter version 3.31.0-1.0.pre.345 on channel master at /Users/mahesh/Development/flutter_master
        • Upstream repository https://github.com/flutter/flutter.git
        • Framework revision 9ce60b743d (2 hours ago), 2025-03-31 23:50:27 +0300
        • Engine revision 9ce60b743d
        • Dart version 3.8.0 (build 3.8.0-245.0.dev)
        • DevTools version 2.45.0-dev.0
    
    [✓] Android toolchain - develop for Android devices (Android SDK version 35.0.0) [3.1s]
        • Android SDK at /Users/mahesh/Library/Android/sdk
        • Platform android-35, build-tools 35.0.0
        • ANDROID_HOME = /Users/mahesh/Library/Android/sdk
        • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
          This is the JDK bundled with the latest Android Studio installation on this machine.
          To manually set the JDK path, use: `flutter config --jdk-dir="path/to/jdk"`.
        • Java version OpenJDK Runtime Environment (build 21.0.5+-12932927-b750.29)
        • All Android licenses accepted.
    
    [✓] Xcode - develop for iOS and macOS (Xcode 16.0) [1,745ms]
        • Xcode at /Applications/Xcode.app/Contents/Developer
        • Build 16A242d
        • CocoaPods version 1.16.2
    
    [✓] Chrome - develop for the web [147ms]
        • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
    
    [✓] Android Studio (version 2024.3) [146ms]
        • Android Studio at /Applications/Android Studio.app/Contents
        • Flutter plugin can be installed from:
          🔨 https://plugins.jetbrains.com/plugin/9212-flutter
        • Dart plugin can be installed from:
          🔨 https://plugins.jetbrains.com/plugin/6351-dart
        • Java version OpenJDK Runtime Environment (build 21.0.5+-12932927-b750.29)
    
    [✓] IntelliJ IDEA Community Edition (version 2021.2.1) [144ms]
        • IntelliJ at /Applications/IntelliJ IDEA CE.app
        • Flutter plugin version 61.2.4
        • Dart plugin version 212.5080.8
    
    [✓] VS Code (version 1.96.2) [19ms]
        • VS Code at /Applications/Visual Studio Code.app/Contents
        • Flutter extension version 3.102.0
    
    [✓] Connected device (2 available) [7.0s]
        • macOS (desktop) • macos  • darwin-arm64   • macOS 15.1.1 24B2091 darwin-arm64
        • Chrome (web)    • chrome • web-javascript • Google Chrome 131.0.6778.265
    
    [✓] Network resources [688ms]
        • All expected network resources are available.
    
    • No issues found!

    stable

    [✓] Flutter (Channel stable, 3.29.2, on macOS 15.1.1 24B2091 darwin-arm64, locale en-US) [822ms]
        • Flutter version 3.29.2 on channel stable at /Users/mahesh/Development/flutter
        • Upstream repository https://github.com/flutter/flutter.git
        • Framework revision c236373904 (2 weeks ago), 2025-03-13 16:17:06 -0400
        • Engine revision 18b71d647a
        • Dart version 3.7.2
        • DevTools version 2.42.3
    [✓] Android toolchain - develop for Android devices (Android SDK version 35.0.0) [3.2s]
        • Android SDK at /Users/mahesh/Library/Android/sdk
        • Platform android-35, build-tools 35.0.0
        • ANDROID_HOME = /Users/mahesh/Library/Android/sdk
        • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
          This is the JDK bundled with the latest Android Studio installation on this machine.
          To manually set the JDK path, use: `flutter config --jdk-dir="path/to/jdk"`.
        • Java version OpenJDK Runtime Environment (build 21.0.5+-12932927-b750.29)
        • All Android licenses accepted.
    
    [✓] Xcode - develop for iOS and macOS (Xcode 16.0) [3.1s]
        • Xcode at /Applications/Xcode.app/Contents/Developer
        • Build 16A242d
        • CocoaPods version 1.16.2
    
    [✓] Chrome - develop for the web [136ms]
        • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
    
    [✓] Android Studio (version 2024.3) [135ms]
        • Android Studio at /Applications/Android Studio.app/Contents
        • Flutter plugin can be installed from:
          🔨 https://plugins.jetbrains.com/plugin/9212-flutter
        • Dart plugin can be installed from:
          🔨 https://plugins.jetbrains.com/plugin/6351-dart
        • Java version OpenJDK Runtime Environment (build 21.0.5+-12932927-b750.29)
    
    [✓] IntelliJ IDEA Community Edition (version 2021.2.1) [134ms]
        • IntelliJ at /Applications/IntelliJ IDEA CE.app
        • Flutter plugin version 61.2.4
        • Dart plugin version 212.5080.8
    
    [✓] VS Code (version 1.96.2) [18ms]
        • VS Code at /Applications/Visual Studio Code.app/Contents
        • Flutter extension version 3.102.0
    
    [✓] Connected device (4 available) [6.7s]
        • iPad Pro 11-inch (M4) (mobile)  • A97192B5-5CFD-4164-BF2A-A6E2972614FF • ios            • com.apple.CoreSimulator.SimRuntime.iOS-18-0
          (simulator)
        • macOS (desktop)                 • macos                                • darwin-arm64   • macOS 15.1.1 24B2091 darwin-arm64
        • Mac Designed for iPad (desktop) • mac-designed-for-ipad                • darwin         • macOS 15.1.1 24B2091 darwin-arm64
        • Chrome (web)                    • chrome                               • web-javascript • Google Chrome 131.0.6778.265
    
    [✓] Network resources [294ms]
        • All expected network resources are available.
    
    ! Doctor found issues in 1 category.
  3. added
    platform-androidAndroid applications specifically
    a: accessibilityAccessibility, e.g. VoiceOver or TalkBack. (aka a11y)
    has reproducible stepsThe issue has been confirmed reproducible and is ready to work on
    team-androidOwned by Android platform team
    and removed
    in triagePresently being triaged by the triage team
    on Mar 31, 2025
  4. added
    team-accessibilityOwned by Framework Accessibility team (i.e. responsible for accessibility code in flutter/flutter)
    and removed
    team-androidOwned by Android platform team
    on Apr 1, 2025
  5. 1 remaining item

  6. added
    P1High-priority issues at the top of the work list
    on Apr 2, 2025
  7. chunhtai commented on Apr 2, 2025

    @chunhtai
    Contributor

    In native Android, navigate to a route through push and pop will re-announce the live region, but dialog won't.

    so it looks like there is some work we need to do in flutter since route and dialog are treated the same in flutter.

    Right now, a route will use BlockSemantics widget to hide the semantics for the route below, so navigating to a page will sends a new tree of semantics nodes to the android. Android will see a new live region node is created and announce it.

    To properly fix this issue, the PopupRoute's modal barrier can't use blocksemantics, but instead having a way to make the semantics node of previous route unfocusable. This may depend on #165857

  8. math1man commented on Apr 8, 2025

    @math1man
    ContributorAuthor

    Is it true that push-pop announces a live region on native Android? That's surprising to me.

  9. chunhtai commented on Apr 22, 2025

    @chunhtai
    Contributor

    @math1man yes, I tested by push a new fragment and pop.

  10. chunhtai commented on Jul 29, 2025

    @chunhtai
    Contributor

    blocked on #165857

  11. self-assigned this
    on Oct 21, 2025
  12. jmagman commented on Jan 9, 2026

    @jmagman
    Member

    Note #165857 is now fixed (thank you @hannah-hyj !).

  13. hannah-hyj commented on Mar 19, 2026

    @hannah-hyj
    Member

    This live region re-announcement issue requires a non-trivial fix, we need to refactor or replace the BlockSemantics to fix the underlying semantics tree issue , I wrote a design doc for this issue: https://docs.google.com/document/d/1niJnShCR3-PIMYo1a9lWdVySBqr_wmXYPvBXntvcc0c/edit?tab=t.0 and will start the work once the design is approved.

  14. added
    ⏳Bot is counting down the days until it unassigns the issue
    on Jul 23, 2026
  15. flutter-triage-bot commented on Jul 23, 2026

    @flutter-triage-bot

    This issue is assigned to @hannah-hyj but has had no recent status updates. Please consider unassigning this issue if it is not going to be addressed in the near future. This allows people to have a clearer picture of what work is actually planned. Thanks!

  16. removed their assignment
    on Jul 29, 2026
  17. removed
    ⏳Bot is counting down the days until it unassigns the issue
    on Jul 29, 2026
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

    P1High-priority issues at the top of the work lista: accessibilityAccessibility, e.g. VoiceOver or TalkBack. (aka a11y)customer: huggsy (g3)found in release: 3.29Found to occur in 3.29found in release: 3.31Found to occur in 3.31has reproducible stepsThe issue has been confirmed reproducible and is ready to work onplatform-androidAndroid applications specificallyteam-accessibilityOwned by Framework Accessibility team (i.e. responsible for accessibility code in flutter/flutter)triaged-accessibilityTriaged by Framework Accessibility team

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions