Repository navigation
[flutter_tools] Extract Windows archives using native tar with PowerShell fallback - #192298
Conversation
…d test manual pins Decouples WindowsApp.fromPrebuiltApp from package:archive by catching general Exception rather than ArchiveException when unzipping prebuilt archives, eliminating an unused dependency import. Adds regression and invariant tests in update_packages_test to verify that package:archive is explicitly pinned to 3.6.1 in kManuallyPinnedDependencies to prevent unwanted transitive dependencies (package:posix). Fixes flutter#115660
…hell fallback Replaces in-memory extraction via package:archive in _WindowsUtils with native tar (available on Windows 10 build 17063+) and PowerShell Expand-Archive fallback (powershell / pwsh) for backwards compatibility. This eliminates out-of-memory crashes on Windows when extracting large archives and removes all package:archive dependencies from packages/flutter_tools/lib/src/base/os.dart. Fixes flutter#133371 Part of flutter#115660
Reverts changes to update_packages_test.dart which added test assertions for package:archive in kManuallyPinnedDependencies and macro packages, keeping the PR focused strictly on the Windows archive extraction optimization.
There was a problem hiding this comment.
Code Review
This pull request removes the dependency on the archive package in flutter_tools on Windows, replacing it with native system tools like tar and PowerShell's Expand-Archive. Feedback on these changes includes ensuring that ToolExit is not swallowed when catching exceptions during unzipping in application_package.dart (which requires importing ../base/common.dart), and using single quotes for 'Stop' in the PowerShell script to avoid escaping issues.
- Rethrow ToolExit when unzipping in application_package to avoid masking missing extraction tools as invalid archives. - Add test verifying ToolExit rethrow in application_package_test. - Use single quotes for 'Stop' in PowerShell error action preference script.
mattkae
left a comment
There was a problem hiding this comment.
One piece of feedback, but largely looks good by me!
…ion on Windows Moves the targetDirectory.createSync check to the top of unzip in _WindowsUtils to avoid duplicating the check across extraction paths.
|
autosubmit label was removed for flutter/flutter/192298, because The base commit of the PR is older than 7 days and can not be merged. Please merge the latest changes from the main into this branch and resubmit the PR. |
Description
Today,
flutter_toolsextracts archives on Windows usingpackage:archivein memory because historically Windows lacked a built-in unzipping CLI tool. This causes high memory consumption, slow extraction speeds, and out-of-memory crashes on large archives (#133371). Furthermore,package:archive4.x introduced a dependency onpackage:posixwhich relies on native FFI and cannot execute on Windows (#115660).This PR:
_WindowsUtils.unzipand_WindowsUtils.unpackinos.dartto use native%WINDIR%\System32\tar.exe(available on Windows 10 build 17063+ / version 1803 and Windows 11). This streams extraction directly from disk to disk, eliminating OOM crashes and providing significantly faster throughput.Expand-Archive(checkingpowershellthenpwsh) with verbatim single-quote escaping and$ErrorActionPreference = "Stop"for older Windows 10 versions.WindowsApp.fromPrebuiltAppinapplication_package.dartfrompackage:archiveby handling generalException.package:archivefromos.dartandos_test.dart.tarunzipping, target directory creation, PowerShell fallback, PowerShell Core (pwsh) fallback, and tool-missing error exits.Related Issues
Tests
packages/flutter_tools/test/general.shard/base/os_test.dartpackages/flutter_tools/test/general.shard/windows/application_package_test.dartflutter testand cleandart analyze --fatal-infos