Repository navigation
Handle newer "chosenRuntimeBuild" iOS simulator runtime key on devicelab tests - #194509
Conversation
There was a problem hiding this comment.
Code Review
This pull request updates the iOS simulator device type in uiscene_plugin_lifecycle_test_ios.dart and refactors the simulator runtime selection logic in ios.dart to use structured JSON parsing instead of regex. Feedback suggests optimizing redundant process calls to simctl list runtimes and improving the readability of error messages by formatting the list of available runtimes instead of printing raw JSON.
| await testWithNewIOSSimulator( | ||
| 'TestAdd2AppSim', | ||
| deviceTypeId: 'com.apple.CoreSimulator.SimDeviceType.iPad-Pro-11-inch-3rd-generation', | ||
| deviceTypeId: 'com.apple.CoreSimulator.SimDeviceType.iPad-Pro-11-inch-M4-8GB', |
There was a problem hiding this comment.
This should work on Xcode 26 or 27
There was a problem hiding this comment.
Code Review
This pull request updates the iOS simulator runtime selection logic in the devicelab framework to parse the output of simctl list runtimes as JSON and filter runtimes based on their compatibility with the target deviceTypeId. It also updates the simulator device type used in the iOS UI scene plugin lifecycle test. The review feedback identifies a potential regression on older Xcode versions (prior to Xcode 15) where the supportedDeviceTypes key is absent from the JSON output, and suggests making supportedDeviceTypeIds nullable while updating the parsing and filtering logic to prevent runtime errors.
hellohuanlin
left a comment
There was a problem hiding this comment.
Overall logic makes sense. Can you add some tests?
| if (json.decode(simctlListRuntimesJson) case {'runtimes': final List<Object?> runtimes}) { | ||
| return <_SimulatorRuntime>[ | ||
| for (final Object? runtime in runtimes) | ||
| if (runtime case { |
af2e9a4 to
7e1d0bc
Compare
Done. |
…lab tests (flutter#194509) Newer simctl renamed the `preferredBuild` key in `simctl runtime match list --json` to `chosenRuntimeBuild`. The devicelab only looked for the old key, so it stopped filtering by the selected Xcode and used whatever runtime was listed last. On a machine with Xcode 27.1 installed that was the iOS 27.1 runtime, which only supports the iPhone Duo device type. `simctl create` for any iPad or iPhone fails with "Incompatible device". So: - Accept `chosenRuntimeBuild` or `preferredBuild` to work on either version - Parse `simctl list runtimes --json` and only consider runtimes whose `supportedDeviceTypes` includes the requested device. Prefer the selected Xcode's runtime otherwise take the last compatible one. The `Map<String, Object?>` map parsing was getting crazy and hard to read, so instead replace with a Dart [if-case](https://dart.dev/language/branches#if-case) pattern. - Bump the iPad used by `uiscene_plugin_lifecycle_test_ios` from the 3rd gen 11-inch Pro to the M4, which should work on Xcode 26 or 27. Fixes flutter#194147 ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [AI contribution guidelines] and understand my responsibilities, or I am not using AI tools. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [x] I signed the [CLA]. - [x] I listed at least one issue that this PR fixes in the description above. - [x] I updated/added relevant in-code documentation (doc comments with `///`). - [x] If this PR introduces a new feature or capability, I created and linked a website documentation issue or PR in [flutter/website] (or verified none is needed). - [x] I added new tests to check the change I am making, or this PR is [test-exempt]. - [x] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [x] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. If this change needs to override an active code freeze, provide a comment explaining why. The code freeze workflow can be overridden by code reviewers. See pinned issues for any active code freezes with guidance. **Note**: The Flutter team is currently trialing the use of [Gemini Code Assist for GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code). Comments from the `gemini-code-assist` bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview [AI contribution guidelines]: https://github.com/flutter/flutter/blob/main/CONTRIBUTING.ai.md [Tree Hygiene]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md [test-exempt]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests [Flutter Style Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md [Features we expect every widget to implement]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [flutter/website]: https://github.com/flutter/website [breaking change policy]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md [Data Driven Fixes]: https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
Newer simctl renamed the
preferredBuildkey insimctl runtime match list --jsontochosenRuntimeBuild. The devicelab only looked for the old key, so it stopped filtering by the selected Xcode and used whatever runtime was listed last.On a machine with Xcode 27.1 installed that was the iOS 27.1 runtime, which only supports the iPhone Duo device type.
simctl createfor any iPad or iPhone fails with "Incompatible device".So:
chosenRuntimeBuildorpreferredBuildto work on either versionsimctl list runtimes --jsonand only consider runtimes whosesupportedDeviceTypesincludes the requested device. Prefer the selected Xcode's runtime otherwise take the last compatible one. TheMap<String, Object?>map parsing was getting crazy and hard to read, so instead replace with a Dart if-case pattern.uiscene_plugin_lifecycle_test_iosfrom the 3rd gen 11-inch Pro to the M4, which should work on Xcode 26 or 27.Fixes #194147
Pre-launch Checklist
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.
If this change needs to override an active code freeze, provide a comment explaining why. The code freeze workflow can be overridden by code reviewers. See pinned issues for any active code freezes with guidance.
Note: The Flutter team is currently trialing the use of Gemini Code Assist for GitHub. Comments from the
gemini-code-assistbot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.