Skip to content

[iOS] VoiceOver touch exploration loses scroll children after a partial semantics object replacement #196438

Closed

Description

@DD20-dai

Steps to reproduce

  1. Create a stock iOS app with Flutter master: flutter create --platforms=ios bug.
  2. Replace lib/main.dart with the complete sample below.
  3. Enable VoiceOver before starting a fresh app session.
  4. Directly touch Item 1. It initially receives VoiceOver focus.
  5. Touch Enable implicit scrolling, then double-tap to activate it.
  6. Directly touch Item 1 again. Do not hot reload, rebuild the page, or scroll between steps 5 and 6.

The button changes only ScrollPhysics.allowImplicitScrolling from false to true.
The direct semantics parent remains outside the rebuilding subtree; the list
contents and geometry do not change. Restart the app to repeat the one-way transition.

Expected results

Visible list items remain accessible through VoiceOver touch exploration after
the scroll semantics change.

Actual results

On the unmodified official cached engine, list items no longer receive focus
through direct touch after activating the button. The top button remains accessible.

The final pure-Dart sample was manually verified on a physical iPhone with
VoiceOver enabled. With a locally patched engine, the same steps keep Item 1 and
Item 4 accessible. The Dart sample and geometry are identical in both recordings.
The local verification engine includes diagnostic logging; the proposed upstream
fix contains no logging or workaround.

The tested SDK source revision is d9b77d26265f5130ec6b250f087289fd3dddf5bf
(the tool reports 3.51.0-0.1.pre, cached engine revision 9fd98527fd). This is
not a claim that the defect is exclusive to iOS 27; earlier diagnostic runs also
reproduced it on an iOS 27 simulator.
Both A/B builds explicitly used that checkout's Flutter executable, rather than
the other SDK on PATH mentioned in the doctor warnings below.

Code sample

The sample imports only package:flutter/widgets.dart. It needs no plugins,
platform views, native host changes, custom binding, timer, semantics mutation,
or focus request.

Complete lib/main.dart
import 'package:flutter/widgets.dart';

void main() => runApp(
  const Directionality(textDirection: TextDirection.ltr, child: TouchRepro()),
);

class ReproPhysics extends BouncingScrollPhysics {
  const ReproPhysics({required this.implicit, super.parent});

  final bool implicit;

  @override
  bool get allowImplicitScrolling => implicit;

  @override
  bool shouldUpdate(covariant BouncingScrollPhysics oldPhysics) {
    return super.shouldUpdate(oldPhysics) ||
        oldPhysics is! ReproPhysics ||
        oldPhysics.implicit != implicit;
  }

  @override
  ReproPhysics applyTo(ScrollPhysics? ancestor) {
    return ReproPhysics(implicit: implicit, parent: buildParent(ancestor));
  }
}

class TouchRepro extends StatefulWidget {
  const TouchRepro({super.key});

  @override
  State<TouchRepro> createState() => _TouchReproState();
}

class _TouchReproState extends State<TouchRepro> {
  final ValueNotifier<bool> implicit = ValueNotifier<bool>(false);

  @override
  void dispose() {
    implicit.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return DefaultTextStyle(
      style: const TextStyle(color: Color(0xff202020), fontSize: 18),
      child: ColoredBox(
        color: const Color(0xffffffff),
        child: SafeArea(
          child: Column(
            children: <Widget>[
              Semantics(
                button: true,
                excludeSemantics: true,
                label: 'Enable implicit scrolling',
                onTap: () => implicit.value = true,
                child: GestureDetector(
                  key: const ValueKey<String>('enable-implicit'),
                  onTap: () => implicit.value = true,
                  child: Container(
                    width: double.infinity,
                    color: const Color(0xffe2f0e5),
                    padding: const EdgeInsets.all(20),
                    alignment: Alignment.center,
                    child: const Text('Enable implicit scrolling'),
                  ),
                ),
              ),
              Expanded(
                // Keep this direct semantics parent outside the rebuilding subtree.
                child: Semantics(
                  container: true,
                  explicitChildNodes: true,
                  child: ValueListenableBuilder<bool>(
                    valueListenable: implicit,
                    builder: (BuildContext context, bool value, Widget? child) {
                      return CustomScrollView(
                        physics: ReproPhysics(implicit: value),
                        slivers: <Widget>[child!],
                      );
                    },
                    child: SliverList.list(
                      children: List<Widget>.generate(12, (int index) {
                        return Semantics(
                          container: true,
                          excludeSemantics: true,
                          button: true,
                          identifier: 'touch-row-${index + 1}',
                          label: 'Item ${index + 1}',
                          onTap: () =>
                              debugPrint('Activated item ${index + 1}'),
                          child: Container(
                            height: 140,
                            color: index.isEven
                                ? const Color(0xffffffff)
                                : const Color(0xffeeeeee),
                            alignment: Alignment.centerLeft,
                            padding: const EdgeInsets.all(16),
                            child: Text('Item ${index + 1}'),
                          ),
                        );
                      }),
                    ),
                  ),
                ),
              ),
            ],
          ),
        ),
      ),
    );
  }
}

Screenshots or video

Both approximately 27-second recordings use the final minimal sample, not a
separate diagnostic UI. The files are hosted as reproduction assets on my fork;
they are not an official Flutter release.

Diagnosis and proposed fix

A partial semantics update contains only the scroll node, not its unchanged
parent. Changing hasImplicitScrolling replaces the native semantics object.
SemanticsObject.replaceChildAtIndex:withChild: updates the parent's traversal
array but leaves childrenInHitTestOrder pointing to the old object. Once that
object is detached and its children are cleared, touch hit testing visits an
empty stale subtree.

The proposed fix finds the old child by identity in hit-test order and replaces
it there as well. Traversal and hit-test orders can differ, so their indices must
not be assumed equal. If the old child is absent from hit-test order, leave that
array unchanged. No parent resend, notification, forced focus, suppression,
timeout, or retry is required.

A separate read-only diagnostic run using this Dart sample confirmed:

original: initial hitUid=5 mismatches=0
original: update=[18] parent=3 parentIncluded=false hitUid=-1 mismatches=1
fixed:    initial hitUid=5 mismatches=0
fixed:    update=[18] parent=3 parentIncluded=false hitUid=5 mismatches=0

Node IDs vary by session. This automated run enabled semantics but disabled
VoiceOver, so these are native-tree observations, separate from the manual
VoiceOver recordings. The diagnostic code is not part of the shared sample.

Targeted native XCTest A/B: original implementation 5/7 pass (two regression
tests fail), patched implementation 7/7 pass. This does not claim that the entire
engine suite or upstream presubmit has passed.

Our application-level before/after testing identified #195731, upstream merge
commit
2e65ef92e4e951cdd448f1839786f87b0009058c,
as the change introducing the user-visible touch-exploration regression.
Its container hit-test forwarding exposes an existing omission in
replaceChildAtIndex:withChild:: replacement updates traversal children, but not
the parent's hit-test children. The omission predates #195731; the regression
attribution concerns the observable behavior, not the creation of those
replacement methods.

Related: #192774. This is a touch-exploration failure, not the implicit-scroll
boundary stall fixed by #195731.

Proposed fix: #196439. This also differs from #194389: there is no platform view
or native subcontrol in this sample.

The updated PR also explicitly handles a nil hit-test array. A focused iOS 26.4.1
simulator run passes 8/8 tests, including a test that rejects unnecessary setter
calls when that array is nil. This does not claim full engine presubmit coverage.

Flutter Doctor output

