This PR is a reland of https://github.com/flutter/flutter/pull/181685.
The update introduced NBSP to connect time and its period(am or pm), so
some invisible breakages are expected.
Fix is added in the second
[commit](06be40e4bd).
## 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.
- [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.
Remove use of the `setStartAsyncSynchronously` flag in the DDC
bootstrap. This is long overdue and unblocks removing the unused flag
from the DDC runtime.
Includes:
- Display running apps in a formatted table with age calculation
- Implement mDNS discovery for running apps (multiple
devices/interfaces)
- Deduplicate apps by WebSocket URI
- Centralize mDNS device advertisement in MDNSDeviceDiscovery
- Ensure ResidentRunner advertises correct app name and cleans up
- Add network utility functions and JSON support for running-apps
- Add comprehensive tests for discovery and list command
Lastly, this change uses mDNS to discover running Flutter apps, the
multicast_dns package is used instead of mdns_dart as the discovery
functionality is insufficient in the mdns_dart package, only discovering
a maximum of one service.
Instead of generating assembly code that is then compiled to a Mach-O
dynamic library, use the new app-aot-macho-dylib output option for
gen_snapshot to generate the Mach-O dynamic library without the assembly
step.
This is a reland of https://github.com/flutter/flutter/pull/174870. No
changes from the previously landed PR are needed, as the fixes for the
App Store issue described in
https://github.com/flutter/flutter/issues/178602 are all on the Dart
side: https://github.com/dart-lang/sdk/commit/8cbf864.
Related issues:
* https://github.com/dart-lang/sdk/issues/43299
* https://github.com/dart-lang/sdk/issues/60307
* https://github.com/flutter/flutter/issues/178602
* https://github.com/dart-lang/sdk/issues/62414
## 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.
- [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.
Warn when the flag is passed, and prompt to file an issue if disabling
is required for a web development workflow.
The flag is enabled by default. It is still functional, but will be
removed in an upcoming release.
For what the test tests, we only need to build one mode. `flutter build
aar` defaults to building all 3.
Co-authored-by: Gray Mackall <mackall@google.com>
This can cause a confusing error message when tests are run with `dart
test`, which results in `platform.script` returning a dill file. In
particular, tests run using `testWithoutContext` or without a `Platform`
override that invoke `getFlutterRoot()` will encounter an error about
`context.get<Platform>` not being supported.
Fixes https://github.com/flutter/flutter/issues/181856
`dev/devicelab/bin/task/flutter_test_performance.dart` regressed due to
the CFE not being initialized with the correct dill file for the target
test. This change updates `TestCompiler` to pass the correct dill file
when creating the `ResidentCompiler` and adds a test to verify that the
`ResidentCompiler` is initialized with the correct dill.
Moves the initialization logic for web and non-web compilers into the
`ResidentCompiler` factory and reduces code duplication.
Also bumps the flutter_tools Dart SDK version to ^3.10.0 to enable dot
shorthands.
---------
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
This PR splits the debug info from code assets into separate dsym files
for MacOS and iOS.
The splitting only happens if the build mode is not debug. This aligns
with whether the debug symbols are separated out for the Flutter
framework and the app Framework.
Closes: https://github.com/flutter/flutter/issues/181377
Testing: Added some tests to the integration test
Add deprecation marker to `flutter create --template=plugin_ffi`.
The new way of bundling native code is `flutter create
--template=package_ffi`. (Or if the Flutter Plugin API or Android Play
components need to be bundled: `flutter create --template=plugin)`
Issue:
* https://github.com/flutter/flutter/issues/131209
Since https://github.com/flutter/flutter/pull/174685, the code assets
are wrongly invoked on in the `flutter run` process (in addition to
rightly in the `flutter assemble` process). This should not be the case:
We don't know the target architectures we want to build for, neither do
we know which native compiler is set by the native build system that is
invoking us
(https://github.com/flutter/flutter/pull/181004#pullrequestreview-3664863551).
This PR changes the way the hooks are invoked:
* From `flutter run` only run for data assets. (Unblocks
https://github.com/flutter/flutter/pull/181004)
* All other remaining calls, run for both. There might be locations
where data assets could be disabled, but they are needed from the
`DartBuild` target at least in some cases.
The architecture becomes as follows:
* `FlutterNativeAssetsBuildRunner` this is basically the wrapper around
the `NativeAssetsBuildRunner` and there should be only one in a
`flutter_tools` instance, unchanged.
* `FlutterHookRunner` seems to be an interface to be able to supply
fakes, unchanged.
* `runFlutterSpecificHooks` get bool arguments whether they should build
code assets and data assets.
* The callers of these APIs know what asset types are needed in that
context. The invocations added in
https://github.com/flutter/flutter/pull/174685 should be data assets
only.
* Simplification: `FlutterHookRunnerNative.runHooks` does no longer use
`globals.buildSystem.build`. Instead, it directly calls
`runFlutterSpecificHooks`.
* This completely avoids writing to the flutter build directory, which
was the cause of https://github.com/flutter/flutter/issues/178529.
* The `ProtocolExtension`s (which determine which asset types are built)
are taken from `AssetBuildTarget`s, and take into account what asset
types to build, unchanged.
Tests:
* Code assets covered by existing integration tests such as
packages/flutter_tools/test/integration.shard/isolated/native_assets_test.dart
* Data assets covered by existing integration tests such as
packages/flutter_tools/test/integration.shard/isolated/dart_data_asset_test.dart
* This PR completely deletes
packages/flutter_tools/test/general.shard/build_system/targets/hook_runner_native_test.dart.
It was a unit test that testsed the specific workaround, not the effect
of the workaround.
* I've manually tested the steps in
https://github.com/flutter/flutter/issues/178529#issuecomment-3542651915,
the issue does not come back.
> the underlying issue did involve conflict between state written by the
original run of the build system versus state written by the secondary
run executed for the data assets. If the secondary run can be avoided,
then that seems cleaner.
Yep, removed.
Relands https://github.com/flutter/flutter/pull/162464
Fixes https://github.com/flutter/flutter/issues/170664
The only test that failed last time was `Linux_pixel_7pro
android_obfuscate_test`, and I ran it locally (`flutter test
test/integration.shard/android_obfuscate_test.dart `) to both repro the
failure and verify it passes on this branch with the additional changes.
Also does some stuff in the FGP:
The reason we failed the tests last time was we were bundling of the
libapp.so code into a jar in the aar case, instead of simply including
it as its own file in the source sets. I let gemini go on that part,
modifying it to no longer pack as a jar, but it looks correct to me. Now
that the `libapp.so` file is simply included in this case, AGP is able
to strip it (it's not hidden inside a jar).
Because this changes the FGP build process for add to app, I manually
verified that the add to app flow isn't broken for including a flutter
module both as source and as an aar.
<details>
<summary>Before and after logs from the gradle task output</summary>
Before:
```
> Task :flutter:stripReleaseDebugSymbols NO-SOURCE
Skipping task ':flutter:stripReleaseDebugSymbols' as it has no source files and no previous output files.
```
After:
```
Task ':flutter:stripReleaseDebugSymbols' is not up-to-date because:
No history is available.
The input changes require a full rebuild for incremental task ':flutter:stripReleaseDebugSymbols'.
C/C++: android.ndkVersion from module build.gradle is [28.2.13676358]
C/C++: android.ndkVersion from module build.gradle is [28.2.13676358]
C/C++: android.ndkPath from module build.gradle is not set
C/C++: android.ndkPath from module build.gradle is not set
C/C++: ndk.dir in local.properties is not set
C/C++: ndk.dir in local.properties is not set
C/C++: Not considering ANDROID_NDK_HOME because support was removed after deprecation period.
C/C++: Not considering ANDROID_NDK_HOME because support was removed after deprecation period.
C/C++: android.ndkVersion from module build.gradle is [28.2.13676358]
C/C++: android.ndkPath from module build.gradle is not set
C/C++: sdkFolder is /Users/mackall/Library/Android/sdk
C/C++: ndk.dir in local.properties is not set
C/C++: Not considering ANDROID_NDK_HOME because support was removed after deprecation period.
C/C++: sdkFolder is /Users/mackall/Library/Android/sdk
C/C++: sdkFolder is /Users/mackall/Library/Android/sdk
Starting process 'command '/Users/mackall/Library/Android/sdk/ndk/28.2.13676358/toolchains/llvm/prebuilt/darwin-x86_64/bin/llvm-strip''. Working directory:
/Users/mackall/development/BugTesting/mblahm/.android/Flutter Command: /Users/mackall/Library/Android/sdk/ndk/28.2.13676358/toolchains/llvm/prebuilt/darwin-x86_64/bin/llvm-strip
--strip-unneeded -o
/Users/mackall/development/BugTesting/mblahm/.android/Flutter/build/intermediates/stripped_native_libs/release/stripReleaseDebugSymbols/out/lib/armeabi-v7a/libapp.so
/Users/mackall/development/BugTesting/mblahm/.android/Flutter/build/intermediates/merged_native_libs/release/mergeReleaseNativeLibs/out/lib/armeabi-v7a/libapp.so
Starting process 'command '/Users/mackall/Library/Android/sdk/ndk/28.2.13676358/toolchains/llvm/prebuilt/darwin-x86_64/bin/llvm-strip''. Working directory:
/Users/mackall/development/BugTesting/mblahm/.android/Flutter Command: /Users/mackall/Library/Android/sdk/ndk/28.2.13676358/toolchains/llvm/prebuilt/darwin-x86_64/bin/llvm-strip
--strip-unneeded -o
/Users/mackall/development/BugTesting/mblahm/.android/Flutter/build/intermediates/stripped_native_libs/release/stripReleaseDebugSymbols/out/lib/x86_64/libapp.so
/Users/mackall/development/BugTesting/mblahm/.android/Flutter/build/intermediates/merged_native_libs/release/mergeReleaseNativeLibs/out/lib/x86_64/libapp.so
Starting process 'command '/Users/mackall/Library/Android/sdk/ndk/28.2.13676358/toolchains/llvm/prebuilt/darwin-x86_64/bin/llvm-strip''. Working directory:
/Users/mackall/development/BugTesting/mblahm/.android/Flutter Command: /Users/mackall/Library/Android/sdk/ndk/28.2.13676358/toolchains/llvm/prebuilt/darwin-x86_64/bin/llvm-strip
--strip-unneeded -o
/Users/mackall/development/BugTesting/mblahm/.android/Flutter/build/intermediates/stripped_native_libs/release/stripReleaseDebugSymbols/out/lib/arm64-v8a/libapp.so
/Users/mackall/development/BugTesting/mblahm/.android/Flutter/build/intermediates/merged_native_libs/release/mergeReleaseNativeLibs/out/lib/arm64-v8a/libapp.so
Successfully started process 'command '/Users/mackall/Library/Android/sdk/ndk/28.2.13676358/toolchains/llvm/prebuilt/darwin-x86_64/bin/llvm-strip''
Successfully started process 'command '/Users/mackall/Library/Android/sdk/ndk/28.2.13676358/toolchains/llvm/prebuilt/darwin-x86_64/bin/llvm-strip''
Successfully started process 'command '/Users/mackall/Library/Android/sdk/ndk/28.2.13676358/toolchains/llvm/prebuilt/darwin-x86_64/bin/llvm-strip''
```
</details>
## 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.
- [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
[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: Gray Mackall <mackall@google.com>
Since the `widget_preview_scaffold` project depends on both the Flutter
SDK and `flutter_tools`, `flutter_tools` must use the same version pins
as the Flutter SDK. This change ensures that any packages used by both
the Flutter SDK and `flutter_tools` use the same pinned version.
Fixes https://github.com/flutter/flutter/issues/180503
The widget preview scaffold requires that previews are defined within
importable libraries. Since Dart does not support absolute paths for
imports or relative imports outside of the project, it's not possible
for the widget previewer to display previews defined outside of `lib/`.
This change updates the preview detector to ignore libraries that don't
have a package name (e.g., libraries under `test/`) and updates
`packageName` properties to not allow for null to make it clear that
package names are required for previews.
Fixes https://github.com/flutter/flutter/issues/178651
## Description
This PR replaces `wcslen` with `wcsnlen` in the Windows runner template
and all example/dev/integration test files to address CWE-126 (Buffer
Over-read) flagged by static analysis tools (Semgrep/GitLab SAST).
## Changes
The `Utf8FromUtf16` function now uses `wcsnlen` with the
`UNICODE_STRING_MAX_CHARS` constant (32767) as the maximum length,
providing defensive programming against potential buffer over-reads.
**Key improvements:**
1. Calculate `input_length` **first** using `wcsnlen(utf16_string,
UNICODE_STRING_MAX_CHARS)`
2. Use that bounded length for **both** `WideCharToMultiByte` calls
(eliminates the `-1` unbounded read)
3. Remove the `-1` adjustment since explicit length excludes null
terminator
4. Use `static_cast` instead of C-style casts per Google C++ Style Guide
## Test Coverage
Added comprehensive edge case tests for `Utf8FromUtf16` in
`windows_startup_test`:
- **nullptr input**: Verifies function returns empty string
- **Empty string input**: Verifies function returns empty string
- **Invalid UTF-16 (unpaired surrogate)**: Verifies function handles
malformed input gracefully
These tests address reviewer feedback from @loic-sharma requesting
coverage for corner cases.
## Files Updated
**Template (source of truth):**
- `packages/flutter_tools/templates/app/windows.tmpl/runner/utils.cpp`
**Integration tests (4 files):**
- `dev/integration_tests/flutter_gallery/windows/runner/utils.cpp`
- `dev/integration_tests/ui/windows/runner/utils.cpp`
- `dev/integration_tests/windowing_test/windows/runner/utils.cpp`
- `dev/integration_tests/windows_startup_test/windows/runner/utils.cpp`
**Examples and dev apps (10 files):**
- `examples/hello_world/windows/runner/utils.cpp`
- `examples/layers/windows/runner/utils.cpp`
- `examples/platform_view/windows/runner/utils.cpp`
- `examples/flutter_view/windows/runner/utils.cpp`
- `examples/platform_channel/windows/runner/utils.cpp`
- `examples/api/windows/runner/utils.cpp`
- `examples/multiple_windows/windows/runner/utils.cpp`
- `dev/manual_tests/windows/runner/utils.cpp`
- `dev/benchmarks/complex_layout/windows/runner/utils.cpp`
- `dev/a11y_assessments/windows/runner/utils.cpp`
**Test files (4 files):**
-
`dev/integration_tests/windows_startup_test/windows/runner/flutter_window.cpp`
- `dev/integration_tests/windows_startup_test/lib/main.dart`
- `dev/integration_tests/windows_startup_test/lib/windows.dart`
-
`dev/integration_tests/windows_startup_test/test_driver/main_test.dart`
## Rationale
While the Windows API guarantees null-termination for strings returned
by `CommandLineToArgvW`, using `wcsnlen` with an explicit bound is a
defensive programming best practice that:
- Satisfies static analysis tools
- Provides an extra safety layer
- Follows the principle of defense in depth
The limit of 32767 (`UNICODE_STRING_MAX_CHARS`) is the maximum length of
a `UNICODE_STRING` structure and is far beyond any realistic
command-line argument length.
## Related Issues
Fixes https://github.com/flutter/flutter/issues/180418
## 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.
- [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 labeled this PR with
`severe: API break` if it contains a breaking change.
- [x] All existing and new tests are passing.
[Contributor Guide]:
https://github.com/flutter/flutter/blob/master/docs/contributing/Tree-hygiene.md#overview
[Tree Hygiene]:
https://github.com/flutter/flutter/blob/master/docs/contributing/Tree-hygiene.md
[test-exempt]:
https://github.com/flutter/flutter/blob/master/docs/contributing/Tree-hygiene.md#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/blob/master/docs/contributing/Style-guide-for-Flutter-repo.md
[Features we expect every widget to implement]:
https://github.com/flutter/flutter/blob/master/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/master/docs/contributing/Tree-hygiene.md#breaking-changes
The tool performs various checks to determine whether or not to
regenerate version information as part of a `flutter upgrade` instead of
just regenerating `flutter.version.json` as part of each `flutter
upgrade`. This has lead to some situations where the actual framework
version doesn't match that reported by the `flutter.version.json`.
This change updates `flutter upgrade` to always regenerate
`flutter.version.json` after checking out the new version of the
framework to ensure that it contains the latest version information.
Fixes https://github.com/flutter/flutter/issues/178926