Commit graph

943 commits

Author SHA1 Message Date
Victoria Ashworth 7f368f7ed4
Add --no-dds to Mac_arm64_ios version of hot_mode_dev_cycle_ios__benchmark (#145335)
Attempting to debug https://github.com/flutter/flutter/issues/142305.
2024-03-18 18:51:26 +00:00
Jenn Magder a2678be7ad
Platform view devicelab ad banner scroll list real ads (#145239)
Reland https://github.com/flutter/flutter/pull/144745, which was reverted due to a the Android app ads not being set up correctly, crashing on launch: https://github.com/flutter/flutter/pull/145228

Add the missing [`com.google.android.gms.ads.APPLICATION_ID` `meta-data` tag](https://developers.google.com/admob/android/quick-start#import_the_mobile_ads_sdk) to the manifest.

Validated both `platform_views_scroll_perf__timeline_summary` and `platform_views_scroll_perf_impeller__timeline_summary` ran locally on an Android emulator.

Successful presubmit runs:
https://ci.chromium.org/ui/p/flutter/builders/try/Linux_pixel_7pro%20platform_views_scroll_perf__timeline_summary/4/overview
https://ci.chromium.org/ui/p/flutter/builders/try/Linux_pixel_7pro%20platform_views_scroll_perf_impeller__timeline_summary/4/overview

Original commit message:
_________
This benchmark is to measure the platform view performance improvement. 

It is similar to https://github.com/lucalooz/flutter_ads_list_perf

There's still a pending issue https://github.com/flutter/flutter/issues/144339

Fixes https://github.com/flutter/flutter/issues/143534
Fixes https://github.com/flutter/flutter/issues/143257
2024-03-16 05:44:21 +00:00
auto-submit[bot] ca2d4865cf
Reverts "Reland: "Platform view devicelab ad banner scroll list real ads" (#145224)" (#145228)
Reverts: flutter/flutter#145224
Initiated by: hellohuanlin
Reason for reverting: breaks the tree
Original PR Author: hellohuanlin

Reviewed By: {gmackall, jmagman}

This change reverts the following previous change:
Reland https://github.com/flutter/flutter/pull/144745, which got reverted due to Android lockfile. Fixed by `dart dev/tools/bin/generate_gradle_lockfiles.dart`

*List which issues are fixed by this PR. You must list at least one issue. An issue is not required if the PR fixes something trivial like a typo.*

Fixes https://github.com/flutter/flutter/issues/143534
Fixes https://github.com/flutter/flutter/issues/143257

*If you had to change anything in the [flutter/tests] repo, include a link to the migration guide as per the [breaking change policy].*
2024-03-15 20:09:18 +00:00
hellohuanlin da4d0e4fab
Reland: "Platform view devicelab ad banner scroll list real ads" (#145224)
Reland https://github.com/flutter/flutter/pull/144745, which got reverted due to Android lockfile. Fixed by `dart dev/tools/bin/generate_gradle_lockfiles.dart`

*List which issues are fixed by this PR. You must list at least one issue. An issue is not required if the PR fixes something trivial like a typo.*

Fixes https://github.com/flutter/flutter/issues/143534
Fixes https://github.com/flutter/flutter/issues/143257

*If you had to change anything in the [flutter/tests] repo, include a link to the migration guide as per the [breaking change policy].*
2024-03-15 19:20:25 +00:00
auto-submit[bot] 7f1c93d732
Reverts "Platform view devicelab ad banner scroll list real ads (#144745)" (#145189)
Reverts: flutter/flutter#144745
Initiated by: gspencergoog
Reason for reverting: appears to have broken the build.

Original PR Author: hellohuanlin

Reviewed By: {jmagman, jonahwilliams}

This change reverts the following previous change:
This benchmark is to measure the platform view performance improvement. 

It is similar to https://github.com/lucalooz/flutter_ads_list_perf

There's still a pending issue https://github.com/flutter/flutter/issues/144339

*List which issues are fixed by this PR. You must list at least one issue. An issue is not required if the PR fixes something trivial like a typo.*

Fixes https://github.com/flutter/flutter/issues/143534
Fixes https://github.com/flutter/flutter/issues/143257

*If you had to change anything in the [flutter/tests] repo, include a link to the migration guide as per the [breaking change policy].*
2024-03-15 00:21:25 +00:00
hellohuanlin be78542d6c
Platform view devicelab ad banner scroll list real ads (#144745)
This benchmark is to measure the platform view performance improvement. 

It is similar to https://github.com/lucalooz/flutter_ads_list_perf

There's still a pending issue https://github.com/flutter/flutter/issues/144339

*List which issues are fixed by this PR. You must list at least one issue. An issue is not required if the PR fixes something trivial like a typo.*

Fixes https://github.com/flutter/flutter/issues/143534
Fixes https://github.com/flutter/flutter/issues/143257

*If you had to change anything in the [flutter/tests] repo, include a link to the migration guide as per the [breaking change policy].*
2024-03-14 21:41:07 +00:00
Victoria Ashworth 7e05bc4b30
Fix embedding FlutterMacOS.framework for macOS add2app via cocoapods (#144248)
Fixes https://github.com/flutter/flutter/issues/144244.
2024-03-05 21:59:49 +00:00
Victoria Ashworth d1d9605974
Remove force Xcode debug workflow (#144185)
Now that all tests are on Xcode 15 and iOS 17, we no longer need to force test Xcode debug workflow.

Related https://github.com/flutter/flutter/issues/144020.
2024-02-27 18:18:07 +00:00
Nate c53a18f4e4
Implementing null-aware operators throughout the repository (#143804)
This pull request fixes #143803 by taking advantage of Dart's null-aware operators.

And unlike `switch` expressions ([9 PRs](https://github.com/flutter/flutter/pull/143634) and counting), the Flutter codebase is already fantastic when it comes to null-aware coding. After refactoring the entire repo, all the changes involving `?.` and `??` can fit into a single pull request.
2024-02-23 19:02:22 +00:00
Jonah Williams 27cacca011
[devicelab] migrate new gallery benchmarks to local copy. (#143545)
This is the next step in archiving flutter/gallery - move devicelab tests to use the local copy.
2024-02-15 22:32:38 +00:00
Jenn Magder 01f81b322c
Remove unused devicelab task gradle_non_android_plugin_test (#142742)
I moved this test to integration.shard in https://github.com/flutter/flutter/pull/80161.  Remove the no-op task https://github.com/flutter/flutter/issues/85347.
2024-02-07 18:41:55 +00:00
Jenn Magder 89d46db775
Remove outdated arm64_armv7 check (#142737)
CI is running Xcode 15, remove outdated arm64_armv7 framework checks.
2024-02-01 19:27:56 +00:00
Jenn Magder 91f0878fed
Move iOS content validation devicelab test into tool integration test (#142272)
The archiving was running in devicelab because certs are needed to codesign (see #73577).  However now the certs are available in chromium bots.  Move the archiving test into the existing tool integration test, and delete the devicelab variant.

arm64:
https://logs.chromium.org/logs/flutter/buildbucket/cr-buildbucket/8757886514651624673/+/u/run_test.dart_for_tool_host_cross_arch_tests_shard_and_subshard_None/test_stdout#L6074_4
x64:
https://logs.chromium.org/logs/flutter/buildbucket/cr-buildbucket/8757886514651624689/+/u/run_test.dart_for_tool_host_cross_arch_tests_shard_and_subshard_None/test_stdout#L6389_2

Part of https://github.com/flutter/flutter/issues/142070
2024-01-26 18:04:09 +00:00
Matan Lurey 2f6fdf2650
Start renaming by adding a new bringup: true as an Android emulator. (#142257)
Part 2 of https://github.com/flutter/flutter/issues/142178.

Supersedes https://github.com/flutter/flutter/pull/142078.

Feedback welcome to avoid reverts!
2024-01-26 01:07:08 +00:00
Matan Lurey b3da19f879
Refactor external_ui without making any name changes (I think) (#142192)
Work towards https://github.com/flutter/flutter/issues/142178.

---

This PR makes no _behavioral_ changes to executed code, and instead
focuses on organization and naming:

1. Extended the README to explain the intent of the test, as well as how
to run it
1. Renamed `main.dart` and `main_test.dart` to `frame_rate_main.dart`
and `frame_rate_test.dart` (we'll add more)
1. Did some refactoring of the test to make it more obvious what is
being asserted (i.e. `widgetBuilds` and friends)
2024-01-24 17:14:16 -08:00
godofredoc d51858c2e1
Migrate android views to devicelab. (#142081)
Migrate android view out of recipes.
2024-01-24 23:11:12 +00:00
auto-submit[bot] 54e9f2dbe6
Reverts "Refactor external_uiexternal_textures" (#142173)
Reverts flutter/flutter#142062
Initiated by: eliasyishak
This change reverts the following previous change:
Original Description:
This PR makes no _behavioral_ changes to executed code, and instead focuses on organization and naming:

1. Almost[^1] anything named `external_ui` is renamed `external_textures`
1. Extended the README to explain the intent of the test, as well as how to run it
1. Renamed `main.dart` and `main_test.dart` to `frame_rate_main.dart` and `frame_rate_test.dart` (we'll add more)
1. Did some refactoring of the test to make it more obvious what is being asserted (i.e. `widgetBuilds` and friends)

Given how complex (and in-flux) this directory is, I'm also requesting either John, Jonah or I review any changes.

[^1]: Except the name of the `.ci.yaml` task, i.e. `name: Linux_pixel_7pro external_ui_integration_test` because I'm apparently not able to change that without creating a new task as `bringup: true` and playing a bit of a dance. Maybe that's worth doing though (in future PRs)?
2024-01-24 21:41:17 +00:00
Matan Lurey 2e2042ff8e
Refactor external_uiexternal_textures (#142062)
This PR makes no _behavioral_ changes to executed code, and instead
focuses on organization and naming:

1. Almost[^1] anything named `external_ui` is renamed
`external_textures`
1. Extended the README to explain the intent of the test, as well as how
to run it
1. Renamed `main.dart` and `main_test.dart` to `frame_rate_main.dart`
and `frame_rate_test.dart` (we'll add more)
1. Did some refactoring of the test to make it more obvious what is
being asserted (i.e. `widgetBuilds` and friends)

Given how complex (and in-flux) this directory is, I'm also requesting
either John, Jonah or I review any changes.

[^1]: Except the name of the `.ci.yaml` task, i.e. `name:
Linux_pixel_7pro external_ui_integration_test` because I'm apparently
not able to change that without creating a new task as `bringup: true`
and playing a bit of a dance. Maybe that's worth doing though (in future
PRs)?
2024-01-24 12:44:31 -08:00
林洵锋 f340d207f6
Adjust the position of require File.expand_path (#141521)
On `Podfile`:

```ruby
flutter_application_path = '../flutter_module'
load File.join(flutter_application_path, '.ios', 'Flutter', 'podhelper.rb')

target 'OCProject' do
  # Comment the next line if you don't want to use dynamic frameworks
  use_frameworks!

  # Pods for OCProject
  # install_all_flutter_pods(flutter_application_path)
  # install_flutter_engine_pod(flutter_application_path)
  # install_flutter_application_pod(flutter_application_path)
  install_flutter_plugin_pods(flutter_application_path)

end

post_install do |installer|
  flutter_post_install(installer)
end
```
Encountering the following error after executing `pod install`:

```shell
pod install

[!] Invalid `Podfile` file: undefined method `flutter_relative_path_from_podfile' for #<Pod::Podfile:0x000000010e74c520 @defined_in_file=#<Pathname:/Users/lxf/gitHub/flutter_hybrid_bug/OCProject/Podfile>, @internal_hash={}, @root_target_definitions=[#<Pod::Podfile::TargetDefinition label=Pods>], @current_target_definition=#<Pod::Podfile::TargetDefinition label=Pods>>

  relative = flutter_relative_path_from_podfile(export_script_directory)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^.

 #  from /Users/lxf/gitHub/flutter_hybrid_bug/OCProject/Podfile:17
 #  -------------------------------------------
 #    # install_flutter_plugin_pods(flutter_application_path)
 >    install_flutter_application_pod(flutter_application_path)
 #
 #  -------------------------------------------
```

The `flutter_relative_path_from_podfile` method is in `flutter_tools/bin/podhelper.rb`, but now `flutter_tools/bin/podhelper.rb` is only required in `install_all_flutter_pods` in `podhelper.rb.tmpl`.

Sometimes we only need to use the `install_flutter_plugin_pods` method in podhelper.rb. For example, using `Shorebird` in an iOS hybird app scenario, we need to build `Flutter.xcframework` and `App.xcframework` and embed them into the iOS native project. In order to avoid unnecessary conflicts, use `install_flutter_plugin_pods` method to install Flutter plugin pods.

[Shorebird - Code Push In Hybrid Apps](https://docs.shorebird.dev/guides/hybrid-app/ios)

So I adjust the position of `require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)`.
2024-01-21 06:18:26 +00:00
Daco Harkes 2e229be2ff
Native assets: package in framework on iOS and MacOS (#140907)
Packages the native assets for iOS and MacOS in frameworks.

Issue:

* https://github.com/flutter/flutter/issues/140544
* https://github.com/flutter/flutter/issues/129757

## Details

* [x] This packages dylibs from the native assets feature in frameworks. It packages every dylib in a separate framework.
* [x] The dylib name is updated to use `@rpath` instead of `@executable_path`.
* [x] The dylibs for flutter-tester are no longer modified to change the install name. (Previously it was wrongly updating the install name to the location the dylib would have once deployed in an app.)
* [x] Use symlinking on MacOS.
2024-01-19 20:29:13 +00:00
Reid Baker 2b890af939
handle rc versions of gradle in version compare (#141612)
- handle number format exceptions and strip rc information from version compare
- add test that handles rc format

part 2/n https://github.com/flutter/flutter/issues/138523

Helpfully pointed out by [asaarnak](https://github.com/asaarnak) https://github.com/flutter/flutter/pull/139325#issuecomment-1892554584
2024-01-16 19:29:26 +00:00
Spt 3d112429cc
Solve the problem that <Flutter/Flutter.h> cannot be imported when a pod transitive depends on Flutter (#125610)
![image](https://user-images.githubusercontent.com/8318578/234780282-89b18d27-df49-4b4e-88b5-c9d17cf3334f.png)
![image](https://user-images.githubusercontent.com/8318578/234780668-901ab816-5b6b-4d87-a6f4-120b5852580c.png)
If a pod transitive depends on a pod containing a framework, cocoapods will add the path of the framework to its FRAMEWORK_SEARCH_PATHS.
So I modified the relevant logic in podhelper, hoping to be consistent with the behavior of cocoapods.

Fixes https://github.com/flutter/flutter/issues/126251.
2024-01-16 15:36:38 +00:00
Daco Harkes b2ef2802d2
Native assets support for Android Add2app (#140802)
Support for FFI calls with @Native external functions through Native assets on Android add to app. This enables bundling native code without any build-system boilerplate code.

For more info see:

*  https://github.com/flutter/flutter/issues/129757

## Implementation details for Android add2app

The `.so` files are bundled with the same mechanism that bundles `libapp.so`.
2024-01-09 08:47:53 +00:00
John McCutchan dcc2c91471
Verified input test take 2 (#140836)
This is a reland of https://github.com/flutter/flutter/pull/140806 which had an issue with package versions.
2024-01-03 01:17:08 +00:00
Jenn Magder b08fc60024
Set template and migrate apps to iOS 12 minimum (#140823)
Reland https://github.com/flutter/flutter/pull/140478 with `ios_content_validation_test` test fix.
```
[ios_content_validation_test] Process terminated with exit code 0.
Task result:
{
  "success": true,
  "data": null,
  "detailFiles": [],
  "benchmarkScoreKeys": [],
  "reason": "success"
}

```

__________

1. Change templates to `IPHONEOS_DEPLOYMENT_TARGET`, `MinimumOSVersion`, and Podfile `platform :ios` to 12.0.
2. Add migrator for Podfile part to migrate `platform :ios, '11.0'` -> `platform :ios, '12.0'`
3. Compile with `-miphoneos-version-min=12.0`
4. Run the migrator on all example apps and integration tests.

See also https://github.com/flutter/flutter/pull/62902 and https://github.com/flutter/flutter/pull/85174 and https://github.com/flutter/flutter/pull/101963

Fixes https://github.com/flutter/flutter/issues/136060
2024-01-03 00:47:40 +00:00
auto-submit[bot] 8e431e106e
Reverts "Verified input integration test" (#140833)
Reverts flutter/flutter#140806
Initiated by: zanderso
This change reverts the following previous change:
Original Description:
This is an integration test associated with https://github.com/flutter/engine/pull/49268
2024-01-02 22:44:18 +00:00
John McCutchan ac9a8eb669
Verified input integration test (#140806)
This is an integration test associated with
https://github.com/flutter/engine/pull/49268
2024-01-02 14:20:35 -08:00
Andrew Kolos 9e104eb7c8
Fix flavor conditional asset bundling for macos (#140433)
Fixes https://github.com/flutter/flutter/issues/140430
Fixes https://github.com/flutter/flutter/issues/140432 while we are at it
2023-12-21 20:30:21 +00:00
Victoria Ashworth 6981fe6fd3
Remove workarounds for plugin_lint_mac needed for older version of Cocoapods (#140395)
CI has been updated to Cocoapods 1.13, which fixes previous issues with the `plugin_lint_mac` test. Remove workarounds added previously.

Fixes https://github.com/flutter/flutter/issues/125812. 

See also https://github.com/flutter/flutter/issues/133584.
2023-12-19 20:19:52 +00:00
Andrew Kolos f8b9748661
Restore and fix flavors_test_macos (#139841)
Partially resolves[^1] https://github.com/flutter/flutter/issues/139774.

Effectively reverts https://github.com/flutter/flutter/pull/125581.

The main change here is that I deleted and recreated the macos Xcode project for this integration test (hence the large diff). I tried fixing the existing project first, but it was set up quite differently, and—for whatever reason—the integration test would get stuck trying to load `dev/integration_tests/flavors/integration_test/integration_test.dart`.

I verified that this works locally, but I don't know if it's possible to run this on the devicelab try pool to verify that it works on devicelab hardware.

[^1]: I would not close the issue until 1) this PR lands, 2) the integration test consistently passes on CI, and 3) macOS support for flavors is publicly documented.
2023-12-18 08:52:22 +00:00
Andrew Kolos 935775cb74
[reland] Support conditional bundling of assets based on --flavor (#139834)
Reland of https://github.com/flutter/flutter/pull/132985. Fixes the path to AssetManifest.bin in flavors_test_ios
2023-12-14 05:30:10 +00:00
Daco Harkes 3b370c8539
[deps] update Android SDK to 34 (#138183)
Update Android SDK from 33 to 34.

Following the engine update:

* https://github.com/flutter/engine/pull/47839
2023-12-14 00:55:57 +00:00
Reid Baker 3c80cc7eb9
Do not use project in do last (#139325)
- Use copy task that branches for 8.3 and above to avoid using project.exec in a dolast block. 

part 1/n for flutter/flutter/issues/138523 

This PR does not test the 8.3 branch but instead builds the ability to write a branching gradle test. 
After fixing this project.exec action there I discovered a second that needs to be removed or migrated in order for the build to work. 

Related reading https://docs.gradle.org/8.0/userguide/configuration_cache.html#config_cache:requirements
https://docs.gradle.org/current/javadoc/org/gradle/process/ExecOperations.html (not used but considered) 
https://docs.gradle.org/8.2/dsl/org.gradle.api.tasks.Copy.html#org.gradle.api.tasks.Copy:fileMode
2023-12-13 23:47:58 +00:00
auto-submit[bot] 21766a4f9f
Reverts "Support conditional bundling of assets based on --flavor" (#139787)
Reverts flutter/flutter#132985
Initiated by: christopherfujino
This change reverts the following previous change:
Original Description:
Provides support for conditional bundling of assets through the existing `--flavor` option for `flutter build` and `flutter run`. Closes https://github.com/flutter/flutter/issues/21682. Resolves https://github.com/flutter/flutter/issues/136092

## Change
Within the `assets` section pubspec.yaml, the user can now specify one or more `flavors` that an asset belongs to. Consider this example:

```yaml
# pubspec.yaml
flutter:
  assets:
    - assets/normal-asset.png
    - path: assets/vanilla/ice-cream.png
      flavors: 
        - vanilla
    - path: assets/strawberry/ice-cream.png
      flavors:
        - strawberry
```

With this pubspec,
* `flutter run --flavor vanilla` will not include `assets/strawberry/ice-cream.png` in the build output.
* `flutter run --flavor strawberry` will not include `assets/vanilla/ice-cream.png`.
* `flutter run` will only include `assets/normal-asset.png`.

## Open questions

* Should this be supported for all platforms, or should this change be limited to ones with documented `--flavor` support (Android, iOS, and (implicitly) MacOS)? This PR currently only enables this feature for officially supported platforms.

## Design thoughts, what this PR does not do, etc.

### This does not provide an automatic mapping/resolution of asset keys/paths to others based on flavor at runtime.

The implementation in this PR represents a simplest approach. Notably, it does not give Flutter the ability to dynamically choose an asset based on flavor using a single asset key. For example, one can't use `Image.asset('config.json')` to dynamically choose between different "flavors" of `config.json` (such as `dev-flavor/config.json` or `prod-flavor/config.json`). However, a user could always implement such a mechanism in their project or in a library by examining the flavor at runtime.

### When multiple entries affect the same file and 1) at least one of these entries have a `flavors` list provided and 2) these lists are not equivalent, we always consider the manifest to be ambiguous and will throw a `ToolExit`. 

<details>
For example, these manifests would all be considered ambiguous:

```yaml
assets:
  - assets/
  - path: assets/vanilla.png
    flavors: 
      - vanilla

assets:
  - path: assets/vanilla/
    flavors: 
      - vanilla
  - path: assets/vanilla/cherry.png
     flavor:
      - cherry

# Thinking towards the future where we might add glob/regex support and more conditions other than flavor:
assets:
  - path: assets/vanilla/**
    flavors:
      - vanilla
  - path: assets/**/ios/**
    platforms: 
       - ios

# Ambiguous in the case of assets like "assets/vanilla/ios/icon.svg" since we 
# don't know if flavor `vanilla` and platform `ios` should be combined using or-logic or and-logic.
```

See [this review comment thread](https://github.com/flutter/flutter/pull/132985#discussion_r1381909942) for the full story on how I arrived at this decision.
</details>

### This does not support Android's multidimensional flavors feature (in an intuitive way)

<details>

Conder this excerpt from a Flutter project's android/app/build.gradle file:

```groovy
android {
    // ...

    flavorDimensions "mode", "api"

    productFlavors {
        free {
            dimension "mode"
            applicationIdSuffix ".free"
        }

        premium {
            dimension "mode"
            applicationIdSuffix ".premium"
        }

        minApi23 {
            dimension "api"
            versionNameSuffix "-minApi23"
        }

        minApi21 {
            dimension "api"
            versionNameSuffix "-minApi21"
        }
    }
}
```

In this setup, the following values are valid `--flavor` are valid `freeMinApi21`, `freeMinApi23`, `premiumMinApi21`, and `premiumMinApi23`. We call these values "flavor combinations". Consider the following from the Android documentation[^1]:

> In addition to the source set directories you can create for each individual product flavor and build variant, you can also create source set directories for each combination of product flavors. For example, you can create and add Java sources to the src/demoMinApi24/java/ directory, and Gradle uses those sources only when building a variant that combines those two product flavors.
> 
> Source sets you create for product flavor combinations have a higher priority than source sets that belong to each individual product flavor. To learn more about source sets and how Gradle merges resources, read the section about how to [create source sets](https://developer.android.com/build/build-variants#sourcesets).

This feature will not behave in this way. If a user utilizes this feature and also Android's multidimensional flavors feature, they will have to list out all flavor combinations that contain the flavor they want to limit an asset to:

```yaml
assets:
  - assets/free/
    flavors:
      - freeMinApi21
      - freeMinApi23
```

This is mostly due to a technical limitation in the hot-reload feature of `flutter run`. During a hot reload, the tool will try to update the asset bundle on the device, but the tool does not know the flavors contained within the flavor combination (that the user passes to `--flavor`). Gradle is the source of truth of what flavors were involved in the build, and `flutter run` currently does not access to that information since it's an implementation detail of the build process. We could bubble up this information, but it would require a nontrivial amount of engineering work, and it's unclear how desired this functionality is. It might not be worth implementing.

</details>

See https://flutter.dev/go/flavor-specific-assets for the (outdated) design document. 

<summary>Pre-launch Checklist</summary>

</details>

[^1]: https://developer.android.com/build/build-variants#flavor-dimensions
2023-12-08 06:40:28 +00:00
Andrew Kolos 016eb85177
Support conditional bundling of assets based on --flavor (#132985)
Provides support for conditional bundling of assets through the existing `--flavor` option for `flutter build` and `flutter run`. Closes https://github.com/flutter/flutter/issues/21682. Resolves https://github.com/flutter/flutter/issues/136092

## Change
Within the `assets` section pubspec.yaml, the user can now specify one or more `flavors` that an asset belongs to. Consider this example:

```yaml
# pubspec.yaml
flutter:
  assets:
    - assets/normal-asset.png
    - path: assets/vanilla/ice-cream.png
      flavors: 
        - vanilla
    - path: assets/strawberry/ice-cream.png
      flavors:
        - strawberry
```

With this pubspec,
* `flutter run --flavor vanilla` will not include `assets/strawberry/ice-cream.png` in the build output.
* `flutter run --flavor strawberry` will not include `assets/vanilla/ice-cream.png`.
* `flutter run` will only include `assets/normal-asset.png`.

## Open questions

* Should this be supported for all platforms, or should this change be limited to ones with documented `--flavor` support (Android, iOS, and (implicitly) MacOS)? This PR currently only enables this feature for officially supported platforms.

## Design thoughts, what this PR does not do, etc.

### This does not provide an automatic mapping/resolution of asset keys/paths to others based on flavor at runtime.

The implementation in this PR represents a simplest approach. Notably, it does not give Flutter the ability to dynamically choose an asset based on flavor using a single asset key. For example, one can't use `Image.asset('config.json')` to dynamically choose between different "flavors" of `config.json` (such as `dev-flavor/config.json` or `prod-flavor/config.json`). However, a user could always implement such a mechanism in their project or in a library by examining the flavor at runtime.

### When multiple entries affect the same file and 1) at least one of these entries have a `flavors` list provided and 2) these lists are not equivalent, we always consider the manifest to be ambiguous and will throw a `ToolExit`. 

<details>
For example, these manifests would all be considered ambiguous:

```yaml
assets:
  - assets/
  - path: assets/vanilla.png
    flavors: 
      - vanilla

assets:
  - path: assets/vanilla/
    flavors: 
      - vanilla
  - path: assets/vanilla/cherry.png
     flavor:
      - cherry

# Thinking towards the future where we might add glob/regex support and more conditions other than flavor:
assets:
  - path: assets/vanilla/**
    flavors:
      - vanilla
  - path: assets/**/ios/**
    platforms: 
       - ios

# Ambiguous in the case of assets like "assets/vanilla/ios/icon.svg" since we 
# don't know if flavor `vanilla` and platform `ios` should be combined using or-logic or and-logic.
```

See [this review comment thread](https://github.com/flutter/flutter/pull/132985#discussion_r1381909942) for the full story on how I arrived at this decision.
</details>

### This does not support Android's multidimensional flavors feature (in an intuitive way)

<details>

Conder this excerpt from a Flutter project's android/app/build.gradle file:

```groovy
android {
    // ...

    flavorDimensions "mode", "api"

    productFlavors {
        free {
            dimension "mode"
            applicationIdSuffix ".free"
        }

        premium {
            dimension "mode"
            applicationIdSuffix ".premium"
        }

        minApi23 {
            dimension "api"
            versionNameSuffix "-minApi23"
        }

        minApi21 {
            dimension "api"
            versionNameSuffix "-minApi21"
        }
    }
}
```

In this setup, the following values are valid `--flavor` are valid `freeMinApi21`, `freeMinApi23`, `premiumMinApi21`, and `premiumMinApi23`. We call these values "flavor combinations". Consider the following from the Android documentation[^1]:

> In addition to the source set directories you can create for each individual product flavor and build variant, you can also create source set directories for each combination of product flavors. For example, you can create and add Java sources to the src/demoMinApi24/java/ directory, and Gradle uses those sources only when building a variant that combines those two product flavors.
> 
> Source sets you create for product flavor combinations have a higher priority than source sets that belong to each individual product flavor. To learn more about source sets and how Gradle merges resources, read the section about how to [create source sets](https://developer.android.com/build/build-variants#sourcesets).

This feature will not behave in this way. If a user utilizes this feature and also Android's multidimensional flavors feature, they will have to list out all flavor combinations that contain the flavor they want to limit an asset to:

```yaml
assets:
  - assets/free/
    flavors:
      - freeMinApi21
      - freeMinApi23
```

This is mostly due to a technical limitation in the hot-reload feature of `flutter run`. During a hot reload, the tool will try to update the asset bundle on the device, but the tool does not know the flavors contained within the flavor combination (that the user passes to `--flavor`). Gradle is the source of truth of what flavors were involved in the build, and `flutter run` currently does not access to that information since it's an implementation detail of the build process. We could bubble up this information, but it would require a nontrivial amount of engineering work, and it's unclear how desired this functionality is. It might not be worth implementing.

</details>

See https://flutter.dev/go/flavor-specific-assets for the (outdated) design document. 

<summary>Pre-launch Checklist</summary>

</details>

[^1]: https://developer.android.com/build/build-variants#flavor-dimensions
2023-12-07 23:50:00 +00:00
Daco Harkes 6ad755536e
Native assets support for Android (#135148)
Support for FFI calls with `@Native external` functions through Native assets on Android. This enables bundling native code without any build-system boilerplate code.

For more info see:

* https://github.com/flutter/flutter/issues/129757

### Implementation details for Android.

Mainly follows the design of the previous PRs.

For Android, we detect the compilers inside the NDK inside SDK.

And bundling of the assets is done by the flutter.groovy file.

The `minSdkVersion` is propagated from the flutter.groovy file as well.

The NDK is not part of `flutter doctor`, and users can omit it if no native assets have to be build.
However, if any native assets must be built, flutter throws a tool exit if the NDK is not installed.

Add 2 app is not part of this PR yet, instead `flutter build aar` will tool exit if there are any native assets.
2023-12-07 16:29:11 +00:00
Pavel Mazhnik 0f67c99208
[flutter_tools] build ios-frameworks: option to exclude plugin frameworks from the build (#129739)
A lot of details are written in the feature request: https://github.com/flutter/flutter/issues/114692.

tl;dr: Options B & C from the add2app iOS guide have a limitation (build error) in case the Flutter plugin and native iOS app have a shared dependency. We can use a workaround to avoid the issue, but in this case we don't need to build frameworks for plugins.

Closes https://github.com/flutter/flutter/issues/114692
Part of https://github.com/flutter/flutter/issues/130220
2023-12-04 20:29:53 +00:00
Jonah Williams c421f65b3b
Add Impeller complex layout impeller benchmarks. (#139490)
These benchmarks do a nice job of showing CPU overhead, which is useful for many of the microoptimizations we've been doing.
2023-12-04 19:23:26 +00:00
Ian Hickson 5e216d44ca
Simplify devicelab logic and fix tests (#139122)
- fix https://github.com/flutter/flutter/issues/53707 by having the test not expect a timeout but instead actually look for the retry message
- simplify the `--task` option to only accept task names rather than also accepting paths
- remove some obsolete options that referred to the manifest which no longer seems to exist
2023-11-29 08:41:27 +00:00
Daco Harkes 7634609062
Pin dart-lang/native dependencies (#137601)
Pin the dependencies from dart-lang/native to a specific version during testing (rather than having them auto-upgrade during pub resolution). This will prevent tests using the template to start failing if a bad version is published to pub.

Closes: https://github.com/flutter/flutter/issues/137418

Also bumps dep in flutter_tools.
2023-11-03 22:16:04 +00:00
Victoria Ashworth 5dd2a4e0aa
Ensure Xcode project is setup to start debugger (#136977)
Some users have their Xcode settings set to not debug (see example here https://github.com/flutter/flutter/issues/136197#issuecomment-1766834195). This will cause the [engine check for a debugger](22ce5c6a45/runtime/ptrace_check.cc (L56-L71)) to fail, which will cause an error and cause the app to crash.

This PR parses the scheme file to ensure the scheme is set to start a debugger and warn the user if it's not.

Fixes https://github.com/flutter/flutter/issues/136197.
2023-10-25 17:08:57 +00:00
Victoria Ashworth ddc9b40a98
Fix typo in function name (#136273)
Rename `removeIOSimulator` to `removeIOSSimulator`.
2023-10-12 15:53:00 +00:00
Jonah Williams a106b81cc5
[framework] restore old zoom page transition for benchmarking. (#133346)
In the past I switched the implementation of the zoom page transition because the performance of the old transition was terrible, but I'm hopeful that with Impeller we'll be able to identify and fix the issues that made it so slow. In order to evaluate this though, we need to be able to opt into the old transition for benchmarks on CI.

https://github.com/flutter/flutter/issues/129742
https://github.com/flutter/flutter/issues/121325
2023-10-10 22:27:07 +00:00
Michael Goderbauer b0a90aee17
Enable strict-inference (#135043)
Avoids that dynamic accidentally sneaks in, see https://dart.dev/tools/analysis#enabling-additional-type-checks
2023-09-20 19:59:08 +00:00
gaaclarke 57ad4ff018
Added a devicelab test for vulkan validation layers (#134685)
This makes sure validation layers are being used and that there are no
validation errors

fixes https://github.com/flutter/flutter/issues/134175

## 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] All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel
on [Discord].

<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#overview
[Tree Hygiene]: https://github.com/flutter/flutter/wiki/Tree-hygiene
[test-exempt]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo
[Features we expect every widget to implement]:
https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo#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/wiki/Tree-hygiene#handling-breaking-changes
[Discord]: https://github.com/flutter/flutter/wiki/Chat
2023-09-14 09:13:35 -07:00
Victoria Ashworth af5ac930d8
Set the CONFIGURATION_BUILD_DIR in generated xcconfig when debugging core device (#134493)
Xcode uses the CONFIGURATION_BUILD_DIR build setting to determine the location of the bundle to build and install. When launching an app via Xcode with the Xcode debug workflow (for iOS 17 physical devices), temporarily set the CONFIGURATION_BUILD_DIR to the location of the bundle so Xcode can find it.

Also, added a Xcode Debug version of the `microbenchmarks_ios` integration test since it uses `flutter run --profile` without using `--use-application-binary`.

Fixes https://github.com/flutter/flutter/issues/134186.
2023-09-13 18:08:35 +00:00
Michael Goderbauer b966b2beee
Enable private field promotion for dev (#134480)
New feature in upcoming Dart 3.2. See https://github.com/dart-lang/language/issues/2020. Feature is enabled by bumping the min SDK version to 3.2.

Part of https://github.com/flutter/flutter/issues/134476.
2023-09-12 18:29:00 +00:00
Daco Harkes aa36db1d29
Native assets support for MacOS and iOS (#130494)
Support for FFI calls with `@Native external` functions through Native assets on MacOS and iOS. This enables bundling native code without any build-system boilerplate code.

For more info see:

* https://github.com/flutter/flutter/issues/129757

### Implementation details for MacOS and iOS.

Dylibs are bundled by (1) making them fat binaries if multiple architectures are targeted, (2) code signing these, and (3) copying them to the frameworks folder. These steps are done manual rather than via CocoaPods. CocoaPods would have done the same steps, but (a) needs the dylibs to be there before the `xcodebuild` invocation (we could trick it, by having a minimal dylib in the place and replace it during the build process, that works), and (b) can't deal with having no dylibs to be bundled (we'd have to bundle a dummy dylib or include some dummy C code in the build file).

The dylibs are build as a new target inside flutter assemble, as that is the moment we know what build-mode and architecture to target.

The mapping from asset id to dylib-path is passed in to every kernel compilation path. The interesting case is hot-restart where the initial kernel file is compiled by the "inner" flutter assemble, while after hot restart the "outer" flutter run compiled kernel file is pushed to the device. Both kernel files need to contain the mapping. The "inner" flutter assemble gets its mapping from the NativeAssets target which builds the native assets. The "outer" flutter run get its mapping from a dry-run invocation. Since this hot restart can be used for multiple target devices (`flutter run -d all`) it contains the mapping for all known targets.

### Example vs template

The PR includes a new template that uses the new native assets in a package and has an app importing that. Separate discussion in: https://github.com/flutter/flutter/issues/131209.

### Tests

This PR adds new tests to cover the various use cases.

* dev/devicelab/bin/tasks/native_assets_ios.dart
  * Runs an example app with native assets in all build modes, doing hot reload and hot restart in debug mode.
* dev/devicelab/bin/tasks/native_assets_ios_simulator.dart
  * Runs an example app with native assets, doing hot reload and hot restart.
* packages/flutter_tools/test/integration.shard/native_assets_test.dart
  * Runs (incl hot reload/hot restart), builds, builds frameworks for iOS, MacOS and flutter-tester.
* packages/flutter_tools/test/general.shard/build_system/targets/native_assets_test.dart
  * Unit tests the new Target in the backend.
* packages/flutter_tools/test/general.shard/ios/native_assets_test.dart
* packages/flutter_tools/test/general.shard/macos/native_assets_test.dart
  * Unit tests the native assets being packaged on a iOS/MacOS build.

It also extends various existing tests:

* dev/devicelab/bin/tasks/module_test_ios.dart
   * Exercises the add2app scenario.
* packages/flutter_tools/test/general.shard/features_test.dart
   * Unit test the new feature flag.
2023-09-10 08:07:13 +00:00
Andrew Kolos c05dc3e68e
[Reland] Fix flavors test install checks (#134060)
Reland of https://github.com/flutter/flutter/pull/133719. Updates [the string comparison in flavor_test.dart](https://github.com/flutter/flutter/pull/134060/files#diff-53383b32b975bfed6875306dfb98911cad077a5251ca0591c5b0e125fb4a0f05R39) to use `path.join` to build the path string so that the generated path is correct for both Linux and Windows hosts.

Fixes https://github.com/flutter/flutter/issues/133713

I've tested this on a Windows host targeting a physical Android device.
2023-09-05 18:55:23 +00:00
Victoria Ashworth 5649161bd7
Revert "fix install checks in flavors devicelab tests" (#133894)
Reverts flutter/flutter#133719

`Windows_android flavors_test_win` failed twice in a row in the tree
2023-09-01 22:17:48 +00:00