Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SemanticsBinding.instance.ensureSemantics causes inconsistent state for mobile #158399

Open
chunhtai opened this issue Nov 8, 2024 · 0 comments · May be fixed by flutter/engine#56691 or #159163
Open

SemanticsBinding.instance.ensureSemantics causes inconsistent state for mobile #158399

chunhtai opened this issue Nov 8, 2024 · 0 comments · May be fixed by flutter/engine#56691 or #159163
Assignees
Labels
team-accessibility Owned by Framework Accessibility team (i.e. responsible for accessibility code in flutter/flutter)

Comments

@chunhtai
Copy link
Contributor

chunhtai commented Nov 8, 2024

Steps to reproduce

import 'package:flutter/material.dart';
import 'package:flutter/semantics.dart';

void main() {
  runApp(const TabBarDemo());
  SemanticsBinding.instance.ensureSemantics();
}

class TabBarDemo extends StatelessWidget {
  const TabBarDemo({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: DefaultTabController(
        length: 3,
        child: Scaffold(
          appBar: AppBar(
            bottom: const TabBar(
              tabs: [
                Tab(icon: Icon(Icons.directions_car)),
                Tab(icon: Icon(Icons.directions_transit)),
                Tab(icon: Icon(Icons.directions_bike)),
              ],
            ),
            title: const Text('Tabs Demo'),
          ),
          body: const TabBarView(
            children: [
              Icon(Icons.directions_car),
              Icon(Icons.directions_transit),
              Icon(Icons.directions_bike),
            ],
          ),
        ),
      ),
    );
  }
}
  1. launch the app in android or ios without any assistive technologies like voiceover or talkback
  2. after the app is launched, turn on voiceover or talkback

Actual results

the talkback and voiceover can't recognize the app

Upon closer investigation this is due to that the enable flag in the engine is not flipped by calls to ensureSemantics. It will causes the engine shell to drop all semantics update.

Since the semantics update is sequential update, the accessibility tree in mobile embedding can't be constructed even after the voiceover or talkback is turned on later.

@chunhtai chunhtai self-assigned this Nov 8, 2024
@chunhtai chunhtai added the team-accessibility Owned by Framework Accessibility team (i.e. responsible for accessibility code in flutter/flutter) label Nov 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
team-accessibility Owned by Framework Accessibility team (i.e. responsible for accessibility code in flutter/flutter)
Projects
None yet
1 participant