Skip to content

Handle simctl process exceptions during discovery - #186501

Merged
auto-submit[bot] merged 3 commits into
flutter:masterfrom
mvincentong:fix-ios-simctl-discovery
May 26, 2026
Merged

auto-submit[bot] merged 3 commits into
flutter:masterfrom
mvincentong:fix-ios-simctl-discovery

Conversation

@mvincentong

Copy link
Copy Markdown
Contributor

Issue: Fixes #153776

The crash happens when simulator discovery starts xcrun simctl list devices booted iOS --json and the process cannot be started, for example with Resource temporarily unavailable.

Fix:

  • Check Xcode.isSimctlInstalled in SimControl.getConnectedDevices before querying booted simulator JSON directly.
  • Catch ProcessException from the booted-device query, report the simctl execution error, and return no connected simulators instead of letting polling device discovery fail the tool.

Tests:

  • ../../bin/dart test test/general.shard/ios/simulators_test.dart
  • ../../bin/dart analyze lib/src/ios/simulators.dart test/general.shard/ios/simulators_test.dart

Risk:

  • Low. The change is limited to iOS simulator discovery error handling in flutter_tools.
  • Changed files: one source file and one focused test file.
  • When simctl is unavailable or temporarily fails to start, Flutter now skips simulator discovery for that poll rather than crashing.

@mvincentong
mvincentong requested a review from a team as a code owner May 14, 2026 10:03
@google-cla

google-cla Bot commented May 14, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@github-actions github-actions Bot added platform-ios iOS applications specifically tool Affects the "flutter" command-line tool. See also t: labels. team-ios Owned by iOS platform team labels May 14, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request enhances iOS simulator discovery by verifying simctl availability and adding a try-catch block for ProcessException during command execution, supported by new unit tests. A review comment suggests catching all Exception types instead of only ProcessException to ensure the background polling process remains robust against various I/O or system failures.

Comment thread packages/flutter_tools/lib/src/ios/simulators.dart
@mvincentong
mvincentong force-pushed the fix-ios-simctl-discovery branch from 676941f to 6b4e8f0 Compare May 14, 2026 10:09
@mvincentong
mvincentong force-pushed the fix-ios-simctl-discovery branch from 6b4e8f0 to 8f102e9 Compare May 14, 2026 10:11
vashworth
vashworth previously approved these changes May 19, 2026
@vashworth vashworth added the CICD Run CI/CD label May 19, 2026
@mvincentong
mvincentong changed the base branch from main to master May 21, 2026 03:02
@mvincentong
mvincentong dismissed vashworth’s stale review May 21, 2026 03:02

The base branch was changed.

@hellohuanlin hellohuanlin added CICD Run CI/CD and removed CICD Run CI/CD labels May 21, 2026
@fluttergithubbot

Copy link
Copy Markdown
Contributor

An existing Git SHA, 8f102e9edf35f49f21646a83c2140210db3acd18, was detected, and no actions were taken.

To re-trigger presubmits after closing or re-opeing a PR, or pushing a HEAD commit (i.e. with --force) that already was pushed before, push a blank commit (git commit --allow-empty -m "Trigger Build") or rebase to continue.

@hellohuanlin

Copy link
Copy Markdown
Contributor

From triage: @okorohelijah do you have time to take a look? Thanks!

@okorohelijah okorohelijah added CICD Run CI/CD and removed CICD Run CI/CD labels May 22, 2026
@fluttergithubbot

Copy link
Copy Markdown
Contributor

An existing Git SHA, 8f102e9edf35f49f21646a83c2140210db3acd18, was detected, and no actions were taken.

To re-trigger presubmits after closing or re-opeing a PR, or pushing a HEAD commit (i.e. with --force) that already was pushed before, push a blank commit (git commit --allow-empty -m "Trigger Build") or rebase to continue.

@github-actions github-actions Bot removed the CICD Run CI/CD label May 22, 2026
@okorohelijah okorohelijah added the CICD Run CI/CD label May 26, 2026
@github-actions github-actions Bot removed the CICD Run CI/CD label May 26, 2026
@okorohelijah okorohelijah added the CICD Run CI/CD label May 26, 2026
@okorohelijah okorohelijah added the autosubmit Merge PR when tree becomes green via auto submit App label May 26, 2026
@auto-submit
auto-submit Bot added this pull request to the merge queue May 26, 2026
Merged via the queue into flutter:master with commit 8c72e73 May 26, 2026
166 checks passed
@flutter-dashboard flutter-dashboard Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label May 26, 2026
auto-submit Bot pushed a commit to flutter/packages that referenced this pull request May 27, 2026
flutter/flutter@f3a4b98...c8f2f16