Doctor output (local paths redacted; warnings retained)
[!] Flutter (Channel [user-branch], 3.51.0-0.1.pre, on macOS 27.0 26A428 darwin-arm64, locale zh-Hans-CN) [5.8s]
    ! Flutter version 3.51.0-0.1.pre on channel [user-branch] at /Users/USER/Desktop/VoiceOverTools/flutter-official-master
      Currently on an unknown channel. Run `flutter channel` to switch to an official channel.
      If that doesn't fix the issue, try deleting the 'bin/cache/flutter.version.json' file in your Flutter SDK directory and then reinstall Flutter by following instructions at https://flutter.dev/setup.
    ! Warning: `flutter` on your path resolves to [other-sdk]/bin/flutter, which is not inside your current Flutter SDK checkout at /Users/USER/Desktop/VoiceOverTools/flutter-official-master. Consider adding /Users/USER/Desktop/VoiceOverTools/flutter-official-master/bin to the front of your path.
    ! Warning: `dart` on your path resolves to [other-sdk]/bin/dart, which is not inside your current Flutter SDK checkout at /Users/USER/Desktop/VoiceOverTools/flutter-official-master. Consider adding /Users/USER/Desktop/VoiceOverTools/flutter-official-master/bin to the front of your path.
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision d9b77d2626 (32 hours ago), 2026-11-11 01:12:41 +0000
    • Engine revision 9fd98527fd
    • Dart version 3.15.0 (build 3.15.0-135.0.dev)
    • DevTools version 2.63.0-dev.0
    • Feature flags: enable-web, enable-linux-desktop, enable-macos-desktop, enable-windows-desktop, enable-android, enable-ios, cli-animations, enable-native-assets, enable-record-use, enable-swift-package-manager, omit-legacy-version-file, enable-lldb-debugging, enable-uiscene-migration, enable-riscv64, enable-hcpp
    • If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly to perform update checks and upgrades.

[!] Android toolchain - develop for Android devices (Android SDK version 35.0.0) [3.6s]
    • Android SDK at /Users/USER/Library/Android/sdk
    • Emulator version 35.1.4.0 (build_id 11672324) (CL:N/A)
    • Platform android-36, build-tools 35.0.0
    • ANDROID_HOME = /Users/USER/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 17.0.9+0-17.0.9b1087.7-11185874)
    ! Some Android licenses not accepted. To resolve this, run: flutter doctor --android-licenses

[✓] Xcode - develop for iOS and macOS (Xcode 27.1) [1,632ms]
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 27A9269
    • CocoaPods version 1.16.2

[✓] Chrome - develop for the web [6ms]
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[☠] Connected device (the doctor check crashed)
    ✗ Due to an error, the doctor check did not complete. If the error message below is not helpful, please let us know about this issue at https://github.com/flutter/flutter/issues
    ✗ Exception: Connected device exceeded maximum allowed duration of 0:04:30.000000
    •

[✓] Network resources [1,664ms]
    • All expected network resources are available.

! Doctor found issues in 3 categories.

Activity

  1. added
    platform-ios
    engine
    a: accessibility
    fyi-ios
    team-accessibility
    has reproducible steps
    on Nov 12, 2026
  2. mbcorona commented on Nov 12, 2026

    @mbcorona
    Member

    Thanks for the thorough diagnosis and the recordings @DD20-dai.

    Routing to the accessibility team.

  3. LongCatIsLooong commented on Nov 16, 2026

    @LongCatIsLooong
    Contributor

    The fix to this should be cherry picked if we were to CP #195731, I think #195731 made this issue much easier to reproduce. Without that patch the issue is pretty much only reproducible when you are doing a11y hit testing in a Stack or Overlay. But since #195731 overrode the a11y hit-testing method on the container, you just have to toggle hasImplicitScrolling to repro I think.

  4. added
    triaged-accessibility
    team-ios
    fyi-accessibility
    and removed
    fyi-ios
    team-accessibility
    on Nov 18, 2026
  5. removed
    fyi-accessibility
    triaged-accessibility
    on Nov 18, 2026
  6. added
    triaged-ios
    P1
    on Nov 19, 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

    P1a: accessibilityenginehas reproducible stepsplatform-iosteam-iostriaged-ios

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions