Implements the following:
- If both --host-vmservice-port and --dds-port are specified, use the current behavior
- If only --host-vmservice-port is specified and dds is enabled, use that for the dds port
- If only --dds-port is specified, use that for the dds port
Fixes https://github.com/flutter/flutter/issues/70332
* Move web integration tool tests to web.shard
Web integration tool tests depend on DDC changes in SDK. This change
moves them to a separate shard and subshard so CI bot configurations
can run them separately.
In particular, with will allow running those tests on dart CI flutter
HHH web bot instead of a non-web one, allowing early detection and easy
classification of issues caused by SDK changes as VM- or Web related.
* Enabled verbose mode for flaky web_tool_tests
* fixed local engine crash with --enable-asserts
* Disable failing tests, fix local engine with asserts
* Removed mac web_tool_tests bot
* Addressed CR comments
* Add disabled mac web_tool_tests and disable win web_tool_tests
Necessary to work around #70013 (this looks like it will be fixed, but should protect us in the future)
Restores some notion of skipping pub, with differences from the prior implementation:
Off by default, and only used by the flutter command automatic pub get
A single check parameter. Uses the framework version cached per-project instead of a timestamp of the tool, to avoid cases where downloading a prebuilt framework would cause this check to no longer work.
* Remove references to dart:ui.Window, and point usages to PlatformDispatcher or SingletonFlutterWindow, as appropriate
* remove new test platform dispatchers
* Amend documentation
Instead of loading the use-material-design asset data from a yaml file in the repo, leave it in dart code and simplify. Remove some of the globals, but not enough to update to testWithoutContext
initialize the flutter root as early as possible. This allows all interfaces to be normally injected into commands, even if those objects might read from the flutter root.
If no source files were changed by a hot reload, do not send the reload sources RPC. This slightly speeds up the no-op reloads and gives users a faster way to force a re-render.
* [flutter_tools] Support zipped application bundles for macOS
It is not possible to directly produce a directory (.app) in some build systems
but rather it must be zip'ed before being passed to the tool for
running. This adds support for attempting to extract an application
bundle from a zip file if the bundle is not already a directory. This
uses very similar code from lib/src/application_package.dart which is
used for extracting an ipa for iOS.
This introduces tests for the macos/application_package.dart behavior which did not exist before. These tests cover the changes in the PR and some of the existing behavior, but do not cover everything in that file.
The flutter run failures are cause by the application occasionally taking a long time to start up. This caused the ios fallback discovery to kick in, which will always fail if the application hasn't started. Solution: remove the iOS fallback discovery and wait up to 30 seconds.
This has not proven to reduce the flakes, but it does at least remove one error case and removes code that will no longer work without the mDNS fallback.
Moves the flutter root initialization to a static method on the cache. This is a small step towards making this functionality non-static and instead injected like normal members - however, completely removing all of the static-ness at once was too large of a change.
Instead document and add unit tests and change existing code as little as possible.
#47161
Rolls in several fixes to web tooling, including better handling of absolute file imports. Updates to latest vm service to unblock null safety mode query
Co-authored-by: Gary Roumanis <grouma@google.com>
Co-authored-by: Anna Gringauze <annagrin@google.com>
Performs some small cleanup on the hot reload code path.
- Combines nested try/catch into single try catch, update on clause now that package:vm_service is used and Map does not need to be caught.
- Cache FlutterViews for the lifetime of the hot reload method handler
- Set asset directory path once during startup and remove conditional set during hot reload
The tool observes a large number of unhandled exceptions during the file copy portion of flutter create. it is difficult to tell whether the permission issue is caused by the source/destination, or whether it is due to a bug in dart:io.
To work around this, implement a permission check for both the source and dest files. If either fails, the tool can exit with a more specific message.
If these checks pass, then perform the actual copy. If the copy fails, fallback to manually copying the bytes
Overhaul of flutter drive in order to deliver a better experience, namely:
* flutter run and flutter drive now share more flags, so code paths that were previously only testable on run are now testable on drive.
* Removes web-initialize-platform as this is no longer used
* flutter drive correctly sets up a logger that shows native exceptions, by connecting to the vm service.
* VM service connection now provides access to memory info without launching devtools (only for debug/profile mode)
Web changes
* Passes on the one test in the repo, otherwise the webdriver code has been isolated as much as possible
Additional NNBD related bug fixes:
No longer passes --enable-experiment to the test script. (FYI @blasten ). earlier we might have assumed that the flutter gallery benchmarks would be migrated along side the app and flutter driver, but only the app under test needs to be migrated. The test scripts should never be run with the experiment.
There have been some more additional reports of a missing 'package:characters' import after upgrading flutter. This has me concerned that our pub caching logic is incorrect. Instead of the tool attempting to guess when pub should be run, always delegate to pub.
Also takes an opportunity to fix the kernel snapshot depending on the .packages or package_config. Due to the generated: date field this causes extra rebuilds. Instead when pub get is run, write out an additional file with just the package contents and version.
Fixes#66777Fixes#65723
Overhaul of flutter drive in order to deliver a better experience, namely:
flutter run and flutter drive now share more flags, so code paths that were previously only testable on run are now testable on drive.
Removes web-initialize-platform as this is no longer used
flutter drive correctly sets up a logger that shows native exceptions, by connecting to the vm service.
VM service connection now provides access to memory info without launching devtools (only for debug/profile mode)
Web changes
Passes on the one test in the repo, otherwise the webdriver code has been isolated as much as possible
Additional NNBD related bug fixes:
No longer passes --enable-experiment to the test script. (FYI @blasten ). earlier we might have assumed that the flutter gallery benchmarks would be migrated along side the app and flutter driver, but only the app under test needs to be migrated. The test scripts should never be run with the experiment.
Remove devicelab specific code for shutting down gradle daemon, add --android-gradle-daemon option to build/run/drive`. Avoids need for un-tested devicelab specific handler. There are also some feature requests for this, so 2 birds one stone.
Example:
flutter build apk --no-android-gradle-daemon will pass --no-daemon on to gradle
Remove devicelab specific code for shutting down gradle daemon, add --android-gradle-daemon option to build/run/drive`. Avoids need for un-tested devicelab specific handler. There are also some feature requests for this, so 2 birds one stone.
Example:
flutter build apk --no-android-gradle-daemon will pass --no-daemon on to gradle
This PR suggests improving the IntelliJ plugin "jar" detection logic.
Previously:
The IntelliJ Flutter plugin was contained flutter-intellij.jar.
Currently:
It is named flutter-intellij-X.Y.Z.jar and does not contain META-INF/plugin.xml.
META-INF/plugin.xml is included in flutter-idea-X.Y.Z.jar.
So this PR changes the rules for searching the plugin's jar file.
Concretely, it looks for the jar file containing META-INF/plugin.xml in the plugin's package directory and reads the package version from its META-INF/plugin.xml.
Co-authored-by: Jonah Williams <jonahwilliams@google.com>
We'd like to see how many of these flakes are transient and how many involve the device/machine getting temporarily wedged. Add a retry with no delay to see if it is possible to add sufficient error handling to startApp/installApp to handle this.
Both start and stop app create an application package, but only start app used the application binary. Create the application package once and pass it to both start and stop app.
Do not allow attach in release mode, as there is not VM Service to connect to. Observed in crash reporting as thrown string which is changed to exception below.
--use-application-binary allows running with an already built APK. This can be useful for speeding up CI test cases, or in our case eventually supporting some sort of build server. Demonstrate that this works by updating the old gallery test to use it. Fixes#56604
Co-authored-by: Jenn Magder <magder@google.com>
This class is entirely superseded by the application package factory. Only drive and install use it, and removing it from drive will allow use-application-binary support.
Android Studio 4.1 moved the location of the .home file on Windows which is used to located the install directory. This functionality is important because it is how we locate and discover the Android SDK functionality, as well as the appropriate JRE.
fixes#67986
All of the network requests from google cloud storage include an x-goog-hash header which contains an MD5 checksum. If present, use to validate that the downloaded binary is valid. This will rule out corrupt files as the cause of getting started crashers in the flutter_tool.
#38980
This does not fully resolve the above issue, because while we can check if the checksum matches what was expected from cloud storage, this A) may not necessarily be present and B) may not match up to what should be uploaded as part of the engine build process.
But when life gives you lemons you hash those lemons using an outdated hashing algorithm.
A change which sped up hot restart locally caused many of the devicelab measures to regress. I think this is because we do not measure when the isolate is actually "ready", so starting a reload or restart prematurely can cause time spent doing initialization to be registered as part of the reload operation.
A fix for this would be to have the framework include some sort of "initialization complete" event ... but it is not clear what the correct trigger would be. Perhaps after the first frame is successfully registered?
(9a3a0dc caused the benchmark regression - possibly since we spend less time syncing files now so we start the restart earlier)
Reland of #67669
The flutter tool has a number of crashes on stable where an ArgumentError is thrown due to the process manager not being able to resolve an executable.
So that we can adjust/modify this logic, fold it into flutter and add some additional logging.
caches the resolved executable per target directory, to avoid repeated look ups.
Instead of throwing an argument error, attempts to run the executable as given if an exact path can't be found
Accept files or symlinks for the executable path.
user where/which to resolve path instead of package:process logic.
On every hot reload, the flutter tool must file stat each asset in the bundle. With a large number of assets or a slow file system, this can take 20 - 30 ms. Do this operation while the flutter tool is waiting for a response from the frontend_server.
No tests updated since this is only a timing update. Any difference in behavior will be shown on benchmarks
The flutter tool has a number of crashes on stable where an ArgumentError is thrown due to the process manager not being able to resolve an executable. Fold the resolution logic into the tool and use where/which instead of the package:process specific logic.
Work towards #39925
Currently flutter run will uninstall and reinstall if the initial install fails and the APK was previously installed. Allow drive to share this same logic by moving it into installApp and out of startApp.
This should reduce the occurrence of the error in the devicelab.
This failure has been happening for a while but was covered by the overly broad catch. Removing that revealed that newer intellij versions have a different plugins file. The tool still can't find the file, but it won't crash now
Fixes#67918
For historical reasons, the flutter tool uploads dill files to paths based on the entrypoint URI. This isn't actually necessary, and the tool can use specific files : main.dart.incremental.dill for incremental dills, and main.dart.dill/main.dart.swap.dill for full dills. This allows hot restarting applications with an entrypoint outside of lib/ and simplifies the devFS code.
Fixes#63243
[flutter tools] Add a DelegatingLogger class
Move most of `DelegateLogger` `from test/src/testbed.dart` to
`lib/src/base/logger.dart` to better formalize the common practice of
chaining `Logger`s together. I renamed the class since it isn't
itself the delegate and to better match the `Delegating...` classes
from `package:collection`.
Additionally, add a freestanding `asLogger<T>` function to "cast" a
`Logger` into a matching delegate if possible. This will allow
`Logger` chains to be ordered a *bit* more freely (e.g.
`NotifyingLogger` and `AppRunLogger` will no longer required to be
at the end of the chain, an unwritten rule that has led to breakage in
google3). Chain order still matters since lack of virtual dispatch
means that parent `Logger`s can never invoke child methods, however.
I made `asLogger<T>` a freestanding function because I didn't want to
make it part of the `Logger` interface (and I thought that making it
an extension method might be weird).
Bonus cleanup:
There no longer appears to be a way to construct an `AppRunLogger`
with a null parent, so remove all of code paths for that case and
make the `parent` construction parameter required.
If the vm of an attached device rejects a hot reload, pretty print the reason. Suggest a hot restart so that users are aware that they do not have to detach and rebuild. Also resets the last compilation time, so a subsequent restart would still apply the last change. Adds an integration test for the const field removal.
Fixes#64027
The train command does nothing and was originally added to provide a no-output default for generating app-jit snapshots. The inject-plugins command is only for a repo-only analysis check, which is not necessary since we regenerate during pub get.
#29805
Move the intellij validator to its own file, and split off the tests. Remove globals from each, and remove dependency on a real jar/filesystem by creating a minimal version of the manifest xml and setting it up in the memory file system.
#47161
Do not upload all assets on initial devFS sync. This should increase the reliability of the initial connection, even in the face of flaky devfs behavior, in addition to a moderate perf improvement.
Updates fast-start to build assets as part of the initial bundle
Requires flutter/engine#21436
Requires flutter/engine#21586
Requires flutter/engine#21611
There have been some more additional reports of a missing 'package:characters' import after upgrading flutter, as well as problems with detecting the correct language version. This has me concerned that our pub caching logic is incorrect. Instead of the tool attempting to guess when pub should be run, always delegate to pub.
Split from #66776
Even if pub does not change the packge_config contents, it will still update a timestamp in one of the fields. This causes unnecessary rebuilds. To fix this, generate an additional file when running pub get that only contains the relevant fields and then update the KernelSnapshot rule to depend on it only.
When the developer doesn't have permission to create symlinks, we
display specific instructions, but they were only correct for recent
versions of Windows 10. This improves them by:
- Giving the correct instructions for older versions.
- For recent versions, adds a command that will deep-link into the
settings application so that developers don't have to figure out
where/how to enable developer mode.
Fixes https://github.com/flutter/flutter/issues/66973
Remove globals from the flutter validator class, and refactor the tests into a separate file. Applies some other cleanup like adding doc comments, and making the doctor validator work like it is documented to work - removing the gen_snapshot check if the artifact is not downloaded instead of downloading all android artifacts.
#47161
* [flutter_tools] handle case where file is deleted by other program
* Add test cases
* Update file_system.dart
* Update file_system_test.dart
* fix import
* make a static on ErrorHandligFS
* add support for no exit on failure
* address comments
* update doc comment to file or directory
Make the logic for locating a local engine path part of its own class, add documentation, and update tests to cover engine source path locating too.
#47161
Cleans up some undocumented classes and re-organizes the AndroidDevices class to avoid the need for the static testing only member. Adds a script for tracking globals.
Removes usage of global variables, expands documentation, and fixes some formatting inconsistencies. Increased test coverage for android plugin to prove it can determine the embedding version.
Disables source map production by default for build web. For web builds performed as a part of flutter run --release, enable the source maps, or allow force enabling with --source-maps command line flag.
fixes#67328
Allow providing all debugging options to the desktop engine via the FLUTTER_ENGINE_SWITCH_ environment variables.
Fixes#66532Fixes#46005Fixes#58882
The underling engine changes have already landed for Windows, macOS, but linux is still in progress
Any File-derived IOSink may throw un-handleable async exceptions into the zone, see dart-lang/sdk#43663 . Instead, just write to a file with an append mode.
This PR changes the Config class in flutter_tools to use the XDG Base directory specification instead of putting files directly in the user's home directory. If those files are already present in the home directory, they are used instead.
Refactors the desktop devices and workflow to remove unnecessary usage of global variables. This should make it easier to test and continue enhancing the desktop functionality of the tooling
#47161
Add integration tests to verify that ddc and dart2js can be built and run in sound mode. Updates dart2js compilation to insert a language version comment into the generated entrypoint if necessary.
dart-lang/sdk#42253
Flutter logs should not attempt to filter the device list based on the current project, because it does not require a current project. Also fix disabled polling test
Fixes#47996Fixes#63550
No matter what level(error, warning, info) issues flutter analyze always return fatal exit code(1). CI/CD environment receive 1(!0). This may leads to e.g. Jenkins Build step 'Execute shell' marked build as failure.
I propose according to AnalysisSeverity level return fatal(1) or success(0) exit code.
Running a build command with split debug info and analyze size causes a crash in the snapshot analysis library. Disable the combination of these two flags.
Fixes#66962
* Set DDS port to requested observatory port for test
* Add test for DDS and observatory ports
* Use FakePlatform instead of mock, fix spacing
* Use FakeProcessManager instead of mock
* Fix analyze issue
* Make completer private and add fn for future
Re-arrange the implementation of the devtools launcher so that google3 is not required to depend on any devtools packages. Also renames the build_runner folders to isolated to better clarify their intention.
In cases where the Intellij/AS plugins are not located, display links to where they can be downloaded but do not surface an error. This should generally reduce confusion about whether the plugins are required for every installed IDE. For example, frequently users may only install AS so that they can install the Android SDK - or they may have multiple copies of Intellij installed.
For example: #66762
Crash reporting shows at least one occurrence of this due to a windows file lock. That could happen if there is another running chrome instance, or perhaps a virus scanner is running. Print out the error and do not crash.
it is possible for users that download the prebuilt SDKs to run the tool without unzip installed. Rather than crashing with an unclear argument error, exit the tool with a message on how to install that mirrors the message in the update_dart_sdk.sh script.
Also applied to zip for completeness
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
This message is displayed if we do not find a pubspec.yaml
99% of the time this additional advice is going to have nothing to do with the actual error. Just remove it because it will cause more confusion than it could clear up
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.
This should be a mostly non breaking change for hot reload workflows that improves performance, but if you see anything odd with hot reload behavior on master please file a bug. This feature can also be disabled without any changes to the SDK with flutter config --no-single-widget-reload-optimization
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
Improve our ability to measure the performance of hot restart. Also flush all UI thread tasks before calling the hot restart "complete" in benchmark mode.
If this is successful at stabilizing the benchmarks, this should be enabled for "normal" hot restart so that we can accurately track execution time.
Updates all null safe dependencies to versions that allow 2.10 stable and 2.11 dev releases.
Also updates flutter_goldens and flutter_goldens_client to allow 2.11 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.
_attemptServiceConnection in FallbackDiscovery would fail if the root
library URI was not a package URI even if the VM service connection
attempt was successful. This resulted in a VM service connection being
left alive, causing DDS to fail its connection to the VM service.
Updated _attemptServiceConnection to ensure the VM service instance is
disposed after a non-connection related failure and to allow for root
library URIs with a file scheme.
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
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
If a new service worker is installed, automatically update this behind the scenes. Immediately after a page refresh, the new worker and cache will be available, though the main.dart.js and others will be available sooner due to the cache busting URLS