2026-05-27 98614782+auto-submit[bot]@users.noreply.github.com Reverts "[Flutter GPU] Add explicit draw counts (#186639)" (flutter/flutter#187170)
2026-05-27 [email protected] Roll Dart SDK from 7dcea971af6b to f3db7b7d9801 (2 revisions) (flutter/flutter#187144)
2026-05-27 [email protected] [Flutter GPU] Add explicit draw counts (flutter/flutter#186639)
2026-05-27 [email protected] Roll Skia from f9db7748563e to fa944af10f91 (1 revision) (flutter/flutter#187139)
2026-05-27 [email protected] [Flutter GPU] Flutter GPU ShaderLibrary in-place reload for shader hot reload (flutter/flutter#186793)
2026-05-27 [email protected] Roll Skia from a692cbf38952 to f9db7748563e (8 revisions) (flutter/flutter#187135)
2026-05-27 [email protected] Use local semantics tester in Material button tests (flutter/flutter#186667)
2026-05-27 [email protected] Filter out `a: text input` from `team-framework` PR triage  (flutter/flutter#187129)
2026-05-27 [email protected] [Engine] Fix silent buffer mismatch bug in FML Win32 CommandLineFromPlatform (flutter/flutter#187120)
2026-05-27 [email protected] examples: Remove unused parameters (flutter/flutter#185819)
2026-05-27 [email protected] Remove another `String.valueOf` (flutter/flutter#186628)
2026-05-27 [email protected] Print trace when skipping flavor-specific and platform-specific assets (flutter/flutter#187045)
2026-05-26 [email protected] Fix `InteractiveViewer` memory leak from undisposed `CurvedAnimation`s (flutter/flutter#185826)
2026-05-26 [email protected] Fix AccessibilityBridge startup crash on vendor-modified Android (flutter/flutter#184630)
2026-05-26 [email protected] Update data driven fixes docs (flutter/flutter#186217)
2026-05-26 [email protected] Add more 0x0 size tests part10 (flutter/flutter#186201)
2026-05-26 [email protected] Disable spell check for obscured text (flutter/flutter#186329)
2026-05-26 [email protected] [iOS] Migrate VSyncClient and DisplayLinkManager to Swift (flutter/flutter#187001)
2026-05-26 [email protected] [flutter_tools, devicelab] Add safety filesystem guard to tests (flutter/flutter#186748)
2026-05-26 [email protected] Roll Fuchsia Linux SDK from Itd2Jq_ZIABH2rW7B... to k9EizfEGJO4WwQN9-... (flutter/flutter#187115)
2026-05-26 [email protected] Roll Dart SDK from 00e625453c43 to 7dcea971af6b (1 revision) (flutter/flutter#187117)
2026-05-26 [email protected] Remove use of deprecated copy_trees. (flutter/flutter#187091)
2026-05-26 [email protected] Use resolved implementation plugins with SwiftPM (flutter/flutter#187097)
2026-05-26 [email protected] Roll Skia from 27a819894f7c to a692cbf38952 (3 revisions) (flutter/flutter#187109)
2026-05-26 [email protected] Roll Packages from 69cf959 to fc795e5 (4 revisions) (flutter/flutter#187114)
2026-05-26 [email protected] Handle simctl process exceptions during discovery (flutter/flutter#186501)
2026-05-26 [email protected] Clarify precache enabled platforms help (flutter/flutter#186878)
2026-05-26 [email protected] [tool] Refactor artifacts.dart to use enhanced enums and reduce duplication (flutter/flutter#187063)
2026-05-26 [email protected] Build script updates for syncing engine sources and building artifacts on linux-arm64 (flutter/flutter#186917)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages
Please CC [email protected],[email protected] on the revert to ensure that a human
is aware of the problem.

To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
creatorpiyush pushed a commit to creatorpiyush/packages that referenced this pull request Jun 10, 2026
…r#11795)

flutter/flutter@f3a4b98...c8f2f16

2026-05-27 98614782+auto-submit[bot]@users.noreply.github.com Reverts "[Flutter GPU] Add explicit draw counts (#186639)" (flutter/flutter#187170)
2026-05-27 [email protected] Roll Dart SDK from 7dcea971af6b to f3db7b7d9801 (2 revisions) (flutter/flutter#187144)
2026-05-27 [email protected] [Flutter GPU] Add explicit draw counts (flutter/flutter#186639)
2026-05-27 [email protected] Roll Skia from f9db7748563e to fa944af10f91 (1 revision) (flutter/flutter#187139)
2026-05-27 [email protected] [Flutter GPU] Flutter GPU ShaderLibrary in-place reload for shader hot reload (flutter/flutter#186793)
2026-05-27 [email protected] Roll Skia from a692cbf38952 to f9db7748563e (8 revisions) (flutter/flutter#187135)
2026-05-27 [email protected] Use local semantics tester in Material button tests (flutter/flutter#186667)
2026-05-27 [email protected] Filter out `a: text input` from `team-framework` PR triage  (flutter/flutter#187129)
2026-05-27 [email protected] [Engine] Fix silent buffer mismatch bug in FML Win32 CommandLineFromPlatform (flutter/flutter#187120)
2026-05-27 [email protected] examples: Remove unused parameters (flutter/flutter#185819)
2026-05-27 [email protected] Remove another `String.valueOf` (flutter/flutter#186628)
2026-05-27 [email protected] Print trace when skipping flavor-specific and platform-specific assets (flutter/flutter#187045)
2026-05-26 [email protected] Fix `InteractiveViewer` memory leak from undisposed `CurvedAnimation`s (flutter/flutter#185826)
2026-05-26 [email protected] Fix AccessibilityBridge startup crash on vendor-modified Android (flutter/flutter#184630)
2026-05-26 [email protected] Update data driven fixes docs (flutter/flutter#186217)
2026-05-26 [email protected] Add more 0x0 size tests part10 (flutter/flutter#186201)
2026-05-26 [email protected] Disable spell check for obscured text (flutter/flutter#186329)
2026-05-26 [email protected] [iOS] Migrate VSyncClient and DisplayLinkManager to Swift (flutter/flutter#187001)
2026-05-26 [email protected] [flutter_tools, devicelab] Add safety filesystem guard to tests (flutter/flutter#186748)
2026-05-26 [email protected] Roll Fuchsia Linux SDK from Itd2Jq_ZIABH2rW7B... to k9EizfEGJO4WwQN9-... (flutter/flutter#187115)
2026-05-26 [email protected] Roll Dart SDK from 00e625453c43 to 7dcea971af6b (1 revision) (flutter/flutter#187117)
2026-05-26 [email protected] Remove use of deprecated copy_trees. (flutter/flutter#187091)
2026-05-26 [email protected] Use resolved implementation plugins with SwiftPM (flutter/flutter#187097)
2026-05-26 [email protected] Roll Skia from 27a819894f7c to a692cbf38952 (3 revisions) (flutter/flutter#187109)
2026-05-26 [email protected] Roll Packages from 69cf959 to fc795e5 (4 revisions) (flutter/flutter#187114)
2026-05-26 [email protected] Handle simctl process exceptions during discovery (flutter/flutter#186501)
2026-05-26 [email protected] Clarify precache enabled platforms help (flutter/flutter#186878)
2026-05-26 [email protected] [tool] Refactor artifacts.dart to use enhanced enums and reduce duplication (flutter/flutter#187063)
2026-05-26 [email protected] Build script updates for syncing engine sources and building artifacts on linux-arm64 (flutter/flutter#186917)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages
Please CC [email protected],[email protected] on the revert to ensure that a human
is aware of the problem.

To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
via-guy pushed a commit to via-guy/flutter that referenced this pull request Jun 26, 2026
Issue: Fixes flutter#153776

The crash happens when simulator discovery starts `xcrun simctl list
devices booted iOS --json` and the process cannot be started, for
example with `Resource temporarily unavailable`.

Fix:
- Check `Xcode.isSimctlInstalled` in `SimControl.getConnectedDevices`
before querying booted simulator JSON directly.
- Catch `ProcessException` from the booted-device query, report the
simctl execution error, and return no connected simulators instead of
letting polling device discovery fail the tool.

Tests:
- `../../bin/dart test test/general.shard/ios/simulators_test.dart`
- `../../bin/dart analyze lib/src/ios/simulators.dart
test/general.shard/ios/simulators_test.dart`

Risk:
- Low. The change is limited to iOS simulator discovery error handling
in `flutter_tools`.
- Changed files: one source file and one focused test file.
- When simctl is unavailable or temporarily fails to start, Flutter now
skips simulator discovery for that poll rather than crashing.

Co-authored-by: Elijah Okoroh <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CICD Run CI/CD platform-ios iOS applications specifically team-ios Owned by iOS platform team tool Affects the "flutter" command-line tool. See also t: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

When discovering iOS devices: ProcessException: Resource temporarily unavailable

6 participants