Skip to content

Dart SDK roll for 2018-10-18 - #1

Closed
bkonyi wants to merge 2 commits into
masterfrom
dart-sdk-roll-2018-10-18
Closed

bkonyi wants to merge 2 commits into
masterfrom
dart-sdk-roll-2018-10-18

Conversation

@bkonyi

@bkonyi bkonyi commented Oct 18, 2018

Copy link
Copy Markdown
Owner

This is an automated pull request which will automatically merge once checks pass.

@@ -1 +1 @@
104f0572802c9304b9e0f655b3d44cac5a4f4ca0
d39a0bd60855990b5cea23a854543e072a8bd457 No newline at end of file

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

@brkonyi brkonyi closed this Oct 18, 2018
@brkonyi
brkonyi deleted the dart-sdk-roll-2018-10-18 branch October 18, 2018 22:47
bkonyi pushed a commit that referenced this pull request May 20, 2026
This patch:
1. Updates the `-mios-simulator-version-min` ldflag to `15.0` (this
fixes the crash during test discovery).
2. refactors swiftc.py a bit, moves the target triplet logic from
darwin/BUILD.gn to swiftc.py so you can override the ios version in a
test target (but it's not absolutely necessary for this change since
it's the linker flag that makes the difference).
3. Migrates a few xctest tests to swift testing tests. The names of the
tests are kept as-is so the diff is easier to read.


### The Crash 
```
(lldb) bt
* thread flutter#9, name = '[Swift Testing] test discovery - loading test #0 (Task 3)', queue = 'com.apple.root.user-initiated-qos.cooperative', stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
  * frame #0: 0x0000000000000000 
    frame #1: 0x000000010ad0fb80 libios_test_flutter.dylib`closure #1() in variable initialization expression of static AccessibilityFeaturesTests.$s22ios_test_flutter_swift26AccessibilityFeaturesTestsV43accessibilityFeatureFlagRawValuesAreCorrect4TestfMp_24accessorc8120add5c86a9e3fMu_ at @__swiftmacro_22ios_test_flutter_swift26AccessibilityFeaturesTestsV43accessibilityFeatureFlagRawValuesAreCorrect4TestfMp_.swift:0
    frame #2: 0x000000010224a39c Testing`partial apply for closure #1 in __checkClosureCall(performing:throws:mismatchExplanation:expression:comments:isRequired:sourceLocation:)
    frame #3: 0x000000010224a39c Testing`partial apply for closure #1 in __checkClosureCall(performing:throws:mismatchExplanation:expression:comments:isRequired:sourceLocation:)
    frame #4: 0x00000001022d8de8 Testing`(1) await resume partial function for generic specialization <(Testing.Test, Testing.Runner.Plan.Action)> of reabstraction thunk helper <τ_0_0 where τ_0_0: Swift.Sendable> from @escaping @isolated(any) @callee_guaranteed @async () -> (@out τ_0_0) to @escaping @callee_guaranteed @async () -> (@out τ_0_0, @error @owned Swift.Error)
    frame #5: 0x000000010224ae24 Testing`closure #1 in __checkClosureCall(throws:performing:expression:comments:isRequired:sourceLocation:)
```

Initially I thought swift testing doesn't support test discovery in
linked dylibs but it's apparently not the case. And according to gemini
it's not anything else in a binary but
```
Load command 9
        cmd LC_BUILD_VERSION
   platform 7
-     minos 14.0
+     minos 15.6
        sdk 26.4
```

As it tried to use `15.6` in `swift_flags` and put `14.0` in `ldflags`
and hit the same crash.

This is what gemini has to say:
> This is the definitive end of the road! 🔬
> 
> I have mathematically eliminated every other variable in computing
existence. Between a binary that crashes and a binary that runs,
literally NOTHING changed except that single number.


Also it thinks it's because of this in `dyld`:
> Look at the code in dyldMain.cpp at Line 430:
> 
> cpp
> // dyldMain.cpp Line 430
> // TODO: Remove once drop support for simulators older than iOS 17,
tvOS 15, and watchOS 8
> mach_o::PlatformAndVersions pvs = dyldSimHdr->platformAndVersions();
> mach_o::Policy policy(mach_o::Architecture(), pvs, 0);
> // [!!] THE SMOKING GUN [!!]
> // Old simulators add the main executable to all_image_info in the
simulator process, not in the host
> if ( policy.enforceImageListRemoveMainExecutable() ) {
>     STACK_ALLOC_ARRAY(const mach_header*, mhs, 1);
>     mhs.push_back(state.config.process.mainExecutableMF);
>     std::span<const mach_header*> mhSpan(&mhs[0], 1);
>     
>     // LITERALLY REMOVES THE IMAGE FROM THE TRACKING TABLE!!
> state.externallyViewable->removeImages(state.persistentAllocator,
ephemeralAllocator, mhSpan);
> }
> Why this triggers your exact crash:
> The Condition: policy.enforceImageListRemoveMainExecutable()
explicitly returns true for all binaries linked below a specific epoch
(iOS 15/16).
> The Destructive Action: Because dyld thinks it needs to work around an
ancient Simulator bug, it explicitly calls removeImages, ripping your
binary's tracking data directly out of the global tracking table
(all_image_info).
> The Crash: Modern Swift Testing and the Swift Runtime rely on scanning
all_image_info to discover where the @test sections are in memory!
> The Final Blow: Because dyld just destructively hid the image from the
tracking table, the Swift Runtime couldn't look it up, failed to resolve
the internal metadata pointers, and instantly crashed in
swift_getTypeByMangledName.
> By simply lying and writing minos 15.0 into the header, you caused
policy.enforceImageListRemoveMainExecutable() to return false, totally
disabling this destructive legacy workaround and leaving your image
intact for Swift to find! 🔬🏆🏁

## Pre-launch Checklist

- [ ] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [ ] I read the [AI contribution guidelines] and understand my
responsibilities, or I am not using AI tools.
- [ ] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [ ] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [ ] I signed the [CLA].
- [ ] I listed at least one issue that this PR fixes in the description
above.
- [ ] I updated/added relevant documentation (doc comments with `///`).
- [ ] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [ ] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [ ] 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/docs/contributing/Tree-hygiene.md#ai-contribution-guidelines
[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
[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
bkonyi pushed a commit that referenced this pull request Jun 1, 2026
flutter#187370)

…gine (flutter#187268)"

Reason for revert: removal of some snapshot binaries break mac code
signing

Looks like the removal of the MCP server snapshot (and others) caused
the codesigning failure.

Log from the Dart SDK roll that was in the reverted patch:
https://dart.googlesource.com/sdk.git/+log/6833224264116d1becc20dd037d6c25c92194612..3cdc25e8ffe98c61b36af485573639dc833b75cb

Failure logs for arm64 and x64 bots both show the same errors:
*
https://ci.chromium.org/ui/p/flutter/builders/prod/Mac_arm64%20verify_binaries_pre_codesigned/5308
*
https://ci.chromium.org/ui/p/flutter/builders/prod/Mac_x64%20verify_binaries_pre_codesigned/5305/overview

Errors:
```
Expected binaries not found in cache:

/Volumes/Work/s/w/ir/x/w/flutter/bin/cache/dart-sdk/bin/snapshots/analysis_server.dart.snapshot
/Volumes/Work/s/w/ir/x/w/flutter/bin/cache/dart-sdk/bin/snapshots/dart_mcp_server_aot.dart.snapshot
/Volumes/Work/s/w/ir/x/w/flutter/bin/cache/dart-sdk/bin/snapshots/dartdevc.dart.snapshot
/Volumes/Work/s/w/ir/x/w/flutter/bin/cache/dart-sdk/bin/snapshots/kernel-service.dart.snapshot

If this commit is removing binaries from the cache, this test should be fixed by
removing the relevant entry from either the "binariesWithEntitlements" or
"binariesWithoutEntitlements" getters in dev/tools/lib/codesign.dart.
╔═╡ERROR #1╞════════════════════════════════════════════════════════════════════
║ UNEXPECTED ERROR!
║ Exception: Did not find all expected binaries!
║ #0      verifyExist (file:///Volumes/Work/s/w/ir/x/w/flutter/dev/bots/suite_runners/run_verify_binaries_codesigned_tests.dart:231:5)
║ <asynchronous suspension>
║ #1      verifyPreCodesignedTestRunner (file:///Volumes/Work/s/w/ir/x/w/flutter/dev/bots/suite_runners/run_verify_binaries_codesigned_tests.dart:40:3)
║ <asynchronous suspension>
║ #2      _runFromList (file:///Volumes/Work/s/w/ir/x/w/flutter/dev/bots/utils.dart:727:7)
║ <asynchronous suspension>
║ #3      main (file:///Volumes/Work/s/w/ir/x/w/flutter/dev/bots/test.dart:123:5)
║ <asynchronous suspension>
║ 
║ The test.dart script should be corrected to catch this error and call foundError().
║ Some tests are likely to have been skipped.
╚═══════════════════════════════════════════════════════════════════════════════
Step failed (retcode: 255)
```

This reverts commit 6d7a865.

<!--
Thanks for filing a pull request!
Reviewers are typically assigned within a week of filing a request.
To learn more about code review, see our documentation on Tree Hygiene:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md
-->

## 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].
- [ ] I listed at least one issue that this PR fixes in the description
above.
- [X] I updated/added relevant documentation (doc comments with `///`).
- [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/docs/contributing/Tree-hygiene.md#ai-contribution-guidelines
[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
[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
bkonyi pushed a commit that referenced this pull request Jun 2, 2026
Fixes flutter#184725

This PR makes the tool exit when building with XCode and we didn't parse
any build setting. I understand that there are no cases where this map
can be empty, as it includes the app bundle ID, which is required when
building.

If we don't exit, it can show unrelated error messages to the users
which could be confusing and hard to debug.
For instance, from the linked issue, one could end up getting: `No valid
code signing certificates were found` simply because the development
team build setting was not available, despite having valid certificates
installed.

Sample output:
```
[  +63 ms] executing: [/Users/admin/builds/AEFj1IwjB/0/repo/ios/Runner.xcodeproj/] /usr/bin/arch -arm64e xcrun xcodebuild -project /Users/admin/builds/AEFj1IwjB/0/repo/ios/Runner.xcodeproj -scheme Runner -configuration Release -destination generic/platform=iOS -showBuildSettings BUILD_DIR=/Users/admin/builds/AEFj1IwjB/0/repo/build/ios
[        ] executing: [/Users/admin/builds/AEFj1IwjB/0/repo/ios/Runner.xcodeproj/] /usr/bin/arch -arm64e xcrun xcodebuild -project /Users/admin/builds/AEFj1IwjB/0/repo/ios/Runner.xcodeproj -scheme Runner -configuration Release -destination generic/platform=iOS -showBuildSettings BUILD_DIR=/Users/admin/builds/AEFj1IwjB/0/repo/build/ios
[ +765 ms] Command line invocation:
               /Applications/Xcode-26.3.0.app/Contents/Developer/usr/bin/xcodebuild -project /Users/admin/builds/AEFj1IwjB/0/repo/ios/Runner.xcodeproj -scheme Runner -configuration Release -destination generic/platform=iOS -showBuildSettings BUILD_DIR=/Users/admin/builds/AEFj1IwjB/0/repo/build/ios
           Build settings from command line:
               BUILD_DIR = /Users/admin/builds/AEFj1IwjB/0/repo/build/ios
           2026-04-06 17:36:53.692 xcodebuild[9020:45597] Writing error result bundle to /var/folders/4p/084k9rr96ld_w60n8rdr0wtm0000gn/T/ResultBundle_2026-06-04_17-36-0053.xcresult
           xcodebuild: error: Could not configure request to show build settings: Unable to find a destination matching the provided destination specifier:
           		{ generic:1, platform:iOS }
           	Ineligible destinations for the "Runner" scheme:
           		{ platform:iOS, id:dvtdevice-DVTiPhonePlaceholder-iphoneos:placeholder, name:Any iOS Device, error:iOS 26.2 is not installed. Please download and install the platform from Xcode > Settings > Components. }
[        ] Unexpected failure to get Xcode build settings: ProcessException: Process exited abnormally with exit code 64:
           Command line invocation:
               /Applications/Xcode-26.3.0.app/Contents/Developer/usr/bin/xcodebuild -project /Users/admin/builds/AEFj1IwjB/0/repo/ios/Runner.xcodeproj -scheme Runner -configuration Release -destination generic/platform=iOS -showBuildSettings BUILD_DIR=/Users/admin/builds/AEFj1IwjB/0/repo/build/ios
           Build settings from command line:
               BUILD_DIR = /Users/admin/builds/AEFj1IwjB/0/repo/build/ios
           2026-04-06 17:36:53.692 xcodebuild[9020:45597] Writing error result bundle to /var/folders/4p/084k9rr96ld_w60n8rdr0wtm0000gn/T/ResultBundle_2026-06-04_17-36-0053.xcresult
           xcodebuild: error: Could not configure request to show build settings: Unable to find a destination matching the provided destination specifier:
           		{ generic:1, platform:iOS }
           	Ineligible destinations for the "Runner" scheme:
           		{ platform:iOS, id:dvtdevice-DVTiPhonePlaceholder-iphoneos:placeholder, name:Any iOS Device, error:iOS 26.2 is not installed. Please download and install the platform from Xcode > Settings > Components. }
             Command: /usr/bin/arch -arm64e xcrun xcodebuild -project /Users/admin/builds/AEFj1IwjB/0/repo/ios/Runner.xcodeproj -scheme Runner -configuration Release -destination generic/platform=iOS -showBuildSettings BUILD_DIR=/Users/admin/builds/AEFj1IwjB/0/repo/build/ios.
[   +2 ms] Archiving example.com.myapp...
[  +25 ms] Migrating AppFrameworkInfo.plist contents
[        ] Upgrading AppFrameworkInfo.plist
[        ] Upgrading Podfile
[   +9 ms] The Swift Package Manager feature is off. Skipping the migration that adds Swift Package Manager integration...
[   +6 ms] executing: xattr -r -d com.apple.FinderInfo /Users/admin/builds/AEFj1IwjB/0/repo
[+1948 ms] Failed to remove xattr com.apple.FinderInfo from /Users/admin/builds/AEFj1IwjB/0/repo
[   +1 ms] executing: [/Users/admin/builds/AEFj1IwjB/0/repo/ios/Runner.xcodeproj/] /usr/bin/arch -arm64e xcrun xcodebuild -project /Users/admin/builds/AEFj1IwjB/0/repo/ios/Runner.xcodeproj -scheme Runner -configuration Release -destination generic/platform=iOS -showBuildSettings BUILD_DIR=/Users/admin/builds/AEFj1IwjB/0/repo/build/ios
[        ] executing: [/Users/admin/builds/AEFj1IwjB/0/repo/ios/Runner.xcodeproj/] /usr/bin/arch -arm64e xcrun xcodebuild -project /Users/admin/builds/AEFj1IwjB/0/repo/ios/Runner.xcodeproj -scheme Runner -configuration Release -destination generic/platform=iOS -showBuildSettings BUILD_DIR=/Users/admin/builds/AEFj1IwjB/0/repo/build/ios
[ +920 ms] Command line invocation:
               /Applications/Xcode-26.3.0.app/Contents/Developer/usr/bin/xcodebuild -project /Users/admin/builds/AEFj1IwjB/0/repo/ios/Runner.xcodeproj -scheme Runner -configuration Release -destination generic/platform=iOS -showBuildSettings BUILD_DIR=/Users/admin/builds/AEFj1IwjB/0/repo/build/ios
           Build settings from command line:
               BUILD_DIR = /Users/admin/builds/AEFj1IwjB/0/repo/build/ios
           2026-04-06 17:36:56.608 xcodebuild[9023:45646] Writing error result bundle to /var/folders/4p/084k9rr96ld_w60n8rdr0wtm0000gn/T/ResultBundle_2026-06-04_17-36-0056.xcresult
           xcodebuild: error: Could not configure request to show build settings: Unable to find a destination matching the provided destination specifier:
           		{ generic:1, platform:iOS }
           	Ineligible destinations for the "Runner" scheme:
           		{ platform:iOS, id:dvtdevice-DVTiPhonePlaceholder-iphoneos:placeholder, name:Any iOS Device, error:iOS 26.2 is not installed. Please download and install the platform from Xcode > Settings > Components. }
[        ] Unexpected failure to get Xcode build settings: ProcessException: Process exited abnormally with exit code 64:
           Command line invocation:
               /Applications/Xcode-26.3.0.app/Contents/Developer/usr/bin/xcodebuild -project /Users/admin/builds/AEFj1IwjB/0/repo/ios/Runner.xcodeproj -scheme Runner -configuration Release -destination generic/platform=iOS -showBuildSettings BUILD_DIR=/Users/admin/builds/AEFj1IwjB/0/repo/build/ios
           Build settings from command line:
               BUILD_DIR = /Users/admin/builds/AEFj1IwjB/0/repo/build/ios
           2026-04-06 17:36:56.608 xcodebuild[9023:45646] Writing error result bundle to /var/folders/4p/084k9rr96ld_w60n8rdr0wtm0000gn/T/ResultBundle_2026-06-04_17-36-0056.xcresult
           xcodebuild: error: Could not configure request to show build settings: Unable to find a destination matching the provided destination specifier:
           		{ generic:1, platform:iOS }
           	Ineligible destinations for the "Runner" scheme:
           		{ platform:iOS, id:dvtdevice-DVTiPhonePlaceholder-iphoneos:placeholder, name:Any iOS Device, error:iOS 26.2 is not installed. Please download and install the platform from Xcode > Settings > Components. }
             Command: /usr/bin/arch -arm64e xcrun xcodebuild -project /Users/admin/builds/AEFj1IwjB/0/repo/ios/Runner.xcodeproj -scheme Runner -configuration Release -destination generic/platform=iOS -showBuildSettings BUILD_DIR=/Users/admin/builds/AEFj1IwjB/0/repo/build/ios.
[  +66 ms] executing: which security
[   +4 ms] executing: which openssl
[  +22 ms] executing: security find-identity -p codesigning -v
[  +57 ms]   1) <ID> "Apple Distribution: ACME. (<ID>)"
                1 valid identities found
[   +1 ms] ════════════════════════════════════════════════════════════════════════════════
           No valid code signing certificates were found
           You can connect to your Apple Developer account by signing in with your Apple ID
           in Xcode and create an iOS Development Certificate as well as a Provisioning 
           Profile for your project by:
             1- Open the Flutter project's Xcode target with
                  open ios/Runner.xcworkspace
             2- Select the 'Runner' project in the navigator then the 'Runner' target
                in the project settings
             3- Make sure a 'Development Team' is selected under Signing & Capabilities > Team. 
                You may need to:
                    - Log in with your Apple ID in Xcode first
                    - Ensure you have a valid unique Bundle ID
                    - Register your device with your Apple Developer Account
                    - Let Xcode automatically provision a profile for your app
             4- Build or run your project again
             5- Trust your newly created Development Certificate on your iOS device
                via Settings > General > Device Management > [your new certificate] > Trust
           For more information, please visit:
             https://developer.apple.com/library/content/documentation/IDEs/Conceptual/
             AppDistributionGuide/MaintainingCertificates/MaintainingCertificates.html
           Or run on an iOS simulator without code signing
           ════════════════════════════════════════════════════════════════════════════════
[   +1 ms] "flutter ipa" took 7,479ms.
[   +2 ms] executing: sw_vers -productName
[   +8 ms] Exit code 0 from: sw_vers -productName
[        ] macOS
[        ] executing: sw_vers -productVersion
[   +6 ms] Exit code 0 from: sw_vers -productVersion
[        ] 26.0
[        ] executing: sw_vers -buildVersion
[   +6 ms] Exit code 0 from: sw_vers -buildVersion
[        ] 25A354
[        ] executing: uname -m
[  +10 ms] Exit code 0 from: uname -m
[        ] arm64
[  +20 ms] No development certificates available to code sign app for device deployment
[        ] 
           #0      throwToolExit (package:flutter_tools/src/base/common.dart:34:3)
           #1      XcodeCodeSigningSettings._getCodeSigningBuildSettings (package:flutter_tools/src/ios/code_signing.dart:340:9)
           <asynchronous suspension>
           #2      buildXcodeProject (package:flutter_tools/src/ios/mac.dart:322:26)
           <asynchronous suspension>
           #3      _BuildIOSSubCommand.runCommand (package:flutter_tools/src/commands/build_ios.dart:986:37)
           <asynchronous suspension>
           #4      BuildIOSArchiveCommand.runCommand (package:flutter_tools/src/commands/build_ios.dart:477:50)
           <asynchronous suspension>
           #5      FlutterCommand.run.<anonymous closure> (package:flutter_tools/src/runner/flutter_command.dart:1590:27)
           <asynchronous suspension>
           #6      AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:154:19)
           <asynchronous suspension>
           flutter#7      CommandRunner.runCommand (package:args/command_runner.dart:212:13)
           <asynchronous suspension>
           flutter#8      FlutterCommandRunner.runCommand.<anonymous closure> (package:flutter_tools/src/runner/flutter_command_runner.dart:496:9)
           <asynchronous suspension>
           flutter#9      AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:154:19)
           <asynchronous suspension>
           flutter#10     FlutterCommandRunner.runCommand (package:flutter_tools/src/runner/flutter_command_runner.dart:431:5)
           <asynchronous suspension>
           flutter#11     FlutterCommandRunner.run.<anonymous closure> (package:flutter_tools/src/runner/flutter_command_runner.dart:307:33)
           <asynchronous suspension>
           flutter#12     run.<anonymous closure>.<anonymous closure> (package:flutter_tools/runner.dart:104:11)
           <asynchronous suspension>
           flutter#13     AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:154:19)
           <asynchronous suspension>
           flutter#14     main (package:flutter_tools/executable.dart:103:3)
           <asynchronous suspension>
[        ] Running 2 shutdown hooks
[        ] Shutdown hooks complete
[  +56 ms] exiting with code 1
```

## 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 documentation (doc comments with `///`).
- [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].

**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/docs/contributing/Tree-hygiene.md#ai-contribution-guidelines
[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
[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

---------

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: Elijah Okoroh <[email protected]>
bkonyi pushed a commit that referenced this pull request Aug 12, 2026
…on documentation (flutter#190842)

There are 2 files in this pr. One is a document the ai used to keep
track of work. More importantly it acts kind of like issues so it
references the items in future prs. The second is user facing website
documentation. I do not know if we will use it verbatim but for the set
of prs lets treat that md doc as human understandable documentation that
we must understand before landing the next pr.

Reviewers: When the pr is out of draft and your comments are fully
addressed please prioritize this pr over other work. The review bar is
higher, the number of reviews has more people and the work for the next
pr is already done.
 - @reidbaker 
---
Standard review context for this pr stack

This is PR is part of an 11 pr stack to migrate the "newdsl"
`gradle-api` specifically in agp 9.1.0.
The complete stack has pass pre submits, post submits and customer
tests.
https://flutter-dashboard.appspot.com/#/build?repo=flutter&branch=experimental/agp-gradle-api

All of the code was LLM authored. A mix of manual prompting, automatic
prompting, several models and adversarial review. The combined sessions
are enough that I cannot include relevant prompts like I have been doing
on other prs.

If you want to review the pr stack you can find it here. These prs will
be abandoned/closed as prs land into flutter/flutter.
1. reidbaker-agent#1 (branch:
agp-api-doc)
2. reidbaker-agent#2 (branch:
agp-internal-utils)
3. reidbaker-agent#3 (branch:
agp-buildmode-deps)
4. reidbaker-agent#4 (branch:
agp-plugin-buildtypes)
5. reidbaker-agent#5 (branch:
agp-ndk-fallback)
6. reidbaker-agent#6 (branch:
agp-assets-onvariants)
7. reidbaker-agent#7 (branch:
agp-apk-copy-versioncode)
8. reidbaker-agent#8 (branch:
agp-add-to-app)
9. reidbaker-agent#9 (branch:
agp-aar-script)
10. reidbaker-agent#10 (branch:
agp-newdsl-flip)
11. reidbaker-agent#11 (branch:
agp-gradle-api)

