Skip to content

[iOS] Flakey race condition between SetSemanticsTreeEnabled and UpdateSemantics #174842

Closed

Description

@vashworth

Steps to reproduce

  1. flutter create my_app
  2. cd my_app
  3. et run --config ios_debug_sim_unopt_arm64
  4. Quit the app once it launches
  5. Open my_app/ios/Runner.xcworkspace
  6. In Xcode do Product > Run

Note: Error does not always happen since it's a race condition, you may need to do step 6 multiple times. It is more likely to happen if you setup UIScene in your Info.plist, but I have seen it happen for both. Also, the crash can also happen when running from the Flutter CLI, but running from Xcode is faster and allows you to see the error log.

Expected results

App should run fine when using a local engine

Actual results

App crashes

[FATAL:flutter/shell/platform/darwin/ios/platform_view_ios.mm(156)] Check failed: accessibility_bridge_.

I tried tracing it down and it appears that occasionally FlutterEngine enables semantics before the _handleFrameworkSemanticsEnabledChanged listener is set up.

- (void)enableSemantics:(BOOL)enabled withFlags:(int64_t)flags {
if (!self.platformView) {
return;
}
self.platformView->SetSemanticsEnabled(enabled);
self.platformView->SetAccessibilityFeatures(flags);
}

addSemanticsEnabledListener(_handleFrameworkSemanticsEnabledChanged);

And therefore, the semantics tree is never enabled:

void _handleFrameworkSemanticsEnabledChanged() {
platformDispatcher.setSemanticsTreeEnabled(semanticsEnabled);
}

Likely caused by #174163.

Code sample

Use default flutter create sample app

Screenshots or Video

No response

Logs

No response

Flutter Doctor output

Doctor output
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel main, 3.36.0-1.0.pre-348, on macOS 15.6.1 24G90 darwin-arm64, locale en)
[✓] Android toolchain - develop for Android devices (Android SDK version 35.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 16.3)
[✓] Chrome - develop for the web
[✓] Connected device (4 available)
[✓] Network resources

• No issues found!

Activity

  1. added
    platform-iosiOS applications specifically
    team-accessibilityOwned by Framework Accessibility team (i.e. responsible for accessibility code in flutter/flutter)
    engineflutter/engine related. See also e: labels.
    on Sep 2, 2025
  2. vashworth commented on Sep 2, 2025

    @vashworth
    ContributorAuthor

    I think this is likely also impacting non-local engine apps, but that's the use case I discovered it with.

    cc @chunhtai Do you think this warrants a revert of #174163?

  3. chunhtai commented on Sep 2, 2025

    @chunhtai
    Contributor

    Let me take a look, this seems like a bug that surface by the change. If i can't figure out something quick, I will revert

  4. chunhtai commented on Sep 2, 2025

    @chunhtai
    Contributor

    actually this seems like a corner case in the pr #174163, but should be a easy fix. I will attempt to fix forward due to the initial pr requires g3fix. Let me know otherwise

  5. added
    P0Critical issues such as a build break or regression
    on Sep 2, 2025
  6. chunhtai commented on Sep 2, 2025

    @chunhtai
    Contributor

    mark it as P0 since this is serious

  7. github-actions commented on Sep 16, 2025

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  8. locked as resolved and limited conversation to collaborators on Sep 16, 2025
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

    P0Critical issues such as a build break or regressione: local-engine-developmentLocal builds of the engine working betterengineflutter/engine related. See also e: labels.platform-iosiOS 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

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions