[engine] Support UTF-8 paths in Windows filesystem and path APIs (#191360)
This change fixes hot reload failures and path resolution issues on Windows when project or temporary directory paths contain UTF-8 characters with non-ASCII code points (e.g. Japanese, Chinese, accented characters). ### Root Cause 1. During hot reload, the VM reads `.dill` files using `tonic::filesystem::ReadFileToBytes` in `file.cc`. On Windows, standard C library `open()` was used, which expects ANSI-encoded paths. 2. If the path contained UTF-8 characters not representable in the active ANSI code page, `open()` failed. 3. This failure triggered a fallback to compile from source via `CompileToKernel`, which attempted to start the Kernel Isolate. Because the Kernel Isolate is disabled in Flutter (`start_kernel_isolate = false`), it failed with the misleading error: `Error while starting Kernel isolate task`. 4. Related path APIs in `tonic/filesystem` (`AbsolutePath`, `GetAbsoluteFilePath`) and `fml/paths` (`AbsolutePath`) similarly used ANSI Win32 APIs (`_fullpath`, `CreateFileA`, `GetFinalPathNameByHandleA`). ### Solution 1. Added shared UTF-8 / UTF-16 conversion utilities (`Utf8ToWide`, `WideToUtf8`) in `tonic/filesystem/filesystem/windows_utils.h`. 2. Updated `tonic::filesystem::ReadFileToString` and `ReadFileToBytes` to use `_wopen` with wide strings on Windows. 3. Updated `tonic::filesystem::AbsolutePath` and `GetAbsoluteFilePath` to use `_wfullpath`, `CreateFileW`, and `GetFinalPathNameByHandleW`. 4. Updated `fml::paths::AbsolutePath` to use `fml::Utf8ToWideString`, `_wfullpath`, and `fml::WideStringToUtf8`. 5. Added an integration test `packages/flutter_tools/test/integration.shard/hot_reload_non_ascii_path_test.dart` verifying that hot reload succeeds when the project is in a directory containing non-ASCII characters (`試験`). Fixes https://github.com/flutter/flutter/issues/64758 ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [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. - [ ] 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]. - [ ] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [x] All existing and new tests are passing. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview [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/ [breaking change policy]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes [Data Driven Fixes]: https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
B
Ben Konyi committed
6ec64b38010b5015480da224c8f057bed8c6bf67
Parent: c842d69
Committed by GitHub <noreply@github.com>
on 8/24/2026, 11:01:07 PM