Follow up work is tracked in
flutter#190964

This work is urgent in the sense that we are worried that android will
publish agp 10 with no opt out but not so urgent that we are willing to
break flutter users because we didn't review or understand the code
because we were in a rush.

Breaking changes are expected as part of this work. There are patterns
the android team explicitly does not want apps to use and apis that have
no equivalent.

As part of the effort to ensure this work does not slip into ai slop,
prs from this stack will be reviewed by me (@reidbaker) before asking
for review. Then we will have 2 android expert reviewers also review the
every pr.

---
Agent authored pr description
This is PR 1 of 11 in the AGP 9.1.0 / public `gradle-api` migration
stack.

It adds the contributor-facing and website draft documentation for the
Flutter Gradle Plugin's migration to the Android Gradle Plugin public
Variant API, which unblocks building Flutter Android apps with AGP's
`newDsl=true` enabled.

Part of flutter#180137 and flutter#166550.

## 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 documentation (doc comments with `///`).
- [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.

---------

Co-authored-by: reidbaker-agent <[email protected]>
bkonyi pushed a commit that referenced this pull request Sep 15, 2026
…#192650)

Fixes flutter#192227

**Problem**

`AppDomain.launch` sends the `app.start` event, which carries the app
ID, before `ResidentRunner.run()` has compiled and called
`generator.accept()`. A client that acts on that ID immediately can land
an `app.restart` in the gap, producing a `recompile` against a compiler
with no accepted baseline. `frontend_server` then crashes on
`lastKnownGoodResult!`, and the app fails to start.

**Fix**

`AppDomain.restart` now waits on a new `AppInstance.started` before
entering the debounce queue, so the compiler is never asked to recompile
before it has a baseline.

**Demo**

No URLs: the bug is in the `flutter run --machine` daemon protocol, not
in rendered output, so a deployed build has no daemon to race.

Verified locally with a harness that sends `app.restart` during the
initial compile, which is the window this closes. Before, it reproduces
the exact trace from the issue and the app
dies:

    Null check operator used on a null value
#0 FrontendCompiler.writeJavaScriptBundle (frontend_server.dart:1100)
#1 FrontendCompiler.recompileDelta (frontend_server.dart:1312)
#2 listenAndCompile.<anonymous closure> (frontend_server.dart:1806)
    App failed to start

After, the restart is held until `app.started` and returns `code: 0`.
bkonyi pushed a commit that referenced this pull request Sep 26, 2026
Fixes flutter#110488.

### Background: The `testWidgets` Lifecycle
Understanding this change requires distinguishing between two layers of
`Future`s and two distinct verification steps in `testWidgets`:

#### 1. Two Layers of `Future`s
* **`testBody()` Future**: The closure containing the user's test logic.
* **`runTest()` Future**: The overall async harness returned by
`binding.runTest()`. It manages the test zone, unmounts the widget tree,
and resolves only after `testBody()` and test-specific verifications
finish.

#### 2. Two Distinct Verification Phases
* **Test-specific verifications (`invariantTester`)**: Passed as a
callback to `runTest` and executed synchronously inside `_runTestBody`
immediately after the `testBody()` Future completes and the widget tree
is unmounted. In `testWidgets`, this runs
`tester._endOfTestVerifications` to verify that tickers and semantics
handles were disposed.
* **Framework-level invariant checks**: Verifies global framework state,
including ensuring foundation/rendering/widgets debug flags were reset
and no non-periodic timers or animations remain.

#### 3. The Teardown Lifecycle & Root Cause of flutter#110488
When `testWidgets` runs:
1. `testWidgets` registers `test_package.addTearDown(binding.postTest)`
with `package:test`.
2. `testWidgets` calls and returns `binding.runTest(...)`.
3. Inside `testBody()`, users may register cleanups using `addTearDown`
(for example, `addTearDown(() => debugDefaultTargetPlatformOverride =
null)`).
4. `package:test` executes teardowns in **LIFO (reverse registration)
order** only *after* the Future returned by `runTest` completes.

Previously, framework-level invariant checks ran at the end of
`_runTestBody` *before* the `runTest` Future completed. As a result,
they ran before `package:test` executed any user-registered
`addTearDown` callbacks, causing tests that clean up debug flags via
`addTearDown` to fail invariant verification (flutter#110488).

The following diagram shows the code flow after this PR:
```
testWidgets(description, (tester) async { ... })
 │
 ├── 1. Registration Phase
 │    └── test_package.addTearDown(binding.postTest)     [Teardown Stack: #1]
 │
 ├── 2. Test Execution Phase: binding.runTest(...)
 │    │
 │    │   [ Future 1: testBody() ]
 │    ├──► Run testBody(tester)
 │    │     └── User calls addTearDown(...)              [Teardown Stack: #2]
 │    │
 │    │   [ Post-testBody cleanup (inside runTest) ]
 │    ├──► Unmount widget tree (runApp)
 │    ├──► Verification 1: invariantTester()             (tickers, semantics)
 │    └──► Set _shouldVerifyInvariants = true
 │
 │    [ Future 2: runTest() completes ]
 │
 └── 3. Teardown Phase: package:test executes in LIFO order
      │
      ├──► [Step 1] User Teardowns (Stack #2)
      │     └── e.g., debugDefaultTargetPlatformOverride = null
      │
      └──► [Step 2] binding.postTest() (Stack #1)
            ├── Verification 2: Framework Invariants     (debug vars, timers)
            ├── Reset Binding State                      (_currentFakeAsync, etc.)
            └── reportTestException(...)                 (if Verification 2 failed)
```
### Changes & Design Rationale
#### 1. Defer Framework Invariant Checks to `postTest`

Framework invariant checks (`_verifyInvariants()`,
`_verifyAutoUpdateGoldensUnset`, etc.) are moved from `_runTestBody`
into `TestWidgetsFlutterBinding.postTest`.
Because `testWidgets` registers `binding.postTest` before running the
test body, `package:test`'s LIFO teardown ordering guarantees that all
user-registered `addTearDown` callbacks execute before
`binding.postTest`.

#### 2. Clarifying the `postTest` Error Contract

Previously, `postTest` only performed state cleanup and did not check
invariants. Moving invariant checks into `postTest` introduced the
question of how invariant failures should be propagated: allowing
`postTest` to throw, or absorbing errors and reporting them via
`reportTestException`.

We explicitly define the contract of `postTest` to **not throw
exceptions**, reporting any invariant failures via
`reportTestException`:

* **Rationale & Trade-offs**:
* *Alternative considered (throwing)*: If `super.postTest()` threw on an
invariant failure, `package:test` would still capture the failure.
However, subclasses (`AutomatedTestWidgetsFlutterBinding`,
`LiveTestWidgetsFlutterBinding`, or custom bindings) override `postTest`
to reset their own state (e.g. nulling `_currentFakeAsync` / `_clock`,
or setting `_inTest = false`). Allowing `super.postTest()` to throw
would require every subclass to defensively wrap `super.postTest()` in
`try ... finally`. If any subclass omitted this, an invariant failure
would leave the binding in a dirty state and trigger cascading `!inTest`
failures in subsequent tests.
* *Chosen approach (non-throwing)*: Absorbing errors in `postTest` and
forwarding them to `reportTestException` guarantees that all cleanup in
base and subclass implementations executes sequentially without
defensive `try ... finally` boilerplate, while still cleanly failing the
test.

**Why this does not break existing behavior:**
In the previous implementation, when invariant assertions failed inside
`_runTestBody`, they were caught by `_testZone.handleUncaughtError` and
forwarded to `reportTestException` (which delegates to
`package:test.registerException`). They never escaped `runTest` as
unhandled thrown exceptions. Catching invariant failures in `postTest`
and routing them to `reportTestException` preserves this exact error
reporting pipeline, diagnostic output, and failure semantics without
disrupting teardown execution.

#### 3. Preserving Existing Behavior on Failed Tests
(`_shouldVerifyInvariants`)

Historically, `_runTestBody` only verified invariants if the test body
did not fail:

```dart
if (_pendingExceptionDetails == null) {
  // We only try to clean up and verify invariants if we didn't already
  // fail. If we got an exception already, then we instead leave everything
  // alone so that we don't cause more spurious errors.
  ...
  _verifyInvariants();
}
```

When invariant checks are moved to `postTest`,
`_pendingExceptionDetails` is no longer available because it has already
been reported and cleared by `testCompletionHandler` when `runTest`
completed.

To preserve this exact existing behavior across the lifecycle boundary,
`_shouldVerifyInvariants` is introduced. It is set to `true` at the end
of `_runTestBody` only when `_pendingExceptionDetails == null`. If a
test fails in its body, `_shouldVerifyInvariants` remains `false`, and
`postTest` skips invariant checks—ensuring no behavior change and
preventing spurious errors (e.g. active animations on an unmounted tree)
from masking the real failure.

#### 4. Documentation Updates
Updated the doc comments on:
* `TestWidgetsFlutterBinding.postTest`: Documents the non-throwing
contract, the `@mustCallSuper` requirement, and error reporting via
`reportTestException`.
* `TestWidgetsFlutterBinding.runTest`: Clarifies the distinction between
`invariantTester` (which runs before `runTest` completes) and framework
invariant checks (which run in `postTest` after `runTest` and user
teardowns complete).

### Tests
- Added unit tests in
`packages/flutter_test/test/bindings_invariants_test.dart` verifying
that foundation variables (`debugDefaultTargetPlatformOverride`,
`debugDoublePrecision`, `debugBrightnessOverride`),
`autoUpdateGoldenFiles`, `ErrorWidget.builder`, and
`shouldPropagateDevicePointerEvents` can all be reset using
`addTearDown`.
- Added test cases verifying invariant failures in `postTest` and
ensuring invariant checks are skipped when the test body throws.

## Pre-launch Checklist

- [ ] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [ ] I read the [AI contribution guidelines] and understand my
responsibilities, or I am not using AI tools.
- [ ] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [ ] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [ ] I signed the [CLA].
- [ ] I listed at least one issue that this PR fixes in the description
above.
- [ ] I updated/added relevant documentation (doc comments with `///`).
- [ ] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [ ] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [ ] 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/docs/contributing/Tree-hygiene.md#ai-contribution-guidelines
[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
[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
bkonyi pushed a commit that referenced this pull request Sep 26, 2026
)

Reverts: [Allow resetting test invariants in
`addTearDown`](flutter#192082)

Initiated by: @b-luk

Reason for reverting: Breaks tree with tool_integration_tests failures.
Example:
https://ci.chromium.org/ui/p/flutter/builders/prod/Mac%20tool_integration_tests_2/1329/overview

Original PR Author: @dkwingsmt

Reviewed By: @justinmc

The original PR description is provided below:

Fixes flutter#110488.

### Background: The `testWidgets` Lifecycle
Understanding this change requires distinguishing between two layers of
`Future`s and two distinct verification steps in `testWidgets`:

#### 1. Two Layers of `Future`s
* **`testBody()` Future**: The closure containing the user's test logic.
* **`runTest()` Future**: The overall async harness returned by
`binding.runTest()`. It manages the test zone, unmounts the widget tree,
and resolves only after `testBody()` and test-specific verifications
finish.

#### 2. Two Distinct Verification Phases
* **Test-specific verifications (`invariantTester`)**: Passed as a
callback to `runTest` and executed synchronously inside `_runTestBody`
immediately after the `testBody()` Future completes and the widget tree
is unmounted. In `testWidgets`, this runs
`tester._endOfTestVerifications` to verify that tickers and semantics
handles were disposed.
* **Framework-level invariant checks**: Verifies global framework state,
including ensuring foundation/rendering/widgets debug flags were reset
and no non-periodic timers or animations remain.

#### 3. The Teardown Lifecycle & Root Cause of flutter#110488
When `testWidgets` runs:
1. `testWidgets` registers `test_package.addTearDown(binding.postTest)`
with `package:test`.
2. `testWidgets` calls and returns `binding.runTest(...)`.
3. Inside `testBody()`, users may register cleanups using `addTearDown`
(for example, `addTearDown(() => debugDefaultTargetPlatformOverride =
null)`).
4. `package:test` executes teardowns in **LIFO (reverse registration)
order** only *after* the Future returned by `runTest` completes.

Previously, framework-level invariant checks ran at the end of
`_runTestBody` *before* the `runTest` Future completed. As a result,
they ran before `package:test` executed any user-registered
`addTearDown` callbacks, causing tests that clean up debug flags via
`addTearDown` to fail invariant verification (flutter#110488).

The following diagram shows the code flow after this PR:
```
testWidgets(description, (tester) async { ... })
 │
 ├── 1. Registration Phase
 │    └── test_package.addTearDown(binding.postTest)     [Teardown Stack: #1]
 │
 ├── 2. Test Execution Phase: binding.runTest(...)
 │    │
 │    │   [ Future 1: testBody() ]
 │    ├──► Run testBody(tester)
 │    │     └── User calls addTearDown(...)              [Teardown Stack: #2]
 │    │
 │    │   [ Post-testBody cleanup (inside runTest) ]
 │    ├──► Unmount widget tree (runApp)
 │    ├──► Verification 1: invariantTester()             (tickers, semantics)
 │    └──► Set _shouldVerifyInvariants = true
 │
 │    [ Future 2: runTest() completes ]
 │
 └── 3. Teardown Phase: package:test executes in LIFO order
      │
      ├──► [Step 1] User Teardowns (Stack #2)
      │     └── e.g., debugDefaultTargetPlatformOverride = null
      │
      └──► [Step 2] binding.postTest() (Stack #1)
            ├── Verification 2: Framework Invariants     (debug vars, timers)
            ├── Reset Binding State                      (_currentFakeAsync, etc.)
            └── reportTestException(...)                 (if Verification 2 failed)
```
### Changes & Design Rationale
#### 1. Defer Framework Invariant Checks to `postTest`

Framework invariant checks (`_verifyInvariants()`,
`_verifyAutoUpdateGoldensUnset`, etc.) are moved from `_runTestBody`
into `TestWidgetsFlutterBinding.postTest`.
Because `testWidgets` registers `binding.postTest` before running the
test body, `package:test`'s LIFO teardown ordering guarantees that all
user-registered `addTearDown` callbacks execute before
`binding.postTest`.

#### 2. Clarifying the `postTest` Error Contract

Previously, `postTest` only performed state cleanup and did not check
invariants. Moving invariant checks into `postTest` introduced the
question of how invariant failures should be propagated: allowing
`postTest` to throw, or absorbing errors and reporting them via
`reportTestException`.

We explicitly define the contract of `postTest` to **not throw
exceptions**, reporting any invariant failures via
`reportTestException`:

* **Rationale & Trade-offs**:
* *Alternative considered (throwing)*: If `super.postTest()` threw on an
invariant failure, `package:test` would still capture the failure.
However, subclasses (`AutomatedTestWidgetsFlutterBinding`,
`LiveTestWidgetsFlutterBinding`, or custom bindings) override `postTest`
to reset their own state (e.g. nulling `_currentFakeAsync` / `_clock`,
or setting `_inTest = false`). Allowing `super.postTest()` to throw
would require every subclass to defensively wrap `super.postTest()` in
`try ... finally`. If any subclass omitted this, an invariant failure
would leave the binding in a dirty state and trigger cascading `!inTest`
failures in subsequent tests.
* *Chosen approach (non-throwing)*: Absorbing errors in `postTest` and
forwarding them to `reportTestException` guarantees that all cleanup in
base and subclass implementations executes sequentially without
defensive `try ... finally` boilerplate, while still cleanly failing the
test.

**Why this does not break existing behavior:**
In the previous implementation, when invariant assertions failed inside
`_runTestBody`, they were caught by `_testZone.handleUncaughtError` and
forwarded to `reportTestException` (which delegates to
`package:test.registerException`). They never escaped `runTest` as
unhandled thrown exceptions. Catching invariant failures in `postTest`
and routing them to `reportTestException` preserves this exact error
reporting pipeline, diagnostic output, and failure semantics without
disrupting teardown execution.

#### 3. Preserving Existing Behavior on Failed Tests
(`_shouldVerifyInvariants`)

Historically, `_runTestBody` only verified invariants if the test body
did not fail:

```dart
if (_pendingExceptionDetails == null) {
  // We only try to clean up and verify invariants if we didn't already
  // fail. If we got an exception already, then we instead leave everything
  // alone so that we don't cause more spurious errors.
  ...
  _verifyInvariants();
}
```

When invariant checks are moved to `postTest`,
`_pendingExceptionDetails` is no longer available because it has already
been reported and cleared by `testCompletionHandler` when `runTest`
completed.

To preserve this exact existing behavior across the lifecycle boundary,
`_shouldVerifyInvariants` is introduced. It is set to `true` at the end
of `_runTestBody` only when `_pendingExceptionDetails == null`. If a
test fails in its body, `_shouldVerifyInvariants` remains `false`, and
`postTest` skips invariant checks—ensuring no behavior change and
preventing spurious errors (e.g. active animations on an unmounted tree)
from masking the real failure.

#### 4. Documentation Updates
Updated the doc comments on:
* `TestWidgetsFlutterBinding.postTest`: Documents the non-throwing
contract, the `@mustCallSuper` requirement, and error reporting via
`reportTestException`.
* `TestWidgetsFlutterBinding.runTest`: Clarifies the distinction between
`invariantTester` (which runs before `runTest` completes) and framework
invariant checks (which run in `postTest` after `runTest` and user
teardowns complete).

### Tests
- Added unit tests in
`packages/flutter_test/test/bindings_invariants_test.dart` verifying
that foundation variables (`debugDefaultTargetPlatformOverride`,
`debugDoublePrecision`, `debugBrightnessOverride`),
`autoUpdateGoldenFiles`, `ErrorWidget.builder`, and
`shouldPropagateDevicePointerEvents` can all be reset using
`addTearDown`.
- Added test cases verifying invariant failures in `postTest` and
ensuring invariant checks are skipped when the test body throws.

## Pre-launch Checklist

- [ ] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [ ] I read the [AI contribution guidelines] and understand my
responsibilities, or I am not using AI tools.
- [ ] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [ ] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [ ] I signed the [CLA].
- [ ] I listed at least one issue that this PR fixes in the description
above.
- [ ] I updated/added relevant documentation (doc comments with `///`).
- [ ] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [ ] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [ ] 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/docs/contributing/Tree-hygiene.md#ai-contribution-guidelines
[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
[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
bkonyi added a commit that referenced this pull request Nov 6, 2026
…tures

Only include the UTF-8 encoding remediation hint in `TestCommand.verifyThenRunCommand` when `readAsStringSync` fails due to a UTF-8 decoding error (`err.osError == null` and `readAsBytesSync` succeeds), rather than on OS or filesystem read failures. Add a hermetic regression test for OS `FileSystemException`s and document the AppleDouble and UTF-16 LE byte-array fixtures in `test_test.dart`.

Previous output (AppleDouble sidecar files):
```
Failed to decode data using encoding 'utf-8', path = '/usr/local/google/home/bkonyi/.gemini/jetski/brain/ee6d5e68-1051-40e6-a23a-a289ca33c97a/scratch/repro_app/test/._a_test.dart'
dart:io                                          _File.readAsStringSync
package:test_core/src/runner/loader.dart 41:22   Loader.parseSuiteMetadata.<fn>.<fn>
package:async/src/result/result.dart 67:40       new Result
package:test_core/src/runner/loader.dart 38:14   Loader.parseSuiteMetadata.<fn>
dart:_compact_hash                               _LinkedHashMapMixin.putIfAbsent
package:test_core/src/runner/loader.dart 36:35   Loader.parseSuiteMetadata
package:test_core/src/runner/loader.dart 266:41  Loader.loadFile

This is an unexpected error. Please file an issue at http://github.com/dart-lang/test
with the stack trace and instructions for reproducing the error.

FileSystemException: Failed to decode data using encoding 'utf-8', path = '/usr/local/google/home/bkonyi/.gemini/jetski/brain/ee6d5e68-1051-40e6-a23a-a289ca33c97a/scratch/repro_app/test/._widget_test.dart'
#0      _File._tryDecode (dart:io/file_impl.dart:704:7)
#1      _File.readAsStringSync (dart:io/file_impl.dart:715:7)
#2      Loader.parseSuiteMetadata.<anonymous closure>.<anonymous closure> (package:test_core/src/runner/loader.dart:41:22)
#3      new Result (package:async/src/result/result.dart:67:40)
#4      Loader.parseSuiteMetadata.<anonymous closure> (package:test_core/src/runner/loader.dart:38:14)
#5      _LinkedHashMapMixin.putIfAbsent (dart:_compact_hash:631:23)
#6      Loader.parseSuiteMetadata (package:test_core/src/runner/loader.dart:36:35)
flutter#7      Loader.loadFile (package:test_core/src/runner/loader.dart:266:41)
<asynchronous suspension>

Feature flags enabled: 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
```

Current output (AppleDouble sidecar files):
```
00:00 +0: loading /usr/local/google/home/bkonyi/.gemini/jetski/brain/ee6d5e68-1051-40e6-a23a-a289ca33c97a/scratch/repro_app/test/widget_test.dart
00:00 +0: passes
00:00 +1: All tests passed!
```

Previous output (non-UTF-8 test files):
```
Failed to decode data using encoding 'utf-8', path = '/usr/local/google/home/bkonyi/.gemini/jetski/brain/ee6d5e68-1051-40e6-a23a-a289ca33c97a/scratch/repro_app/test/non_utf8_1_test.dart'
dart:io                                          _File.readAsStringSync
package:test_core/src/runner/loader.dart 41:22   Loader.parseSuiteMetadata.<fn>.<fn>
package:async/src/result/result.dart 67:40       new Result
package:test_core/src/runner/loader.dart 38:14   Loader.parseSuiteMetadata.<fn>
dart:_compact_hash                               _LinkedHashMapMixin.putIfAbsent
package:test_core/src/runner/loader.dart 36:35   Loader.parseSuiteMetadata
package:test_core/src/runner/loader.dart 266:41  Loader.loadFile

This is an unexpected error. Please file an issue at http://github.com/dart-lang/test
with the stack trace and instructions for reproducing the error.

FileSystemException: Failed to decode data using encoding 'utf-8', path = '/usr/local/google/home/bkonyi/.gemini/jetski/brain/ee6d5e68-1051-40e6-a23a-a289ca33c97a/scratch/repro_app/test/non_utf8_2_test.dart'
#0      _File._tryDecode (dart:io/file_impl.dart:704:7)
#1      _File.readAsStringSync (dart:io/file_impl.dart:715:7)
#2      Loader.parseSuiteMetadata.<anonymous closure>.<anonymous closure> (package:test_core/src/runner/loader.dart:41:22)
#3      new Result (package:async/src/result/result.dart:67:40)
#4      Loader.parseSuiteMetadata.<anonymous closure> (package:test_core/src/runner/loader.dart:38:14)
#5      _LinkedHashMapMixin.putIfAbsent (dart:_compact_hash:631:23)
#6      Loader.parseSuiteMetadata (package:test_core/src/runner/loader.dart:36:35)
flutter#7      Loader.loadFile (package:test_core/src/runner/loader.dart:266:41)
<asynchronous suspension>

Feature flags enabled: 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
```

Current output (non-UTF-8 test files):
```
Failed to read test file
"/usr/local/google/home/bkonyi/.gemini/jetski/brain/ee6d5e68-1051-40e6-a23a-a289
ca33c97a/scratch/repro_app/test/non_utf8_1_test.dart": Failed to decode data
using encoding 'utf-8'.
Ensure that the file is a valid UTF-8 encoded Dart test file.
```
bkonyi added a commit that referenced this pull request Nov 9, 2026
… overwrite test

Updates `native_assets_flutter_test_manifest_overwrite_test.dart` to invoke `flutterBin` (`test_utils.dart`) with `@Timeout(Duration(minutes: 5))` instead of manually compiling `bin/flutter_tools.dart` to `flutter_tools.dill`, and uses `loadPackageConfig`, `PackageConfig`, `Package`, `LanguageVersion`, and `savePackageConfig` from `package:package_config/package_config.dart` to construct the offline test project's `.dart_tool/package_config.json`.

Previous output:
```
Unhandled exception:
FileSystemException: Cannot rename file to '/usr/local/google/home/bkonyi/.gemini/jetski/brain/0a669702-1e2d-46a6-9c37-fdc4d2ca98a9/scratch/repro_196121_dst.tmp', path = '/tmp/repro_196121_src.tmp' (OS Error: Invalid cross-device link, errno = 18)
#0      _File.throwIfError (dart:io/file_impl.dart:779:7)
#1      _File.renameSync (dart:io/file_impl.dart:396:5)
#2      ForwardingFileSystemEntity.renameSync (package:file/src/forwarding/forwarding_file_system_entity.dart:50:49)
#3      ErrorHandlingFile.renameSync.<anonymous closure> (package:flutter_tools/src/base/error_handling_io.dart:430:31)
#4      _runSync (package:flutter_tools/src/base/error_handling_io.dart:1116:16)
#5      ErrorHandlingFile.renameSync (package:flutter_tools/src/base/error_handling_io.dart:429:12)
#6      main (file:///usr/local/google/home/bkonyi/.gemini/jetski/brain/0a669702-1e2d-46a6-9c37-fdc4d2ca98a9/scratch/repro_exdev.dart:24:37)
flutter#7      _delayEntrypointInvocation.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:313:19)
flutter#8      _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:192:12)
```

Current output:
```
Flutter failed to rename file at "/tmp/repro_196121_src.tmp" to "/usr/local/google/home/bkonyi/.gemini/jetski/brain/0a669702-1e2d-46a6-9c37-fdc4d2ca98a9/scratch/repro_196121_dst.tmp".
A file system operation failed across different volumes or mount points.
FileSystemException: Cannot rename file to '/usr/local/google/home/bkonyi/.gemini/jetski/brain/0a669702-1e2d-46a6-9c37-fdc4d2ca98a9/scratch/repro_196121_dst.tmp', path = '/tmp/repro_196121_src.tmp' (OS Error: Invalid cross-device link, errno = 18)
Ensure that the project, build output, and temporary directories are on the same writable volume, or check external volume and security software settings.
```

Previous output (flutter test overwriting existing native_assets.json):
```
Flutter failed to delete file at
"/usr/local/google/home/bkonyi/.gemini/jetski/brain/0a669702-1e2d-46a6-9c37-fdc4
d2ca98a9/scratch/repro_app/build/native_assets/linux/native_assets.json".
Please ensure that the SDK and/or project is installed in a location that has
read/write permissions for the current user.
Try running:
  sudo chown -R $(whoami)
  /usr/local/google/home/bkonyi/.gemini/jetski/brain/0a669702-1e2d-46a6-9c37-fdc
  4d2ca98a9/scratch/repro_app/build/native_assets/linux/native_assets.json
```

Current output (flutter test overwriting existing native_assets.json):
```
00:00 +0: loading /usr/local/google/home/bkonyi/.gemini/jetski/brain/0a669702-1e2d-46a6-9c37-fdc4d2ca98a9/scratch/repro_app/test/smoke_test.dart
00:00 +0: smoke test
00:00 +1: All tests passed!
```

Fixes flutter#196121
bkonyi added a commit that referenced this pull request Nov 9, 2026
Simplifies the fix and tests for avoiding redundant `native_assets.json` deletion and handling `EXDEV`:
- Restores `ErrorHandlingFileSystem.deleteIfExists` to upstream and removes custom `ForwardingFileSystem` test doubles in `error_handling_io_test.dart`, testing `EXDEV` (`errno = 18`) directly with `MemoryFileSystem.test(opHandle: exceptionHandler.opHandle)`.
- Streams `targetDir.list(followLinks: false)` in `_copyNativeCodeAssetsForOS` with `entity is File` instead of `.toList()` and `typeSync`, and deduplicates `installCodeAssets` test setup in `native_assets_test.dart`.
- Removes the redundant `flutter test` subprocess integration test (`native_assets_flutter_test_manifest_overwrite_test.dart`).

Reproduction notes: Both output pairs below were captured on a Linux host, which cannot reproduce the macOS external-volume behavior directly. The first pair comes from a small Dart script (`repro_exdev.dart`) calling `ErrorHandlingFileSystem.file(...).renameSync(...)` from `/tmp` (`tmpfs`) to an `ext4` directory to trigger a real kernel `EXDEV` (`errno = 18`). The second pair comes from running `BOT=true flutter test --no-pub -r expanded` on a minimal app after making `build/native_assets/linux` read-only (`chmod 0555`) while leaving `native_assets.json` writable (`0644`), so `unlink(2)` fails while in-place truncation succeeds; with a writable `build/native_assets/linux` directory, the unfixed tool passes with the same 3-line test output. Local workspace paths inside the fenced output blocks are preserved verbatim to match exact command output.

Previous output:
```
Unhandled exception:
FileSystemException: Cannot rename file to '/usr/local/google/home/bkonyi/.gemini/jetski/brain/0a669702-1e2d-46a6-9c37-fdc4d2ca98a9/scratch/repro_196121_dst.tmp', path = '/tmp/repro_196121_src.tmp' (OS Error: Invalid cross-device link, errno = 18)
#0      _File.throwIfError (dart:io/file_impl.dart:779:7)
#1      _File.renameSync (dart:io/file_impl.dart:396:5)
#2      ForwardingFileSystemEntity.renameSync (package:file/src/forwarding/forwarding_file_system_entity.dart:50:49)
#3      ErrorHandlingFile.renameSync.<anonymous closure> (package:flutter_tools/src/base/error_handling_io.dart:430:31)
#4      _runSync (package:flutter_tools/src/base/error_handling_io.dart:1116:16)
#5      ErrorHandlingFile.renameSync (package:flutter_tools/src/base/error_handling_io.dart:429:12)
#6      main (file:///usr/local/google/home/bkonyi/.gemini/jetski/brain/0a669702-1e2d-46a6-9c37-fdc4d2ca98a9/scratch/repro_exdev.dart:24:37)
flutter#7      _delayEntrypointInvocation.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:313:19)
flutter#8      _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:192:12)
```

Current output:
```
Flutter failed to rename file at "/tmp/repro_196121_src.tmp" to "/usr/local/google/home/bkonyi/.gemini/jetski/brain/0a669702-1e2d-46a6-9c37-fdc4d2ca98a9/scratch/repro_196121_dst.tmp".
A file system operation failed across different volumes or mount points.
FileSystemException: Cannot rename file to '/usr/local/google/home/bkonyi/.gemini/jetski/brain/0a669702-1e2d-46a6-9c37-fdc4d2ca98a9/scratch/repro_196121_dst.tmp', path = '/tmp/repro_196121_src.tmp' (OS Error: Invalid cross-device link, errno = 18)
Ensure that the project, build output, and temporary directories are on the same writable volume, or check external volume and security software settings.
```

Previous output (flutter test overwriting existing native_assets.json):
```
Flutter failed to delete file at
"/usr/local/google/home/bkonyi/.gemini/jetski/brain/0a669702-1e2d-46a6-9c37-fdc4
d2ca98a9/scratch/repro_app/build/native_assets/linux/native_assets.json".
Please ensure that the SDK and/or project is installed in a location that has
read/write permissions for the current user.
Try running:
  sudo chown -R $(whoami)
  /usr/local/google/home/bkonyi/.gemini/jetski/brain/0a669702-1e2d-46a6-9c37-fdc
  4d2ca98a9/scratch/repro_app/build/native_assets/linux/native_assets.json
```

Current output (flutter test overwriting existing native_assets.json):
```
00:00 +0: loading /usr/local/google/home/bkonyi/.gemini/jetski/brain/0a669702-1e2d-46a6-9c37-fdc4d2ca98a9/scratch/repro_app/test/smoke_test.dart
00:00 +0: smoke test
00:00 +1: All tests passed!
```

Fixes flutter#196121
bkonyi added a commit that referenced this pull request Nov 9, 2026
…ative assets

Restores `.toList()` on `targetDir.list(followLinks: false)` in `_copyNativeCodeAssetsForOS` so directory enumeration completes before deleting stale entries in `targetDir`, avoiding concurrent directory stream mutation issues on Windows and network filesystems.

Reproduction notes: Both output pairs below were captured on a Linux host, which cannot reproduce the macOS external-volume behavior directly. The first pair comes from a small Dart script (`repro_exdev.dart`) calling `ErrorHandlingFileSystem.file(...).renameSync(...)` from `/tmp` (`tmpfs`) to an `ext4` directory to trigger a real kernel `EXDEV` (`errno = 18`). The second pair comes from running `BOT=true flutter test --no-pub -r expanded` on a minimal app after making `build/native_assets/linux` read-only (`chmod 0555`) while leaving `native_assets.json` writable (`0644`), so `unlink(2)` fails while in-place truncation succeeds; with a writable `build/native_assets/linux` directory, the unfixed tool passes with the same 3-line test output. Local workspace paths inside the fenced output blocks are preserved verbatim to match exact command output.

Previous output:
```
Unhandled exception:
FileSystemException: Cannot rename file to '/usr/local/google/home/bkonyi/.gemini/jetski/brain/0a669702-1e2d-46a6-9c37-fdc4d2ca98a9/scratch/repro_196121_dst.tmp', path = '/tmp/repro_196121_src.tmp' (OS Error: Invalid cross-device link, errno = 18)
#0      _File.throwIfError (dart:io/file_impl.dart:779:7)
#1      _File.renameSync (dart:io/file_impl.dart:396:5)
#2      ForwardingFileSystemEntity.renameSync (package:file/src/forwarding/forwarding_file_system_entity.dart:50:49)
#3      ErrorHandlingFile.renameSync.<anonymous closure> (package:flutter_tools/src/base/error_handling_io.dart:430:31)
#4      _runSync (package:flutter_tools/src/base/error_handling_io.dart:1116:16)
#5      ErrorHandlingFile.renameSync (package:flutter_tools/src/base/error_handling_io.dart:429:12)
#6      main (file:///usr/local/google/home/bkonyi/.gemini/jetski/brain/0a669702-1e2d-46a6-9c37-fdc4d2ca98a9/scratch/repro_exdev.dart:24:37)
flutter#7      _delayEntrypointInvocation.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:313:19)
flutter#8      _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:192:12)
```

Current output:
```
Flutter failed to rename file at "/tmp/repro_196121_src.tmp" to "/usr/local/google/home/bkonyi/.gemini/jetski/brain/0a669702-1e2d-46a6-9c37-fdc4d2ca98a9/scratch/repro_196121_dst.tmp".
A file system operation failed across different volumes or mount points.
FileSystemException: Cannot rename file to '/usr/local/google/home/bkonyi/.gemini/jetski/brain/0a669702-1e2d-46a6-9c37-fdc4d2ca98a9/scratch/repro_196121_dst.tmp', path = '/tmp/repro_196121_src.tmp' (OS Error: Invalid cross-device link, errno = 18)
Ensure that the project, build output, and temporary directories are on the same writable volume, or check external volume and security software settings.
```

Previous output (flutter test overwriting existing native_assets.json):
```
Flutter failed to delete file at
"/usr/local/google/home/bkonyi/.gemini/jetski/brain/0a669702-1e2d-46a6-9c37-fdc4
d2ca98a9/scratch/repro_app/build/native_assets/linux/native_assets.json".
Please ensure that the SDK and/or project is installed in a location that has
read/write permissions for the current user.
Try running:
  sudo chown -R $(whoami)
  /usr/local/google/home/bkonyi/.gemini/jetski/brain/0a669702-1e2d-46a6-9c37-fdc
  4d2ca98a9/scratch/repro_app/build/native_assets/linux/native_assets.json
```

Current output (flutter test overwriting existing native_assets.json):
```
00:00 +0: loading /usr/local/google/home/bkonyi/.gemini/jetski/brain/0a669702-1e2d-46a6-9c37-fdc4d2ca98a9/scratch/repro_app/test/smoke_test.dart
00:00 +0: smoke test
00:00 +1: All tests passed!
```

Fixes flutter#196121
bkonyi added a commit that referenced this pull request Nov 11, 2026
…lutter#196134)

Previously, `installCodeAssets` invoked `_copyNativeCodeAssetsForOS` on
every `flutter test` run, which listed `build/native_assets/<os>/` and
deleted `native_assets.json` right before `_writeNativeAssetsJson`
truncated and overwrote that same file in place. On macOS external
volumes (for example `/Volumes/...` where endpoint-security or
recycle-bin interposers intercept `unlink(2)` and attempt a cross-volume
`rename(2)`), unlinking `native_assets.json` failed with
`FileSystemException (OS Error: Cross-device link, errno = 18)`
(`EXDEV`). In addition, `_handlePosixException` did not map `EXDEV`
(`errno = 18`) to a `ToolExit`.

This change:
1. Skips deleting `native_assets.json` in `_copyNativeCodeAssetsForOS`
when it already exists on disk as a regular file, since
`_writeNativeAssetsJson` immediately truncates and overwrites it in
place (while still deleting stale bundled native asset artifacts,
directories, and symlinks).
2. Handles POSIX `EXDEV` (`errno = 18`) in `_handlePosixException` on
Linux and macOS by throwing an actionable `ToolExit` instead of crashing
with an unhandled `FileSystemException`.

Reproduction notes: Both output pairs below were captured on a Linux
host, which cannot reproduce the macOS external-volume behavior
directly. The first pair comes from a small Dart script
(`repro_exdev.dart`) calling
`ErrorHandlingFileSystem.file(...).renameSync(...)` from `/tmp`
(`tmpfs`) to an `ext4` directory to trigger a real kernel `EXDEV`
(`errno = 18`). The second pair comes from running `BOT=true flutter
test --no-pub -r expanded` on a minimal app after making
`build/native_assets/linux` read-only (`chmod 0555`) while leaving
`native_assets.json` writable (`0644`), so `unlink(2)` fails while
in-place truncation succeeds; with a writable
`build/native_assets/linux` directory, the unfixed tool passes with the
same 3-line test output. Local workspace paths inside the fenced output
blocks are preserved verbatim to match exact command output.

Previous output:
```
Unhandled exception:
FileSystemException: Cannot rename file to '/usr/local/google/home/bkonyi/.gemini/jetski/brain/0a669702-1e2d-46a6-9c37-fdc4d2ca98a9/scratch/repro_196121_dst.tmp', path = '/tmp/repro_196121_src.tmp' (OS Error: Invalid cross-device link, errno = 18)
#0      _File.throwIfError (dart:io/file_impl.dart:779:7)
#1      _File.renameSync (dart:io/file_impl.dart:396:5)
#2      ForwardingFileSystemEntity.renameSync (package:file/src/forwarding/forwarding_file_system_entity.dart:50:49)
#3      ErrorHandlingFile.renameSync.<anonymous closure> (package:flutter_tools/src/base/error_handling_io.dart:430:31)
#4      _runSync (package:flutter_tools/src/base/error_handling_io.dart:1116:16)
#5      ErrorHandlingFile.renameSync (package:flutter_tools/src/base/error_handling_io.dart:429:12)
#6      main (file:///usr/local/google/home/bkonyi/.gemini/jetski/brain/0a669702-1e2d-46a6-9c37-fdc4d2ca98a9/scratch/repro_exdev.dart:24:37)
flutter#7      _delayEntrypointInvocation.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:313:19)
flutter#8      _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:192:12)
```

Current output:
```
Flutter failed to rename file at "/tmp/repro_196121_src.tmp" to "/usr/local/google/home/bkonyi/.gemini/jetski/brain/0a669702-1e2d-46a6-9c37-fdc4d2ca98a9/scratch/repro_196121_dst.tmp".
A file system operation failed across different volumes or mount points.
FileSystemException: Cannot rename file to '/usr/local/google/home/bkonyi/.gemini/jetski/brain/0a669702-1e2d-46a6-9c37-fdc4d2ca98a9/scratch/repro_196121_dst.tmp', path = '/tmp/repro_196121_src.tmp' (OS Error: Invalid cross-device link, errno = 18)
Ensure that the project, build output, and temporary directories are on the same writable volume, or check external volume and security software settings.
```

Previous output (flutter test overwriting existing native_assets.json):
```
Flutter failed to delete file at
"/usr/local/google/home/bkonyi/.gemini/jetski/brain/0a669702-1e2d-46a6-9c37-fdc4
d2ca98a9/scratch/repro_app/build/native_assets/linux/native_assets.json".
Please ensure that the SDK and/or project is installed in a location that has
read/write permissions for the current user.
Try running:
  sudo chown -R $(whoami)
  /usr/local/google/home/bkonyi/.gemini/jetski/brain/0a669702-1e2d-46a6-9c37-fdc
  4d2ca98a9/scratch/repro_app/build/native_assets/linux/native_assets.json
```

Current output (flutter test overwriting existing native_assets.json):
```
00:00 +0: loading /usr/local/google/home/bkonyi/.gemini/jetski/brain/0a669702-1e2d-46a6-9c37-fdc4d2ca98a9/scratch/repro_app/test/smoke_test.dart
00:00 +0: smoke test
00:00 +1: All tests passed!
```

Fixes flutter#196121
bkonyi added a commit that referenced this pull request Nov 12, 2026
flutter#196136)

Previously, `ErrorHandlingFile.readAsStringSync` dropped its `encoding`
parameter when calling `delegate.readAsStringSync()`, forcing UTF-8
decoding even when callers requested another encoding (unlike
`readAsString`, `readAsLines`, and `readAsLinesSync`, which already
forwarded `encoding`). Because `flutter_tools` wraps `LocalFileSystem`
in `ErrorHandlingFileSystem`, callers such as
`ScreenshotCommand.ensureOutputIsNotJsonRpcError` (which passes
`AsciiCodec(allowInvalid: true)` when checking small screenshot files
for JSON-RPC error payloads) crashed with a `FileSystemException`.

Forward `encoding` to `delegate.readAsStringSync(encoding: encoding)`
and add regression tests covering `ErrorHandlingFile.readAsStringSync`
backed by `LocalFileSystem` and
`ScreenshotCommand.ensureOutputIsNotJsonRpcError` on
`ErrorHandlingFileSystem`.

Fixes flutter#196225

Previous output:
```
Screenshot written to flutter_01.skp (0kB).

FileSystemException: Failed to decode data using encoding 'utf-8', path = '/tmp/repro_screenshot_skp.QPQNLT/flutter_01.skp'
#0      _File._tryDecode (dart:io/file_impl.dart:704:7)
#1      _File.readAsStringSync (dart:io/file_impl.dart:715:7)
#2      ForwardingFile.readAsStringSync (package:file/src/forwarding/forwarding_file.dart:99:16)
#3      ErrorHandlingFile.readAsStringSync.<anonymous closure> (package:flutter_tools/src/base/error_handling_io.dart:258:22)
#4      _runSync (package:flutter_tools/src/base/error_handling_io.dart:1116:16)
#5      ErrorHandlingFile.readAsStringSync (package:flutter_tools/src/base/error_handling_io.dart:257:12)
#6      ScreenshotCommand.ensureOutputIsNotJsonRpcError (package:flutter_tools/src/commands/screenshot.dart:198:39)
flutter#7      ScreenshotCommand.runSkia (package:flutter_tools/src/commands/screenshot.dart:180:5)
<asynchronous suspension>
flutter#8      ScreenshotCommand.runCommand (package:flutter_tools/src/commands/screenshot.dart:123:19)
<asynchronous suspension>
flutter#9      FlutterCommand.run.<anonymous closure> (package:flutter_tools/src/runner/flutter_command.dart:876:27)
<asynchronous suspension>
flutter#10     AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:174:19)
<asynchronous suspension>
flutter#11     CommandRunner.runCommand (package:args/command_runner.dart:212:13)
<asynchronous suspension>
flutter#12     FlutterCommandRunner.runCommand.<anonymous closure> (package:flutter_tools/src/runner/flutter_command_runner.dart:689:9)
<asynchronous suspension>
flutter#13     AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:174:19)
<asynchronous suspension>
flutter#14     FlutterCommandRunner.runCommand (package:flutter_tools/src/runner/flutter_command_runner.dart:619:5)
<asynchronous suspension>
flutter#15     FlutterCommandRunner.run (package:flutter_tools/src/runner/flutter_command_runner.dart:379:5)
<asynchronous suspension>
flutter#16     run.<anonymous closure>.<anonymous closure>.<anonymous closure>.<anonymous closure> (package:flutter_tools/runner.dart:419:19)
<asynchronous suspension>
flutter#17     AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:174:19)
<asynchronous suspension>
flutter#18     AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:174:19)
<asynchronous suspension>
flutter#19     AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:174:19)
<asynchronous suspension>
flutter#20     main (package:flutter_tools/executable.dart:133:3)
<asynchronous suspension>

Feature flags enabled: 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
```

Current output:
```
Screenshot written to flutter_01.skp (0kB).
```
bkonyi added a commit that referenced this pull request Nov 12, 2026
Update `screenshot_test.dart` to write its synthetic package configuration via `writePackageConfigFiles`, resolve local engine paths via `LocalEngineLocator` and `getLocalEngineArguments()` with a normalized absolute `flutterBin` path, and register `flutter_tester` teardown immediately after process startup with early-exit reporting.

Previous output:
```
_flutter.screenshotSkp: (-32000) Cannot capture SKP screenshot with Impeller enabled.
#0      new _OutstandingRequest (package:vm_service/src/vm_service.dart:280:34)
#1      VmService._call.<anonymous closure> (package:vm_service/src/vm_service.dart:1962:25)
#2      VmService._call (package:vm_service/src/vm_service.dart:1974:8)
#3      VmService.callServiceExtension (package:vm_service/src/vm_service.dart:1905:14)
#4      FlutterVmService._checkedCallServiceExtension (package:flutter_tools/src/vmservice.dart:835:28)
#5      FlutterVmService.screenshotSkp (package:flutter_tools/src/vmservice.dart:1069:12)
#6      ScreenshotCommand.runSkia (package:flutter_tools/src/commands/screenshot.dart:167:54)
<asynchronous suspension>
flutter#7      ScreenshotCommand.runCommand (package:flutter_tools/src/commands/screenshot.dart:123:19)
<asynchronous suspension>
flutter#8      FlutterCommand.run.<anonymous closure> (package:flutter_tools/src/runner/flutter_command.dart:876:27)
<asynchronous suspension>
flutter#9      AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:174:19)
<asynchronous suspension>
flutter#10     CommandRunner.runCommand (package:args/command_runner.dart:212:13)
<asynchronous suspension>
flutter#11     FlutterCommandRunner.runCommand.<anonymous closure> (package:flutter_tools/src/runner/flutter_command_runner.dart:689:9)
<asynchronous suspension>
flutter#12     AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:174:19)
<asynchronous suspension>
flutter#13     FlutterCommandRunner.runCommand (package:flutter_tools/src/runner/flutter_command_runner.dart:619:5)
<asynchronous suspension>
flutter#14     FlutterCommandRunner.run (package:flutter_tools/src/runner/flutter_command_runner.dart:379:5)
<asynchronous suspension>
flutter#15     run.<anonymous closure>.<anonymous closure>.<anonymous closure>.<anonymous closure> (package:flutter_tools/runner.dart:419:19)
<asynchronous suspension>
flutter#16     AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:174:19)
<asynchronous suspension>
flutter#17     AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:174:19)
<asynchronous suspension>
flutter#18     AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:174:19)
<asynchronous suspension>
flutter#19     main (package:flutter_tools/executable.dart:133:3)
<asynchronous suspension>

Feature flags enabled: 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
```

Current output:
```
The Skia picture request failed: Cannot capture SKP screenshot with Impeller enabled.
```

Fixes flutter#196119
bkonyi added a commit that referenced this pull request Nov 13, 2026
…#196132)

Previously, running `flutter screenshot --type=skia` against an
application with Impeller enabled crashed with an unhandled
`vm_service.RPCError` (`-32000`) because the engine rejects
`_flutter.screenshotSkp` requests under Impeller and
`ScreenshotCommand.runSkia` did not catch `RPCError`. Catch
`vm_service.RPCError` in `ScreenshotCommand.runSkia` and exit cleanly
via `throwToolExit` with the engine's error message.

Previous output:
```
_flutter.screenshotSkp: (-32000) Cannot capture SKP screenshot with Impeller enabled.
#0      new _OutstandingRequest (package:vm_service/src/vm_service.dart:280:34)
#1      VmService._call.<anonymous closure> (package:vm_service/src/vm_service.dart:1962:25)
#2      VmService._call (package:vm_service/src/vm_service.dart:1974:8)
#3      VmService.callServiceExtension (package:vm_service/src/vm_service.dart:1905:14)
#4      FlutterVmService._checkedCallServiceExtension (package:flutter_tools/src/vmservice.dart:835:28)
#5      FlutterVmService.screenshotSkp (package:flutter_tools/src/vmservice.dart:1069:12)
#6      ScreenshotCommand.runSkia (package:flutter_tools/src/commands/screenshot.dart:167:54)
<asynchronous suspension>
flutter#7      ScreenshotCommand.runCommand (package:flutter_tools/src/commands/screenshot.dart:123:19)
<asynchronous suspension>
flutter#8      FlutterCommand.run.<anonymous closure> (package:flutter_tools/src/runner/flutter_command.dart:876:27)
<asynchronous suspension>
flutter#9      AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:174:19)
<asynchronous suspension>
flutter#10     CommandRunner.runCommand (package:args/command_runner.dart:212:13)
<asynchronous suspension>
flutter#11     FlutterCommandRunner.runCommand.<anonymous closure> (package:flutter_tools/src/runner/flutter_command_runner.dart:689:9)
<asynchronous suspension>
flutter#12     AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:174:19)
<asynchronous suspension>
flutter#13     FlutterCommandRunner.runCommand (package:flutter_tools/src/runner/flutter_command_runner.dart:619:5)
<asynchronous suspension>
flutter#14     FlutterCommandRunner.run (package:flutter_tools/src/runner/flutter_command_runner.dart:379:5)
<asynchronous suspension>
flutter#15     run.<anonymous closure>.<anonymous closure>.<anonymous closure>.<anonymous closure> (package:flutter_tools/runner.dart:419:19)
<asynchronous suspension>
flutter#16     AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:174:19)
<asynchronous suspension>
flutter#17     AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:174:19)
<asynchronous suspension>
flutter#18     AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:174:19)
<asynchronous suspension>
flutter#19     main (package:flutter_tools/executable.dart:133:3)
<asynchronous suspension>

Feature flags enabled: 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
```

Current output:
```
The Skia picture request failed: Cannot capture SKP screenshot with Impeller enabled.
```

Fixes flutter#196119
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants