Skip to content

[VoiceOver] Using a PageView with children that have a Semantics widget with explicitChildNodes set to true crashes on page view scrolling #53827

@dannyvalentesonos

Description

@dannyvalentesonos

When using a PageView with VoiceOver turned on, and the children are wrapped by Semantic widgets that have explicitChildNodes set to true, scrolling causes a crash almost every time.

The following code reproduces this consistently after scrolling left and right:

import 'package:flutter/material.dart';

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

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: SemanticsPageViewHomePage(),
    );
  }
}

class SemanticsPageViewHomePage extends StatefulWidget {
  const SemanticsPageViewHomePage();

  _SemanticsPageViewHomePageState createState() => _SemanticsPageViewHomePageState();
}

class _SemanticsPageViewHomePageState extends State<SemanticsPageViewHomePage> {

  List<Widget> _children = [];

  Widget _buildPage() {
    return Semantics(
      explicitChildNodes: true,
      child: Center(
        child: Column(
          mainAxisSize: MainAxisSize.min,
          children: <Widget>[
            Text("test 1"),
            Text("test 2")
          ],
        ),
      ),
    );
  }

  void _buildChildren() {
    _children.clear();
    _children.add(_buildPage());
    _children.add(_buildPage());
    _children.add(_buildPage());
  }

  @override
  void initState() {
    _buildChildren();

    super.initState();
  }

  @override
  void didUpdateWidget(SemanticsPageViewHomePage oldWidget) {
    _buildChildren();

    super.didUpdateWidget(oldWidget);
  }

  @override
  Widget build(BuildContext context) {

    return Scaffold(
        body: Column(
          mainAxisSize: MainAxisSize.max,
          children: <Widget>[
            Expanded(
              child: PageView(
                children: _children,
              ),
            ),
            Container(
              color: Colors.red,
              height: 60
            )
          ],
        )
    );
  }
}

I am testing on an iPhone 6 running iOS 12.

Metadata

Metadata

Assignees

No one assigned

    Labels

    a: accessibilityAccessibility, e.g. VoiceOver or TalkBack. (aka a11y)c: crashStack traces logged to the consoleengineflutter/engine related. See also e: labels.f: scrollingViewports, list views, slivers, etc.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onplatform-iosiOS applications specifically

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions