Instead of always exiting the tool, provide a mechanism to turn off this behavior for non-critical functionality like configuration and analytics settings.
Fixes#66786Fixes#4674
Crash reporting shows at least one instance of EACCES during an existsSync cache call. Add this to the list of error handling io methods. Did not add the async exists method since we lint against its usage.
This changes the name of the generated output files on android in case a flavor with uppercase letters is used.
Previously, the lowercased flavor name would be used for the apk/aab file. Now, the flavor name is used as-is.
ensure that the terminal handler checks if the service protocol is enabled before calling debug toggle brightness. Also removes globals from TerminalHander and test cases.
Fixes#65477
Otherwise the heuristics we have may decide to skip running pub. We should consider reducing the number of dimensions of caching here to a single check optimized for the run/test case.
Delete the destination directory for the web sdk before copying the new contents. This might fix an error where the OS refuses to overwrite the files on dev
The throttle duration could delay past the point where the destination sink was closed. Check if it is closed before adding an event. Fixes a crash on dev: StateError: Bad State: Stream is already closed.
If a file scheme and one or more roots is provided, fall back to this mapping before the direct file path if the file path cannot be turned into a package URI.
Use URI representation so that the transformation is resilient to the org-dartlang-app scheme used by the web builds.
Fixes#66095Fixes#66404
If a file scheme and one or more roots is provided, fall back to this mapping before the direct file path if the file path cannot be turned into a package URI.
Fixes#66095
The k toggle allows switching between canvaskit and html backend at runtime. unfortunately this causes hot restart to break, since the dart_sdk modules stores state at runtime. The recommendation will be to use cavaskit via dart-defines.
The main.dart.js bypass is not needed now that we have skipWaiting. Additionally optimize the fetch handler so that resources not in the cache skip the service worker altogether.
Fixes#66068
Removes the template version from the Windows template; the API and
tooling boundary will now be considered stable, so there will no longer
be frequent breaking changes.
Also updates the link for adding desktop support to a project for all
three platforms to reflect the current location.
Fixes https://github.com/flutter/flutter/issues/52748
Adds a VERSIONINFO to Runner.rc in the Windows app template, populated
from the project creation metadata.
Currently the version itself is hard-coded, but it is future-proofed to
allow plumbing the actual version through at build time via preprocessor
defines.
If the tool is downloaded from a precompiled snapshot, or if the backing source files in the pub cache are deleted, the dwds debugging functionality will break as the client.js file cannot be located. Instead use the PackageConfig to verify that package location, downloading if it is missing.
Override the dwds middleware to avoid Isolate.resolvePackageUri
Fixes#53644Fixes#65475
Generates version.json in web directory of project. version.json can be used in the future version of package_info which will support web. version.json has the following keys : app_name, version and build_number. This file is generated every time a user runs or builds the project.
Co-authored-by: Jonah Williams <jonahwilliams@google.com>
Like the ProcessException thrown from zip running on a bad file, the tool should catch the ArchiveException thrown from windows implementation using package:archive.
Port the deprecated settings devicelab test to tool integration shard. Tests that apps can be built using the deprecated android/settings.gradle file.
Part of #65790
Some terminals stdin do not support single char mode (like an emacs terminal buffer apparently). If this is the case, then the presented choice values would always have an appended newline \n which would prevent us from finding the value in the listed index (or using it as a signal for the default choice). To fix, treat '' as the default choice and always trim the choice value.
While this has seemingly always been broken, it wasn't noticeable until the multi-device selection prompt was added a few months ago.
Fixes#65267
* [gen_l10n] Support string list as preferred-supported-locales, as documented.
* [gen_l10n] Convert preferredSupportedLocale to a list of strings.
* [gen_l10n] Accept a multi option instead of a json string in the command line.
The Windows plugin CMake generation had code to ensure that the paths
written to it used POSIX separators, but the Linux version didn't; that
meant that plugin updates run on Windows machines would corrupt the
generated (but checked in) Linux CMake file.
This change shares that code so that both will use POSIX paths
regardless of what OS they are generated on.
Fixes https://github.com/flutter/flutter/issues/64591
Integration tests must only go through the real file system/process manager/platform. The global indirection makes this code harder to understand than if it directly referred to the concrete instances that are being used.
Update the integration shard to use a const instance of a LocalFIleSystem, LocalProcessManager, and LocalPlatform. Remove global usage and apply testWithoutContext.
Currently flutter run -d web creates a server with the x-frame-options: SAMEORIGIN added by default (shelf add it's by default). This doesn't allow you to use it inside a frame.
I am trying to build an embedded simulator in vscode and it requires using an iframe.
With this PR I remove the header for debug and profile mode.
The flutter tool is currently unable to detect missing permissions in gradle/gradle.bat that would cause a gradle build to fail via process exception. Rather than crashing and exiting, we can display the exception as an error message and tool exit.
While linux/macOS are able to add the +x bit, this is not possible on windows with our current file system/OS API. These crashes represent a substantial amount of crash reporting, but are otherwise not actionable on our end.
Almost all of the flag setup on Linux, macOS, and Windows should be
identical; this pulls that common setup to a shared method.
This adds support for several flags on macOS that have all the necessary
plumbing already in place due to shared backend code, but were never
enabled.
Fixes https://github.com/flutter/flutter/issues/64944
Attempt to bypass aggressive CDN by requesting main.dart.js/sw.js with a query param and defaulting index.html to online first. This will not stop aggressive CDN caching of the index.html
#64968
Exit the tool after a repeated network error to download. previously we were returning null and continuing on, leading to a ProcessException when we unzipped a missing file.
* synthetic packages by default in gen_l10n tool
* Refactor default path for synthetic package
* Remove unused import
* Code cleanup
* Further improvements to help text
* Refactor synthetic package path
* Remove newlines
* Test cleanup
* clean up logic in inputs and outputs list function
* Update l10n.yaml usage
* only add option if value is non-null
* Update stocks app as proof of concept for synthetic package usage
* Address nits
* print pubspec contents
* add print statements
* Do not allow null value for useSyntheticPackage
* +
* +
* +
* +
* Cleanup
* Add test
* Fix text
* Dont parse pubspec directly
* Test using context
* WIP: generate synthetic packages on pub get -- needs tests
* Allow null value
* Update null handling
* Refactor to properly handle null case
* Fix yamlMap condition
* Fix yaml node for real
* WIP: struggling to write tests
* WIP - take absolute path as an option
* Add tests
* Use environment project directory for synthetic package generation pathway
* Fix typo
* Improve help text
* Update defaults
* Remove unauthorized path import
* Fix pathing issues at synthetic package generation
* Fix typo in test
* Use path.join so projectDir matches up based on OS
* Fix Windows pathing in test
* Remove unnecessary replaceApp code for projectDir.path
* Use globals.fs.currentDirectory.path in resident_runner_test.dart
* Fix merge conflict
* Add test to ensure that synthetic package is generated on pub get
* Fix resident_runner_test.dart tests
* Fix tests
* Use package:file instead of dart:io
* WIP - exploration
* Remove synthetic package use from stocks example
* Update integration test to not use synthetic packages
* Remove trailing whitespace
* flutter pub get runs synth package generation
* Remove more print statements
* Add license header
* WIP - minimally working pub.get
* Use own MockBuildSystem
* Modify test and implementation to be a little cleaner
* Fix flutter pub get invocation
* Use synthetic packages in stocks app
* Revert "Use synthetic packages in stocks app"
This reverts commit 45bf24903c.
* Add environment and buildSystem params to flutter test
* Address code review feedback
* +
* Isolate codegen into its own API
* Fix imports
* Slight refactor
* Add one more test for no l10n.yaml file
* Remove unneeded mock class and import in pub_get_test.dart
* More code review feedback
* Remove unnecessary imports
* Remove `return await`s that I missed
* use arrow functions instead
* Reland "Re-enable the Dart Development Service (DDS) (#64671)"
This reverts commit 2ae25cc2d7.
* Fix MDNS building Observatory URI with port 0 instead of forwarding the device port
* Added MDNS test
This change re-enables DDS and outputs the DDS URI in place of the VM
service URI on the console. If --disable-dds is not provided,
--host-vmservice-port will be used to determine the port for DDS rather
than the host port for the VM service, which will instead be randomly
chosen.
Avoid creating AndroidDevice discovery if the SDK cannot be located. Previously the tool would use which/where adb, however this required us to handle the AndroidSdk class being potentially null - which required an additional layer of indirection around all access. Sometimes these were forgotten leading to NPEs.
In general, not much can be done with an Android Device if the actual SDK is not installed.
Reland with fixed code + tests for null SDK + adb in AndroidDeviceDiscovery
Avoid creating AndroidDevice discovery if the SDK cannot be located. Previously the tool would use which/where adb, however this required us to handle the AndroidSdk class being potentially null - which required an additional layer of indirection around all access. Sometimes these were forgotten leading to NPEs.
In general, not much can be done with an Android Device if the actual SDK is not installed.
Fixes#64246
If decoding the string contents of a stamp file fails, treat it as if the stamp file is missing. This is always safe to do, since at worst it downloads more artifacts. The files could end up corrupted if they were edited by another program, for example
Adds support for size analysis on iOS, macOS, linux, and Windows - using an uncompressed directory based approach. The output format is not currently specified.
Adds support for size analysis on android on windows, switching to package:archive
Updates the console format to display as a tree, allowing longer paths. Increases the number of dart libraries shown (to avoid only ever printing the flutter/dart:ui libraries, which dominate the size)
Like Android/iOS, only enable --null-assertions if asked. Previously this was enabled by default for web, but in general this has proved to be too breaking to enable by default.
#61042
Attempt to simplify the Android SDK interface ahead of refactoring it. The locateAndroidSdk static method is called at startup to locate the android SDK, returning null if it cannot be found. These helper methods attempted to first look up the AndroidSDK if it was already null - which could only cover the case where someone installed the Android SDK while flutter was running (possibly through an IDE)
Remove globals and testbed to simplify test cases, using the existing environment configuration. This is some pre-factoring work to make landing #63610 easier
This reverts commit adc9dde3ba.
- Fixed issue where `FallbackDiscovery` would hold on to a `VmService` when launching on iOS devices, causing DDS to fail to start
- Fixed `flutter drive` case where DDS is already running in another flutter_tools instance
The embedder requires that the isolate is unpaused, because the runInView method requires interaction with dart engine APIs that are not thread-safe. These APIs must be run on the same thread that would be blocked by the pause. Simply unpausing is not sufficient, because this does not prevent the isolate from immediately hitting a breakpoint, for example if the breakpoint was placed in a loop or in a frequently called method. Instead, all breakpoints are first disabled and then the isolate resumed.
To support #61407 , the tool needs to check if a single widget reload is feasible, and then conditionally perform a fast reassemble.
To accomplish this, the FlutterDevice class will have a WidgetCache injected. This will eventually contain the logic for parsing the invalidated dart script. Concurrent with the devFS update, the widget cache will be updated/checked if a single widget reload is feasible. If so, an expression evaluation with the target type is performed and the success is communicated through the devFS result. An integration test which demonstrates that this works is already present in https://github.com/flutter/flutter/blob/master/packages/flutter_tools/test/integration.shard/hot_reload_test.dart#L86
Finally, when actually performing the reassemble the tool simply checks if this flag has been set and calls the alternative reassemble method.
Cleanups:
Remove modules, as this is unused now.
Add feature flags for android, ios, and fuchsia (on by default). After updating the g3 rollers, the fuchsia feature will be turned off by default. Creates a simpler base type of feature flags for g3 to extend.
Updates android, ios, fuchsia workflows to use feature flags check.
Removes concept of stable artifacts and checks on flutter version.
Fixes#58999#52859#12768
Allow configuring the flutter_manifest to support a synthetic package, this is done through flutter: generate: true.
When running pub get, insert a flutter_gen entry into the packages if it does not already exist. This points to .dart_tool/flutter_gen, which can be updated to contain the generated intl sources (But doesn't currently)
Adds an integration test that verifies this code can be run and imported when enabled.
Part of #60914
* Fixing patch for coming breaking change in HttpClientRequest
* Add noSuchMethod() and comment out abort()
* Add ignore: override_on_non_overriding_member
Enable null safety asserts for web debug mode. This induces runtime asserts at the boundaries between null safe and non-null safe libraries. Adds integration test that validates assertion error is thrown.
#61042
For #61407 , we need to be able to find all widgets that of a given type. Previously I experimented with using the type name, but of course this does not handles subtypes. The actual check needs to be an is check.
Since there is no way to convert a String to a Type at runtime for use in this check, we can instead evaluate an expression which assigns a closure to a field. The idea for this was inspired by how the dart devtools adds debug functionality to older versions of flutter.
Since the reload feature is not complete yet, adds an integration test which simulates how it will eventually behave
Skip unnecessary parsing of chrome URI. Ensure stack traces are initialized in web server. Disclaimer on web server that it does not support debugging and remove help message. Fix generated entrypoint to check for main(List<String> args)
- Fixes#59643
- Fixes#55084
- Fixes#60417
Made flutter tools serve metadata produced by the frontend server:
pass --experimental-emit-metadata flag to flutter engine
store and serve metadata from web asset server
store and serve merged metadata from web asset server
add tests to verify that metadata is served from memory
update dwds version so it can read metadata
configure dwds to read metadata from file
Prerequisite changes (landed):
sdk: https://dart-review.googlesource.com/c/sdk/+/150181
flutter engine: flutter/engine#19168
webdev:dart-lang/webdev#1064
We have too many loggers, and the logger construction rules are too complicated to be untested. Capture these in a LoggerFactory and test that construction is correct.
Fixes#45075Fixes#57210
If an asset was included directly from the project root directory, then the same asset when copied to various output or ephemeral directories would also be picked up as an asset variant. This could cause assets to be recursively copied into asset/build/ephemeral directories, as each time it would run it would pick up all of the previous "variants".
The solution is to include project ephemeral directories, in addition to the build directory.
update flutter precache --force to delete all stamp files. In the event that a user is hitting a cache issue, this should be easier than re-downloading all artifacts or manually blowing away the cache.
This is probably how it should have worked in the first place
Remove globals from flutter_tester device and cleanup test case. Not completely gone since the Kernel Builder will still use them, but a good incremental improvement.
* First pass at CMake files; untested
* First pass of adding CMake generation logic on Windows
* Misc fixes
* Get bundling working, start incoprorating CMake build into tool
* Fix debug, exe name.
* Add resources
* Move cmake.dart
* Rip out all the vcxproj/solution plumbing
* Fix plugin cmake generation
* Build with cmake rather than calling VS directly
* Adjust Windows plugin template to match standard header directory structure
* Pass config selection when building
* Partially fix multi-config handling
* Rev template version
* Share the CMake generation instead of splitting it out
* VS build/run cycle works, with slightly awkward requirement to always build all
* Update manifest
* Plugin template fixes
* Minor adjustments
* Build install as part of build command, instead of separately
* Test cleanup
* Update Linux test for adjusted generated CMake approach
* Plugin test typo fix
* Add missing stub file for project test
* Add a constant for VS generator
initialize from dill does not handle changing null-safety flags and will incorrectly use the nullability mode of the last compile. Add all extra frontend options to the unique name prefix for the flutter run dill cache to avoid this situation.
In web debug mode, infer sound null safety by default. When sound null safety is enabled, provide a separate dill and precompiled Dart SDK. Release builds do not need this setting since we run dart2js from source.
Fixes#59873
The flutter daemon unconditionally waits for the appFinished signal, even if startup failed. Ensure this future is correctly completed if there is a failure in ResidentRunner.run and not just ResidentRunner.attach. Adds regression tests for run release, debug, debug web, and release web. Adds missing try catch in cold runner startup.
Manually tested with release/debug on Android and release/debug on web.
Fixes#60613
Remove unnecessary use of globals from base tests, and an android test. This changes the test to avoid bouncing through the global getters, which can lead to incorrectly cached zone values. Switches the memory filesystem implementation to the test implementation
The global packages path could cause tests to fail when it would be overriden to unexpected (in test setup) values. Remove most usage and make it a configuration on buildInfo, along with most other build information. Cleanup the asset builder to require the .packages path and the resident runners to no longer require it, since they already have the information in build_info.
It needs to stick around for the fuchsia deps we do not control.
Filled #60232 for remaining work.
First pass at fixing #57985 and implementing #59602
This doesn't have enough metadata to be useful for IDEs yet, but it prevents the issue from getting worse while we iterate on it.
WebAssetServer could fail if some of the global statics it depended on were initialized in a different order. Fix this by removing globals.
Delete dwds startup test that needs to spawn a real server.
Remove the version checking and associated warnings. The Linux template
and build process will now be subject to more typical Flutter breaking
change policy, and should no longer require regularly deleting and
recreating the platform directory.
The vm_service_integration test flake is caused by trying to call the method before the framework is initialized (and the extension added). The run errors failure is caused by the error taking some time to propagate to the harness
Update all versions, specifically file which fixes some bugs that caused tests to fail if run in different orders:
- systemTemp directories created by MemoryFileSystem will allot names based on the file system instance instead of globally.
- MemoryFile.readAsLines()/readAsLinesSync() no longer treat a final newline in the file as the start of a new, empty line.
- RecordingFile.readAsLine()/readAsLinesSync() now always record a final newline.