Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test based on android manifest #1

Conversation

christopherfujino
Copy link

No description provided.

@andrewkolos andrewkolos merged this pull request into andrewkolos:flavor-specific-assets Nov 20, 2023
1 check passed
@christopherfujino christopherfujino deleted the pr-for-andrew-132985 branch November 20, 2023 23:41
andrewkolos added a commit that referenced this pull request Dec 7, 2023
* remove trace and fix test

* update to use AssetManifest.bin; mirror change in flavors_test_ios

---------

Co-authored-by: Andrew Kolos <[email protected]>
andrewkolos added a commit that referenced this pull request Dec 8, 2023
oops

enable for `flutter daemon` and `flutter run --machine`

nit

working (ugly) flavor-collision-handling logic

nits

add commented out tests

refactor main test a little

update tests and add support for deferred components assets

remove extra log statements

add a test for assetsentry parsing

get build_info.dart changes under test

fix asset bundle test for windows

make asset bundle tests work on Windows

typos

remove feature for web

typo

fix some tests

fix xcode_backend_test

remove feature for web

fix a test

fix oopsie

fix test

try fix xcode backend test

restore in-order sequencing of install tests

augment flavors integration tests with flavor-specific assets checks

add support to HotRunner (untested)

more diff cleanup

remove support for flavors for platforms that we haven't documented flavors support for

enable for web

add tests to asset bundle tests

add tests for CopyAssets target and fix logic for unflavored builds

clean up print statements

simplify pubspec syntax

implement group pubspec syntax (very hacky)

group parsing actually works (image displays at runtime)

xcode sends flavor, we use flavor in asset bundling (hacky)

gradle-sends-flavor-to-flutter-assembler

run update-packages

fix test: clean up after flavors test

fixing rebasing oopsies

rebasing because frob asked me to

add tech debt note about redundant parsing

make flavor matching behavior more explicit

remove unused flavor parameter

nits

nit

test based on android manifest (#1)

* remove trace and fix test

* update to use AssetManifest.bin; mirror change in flavors_test_ios

---------

oops again

oops

remove redundant flavor arg from HotRunner

nits

change `flavor` to `flavors` to allow multiple flavors per asset

consider flavor in AssetsEntry.hashCode

fix some tests

fix flavors for deferred components

disallow overlapping entries of different flavors

allow empty flavor when passing to xcode

This shouldn't really matter because the app won't shouldn't build with any empty flavor.

if flavor is null or empty, do not pass it to xcode via -d

remove redundant --flavor option in assemble command

make AssetsEntry parsing functions pure

revert unnecessary extraction of expression into local variable

remove duplicate Xcode define

cleanup

Co-Authored-By: Christopher Fujino <[email protected]>
Co-Authored-By: Andrew Kolos <[email protected]>
andrewkolos pushed a commit that referenced this pull request Mar 22, 2024
A test was failing silently because of this (see
flutter#144353 and fixed in
flutter#144709). The failure went
undetected for months. Ideally, this should have been a regular
non-silent failure. This change makes that so. `package:test` can
properly handle reported exceptions outside of test cases. With this
change, the test fails as follows:

```
00:03 +82: Smoke test material/color_scheme/dynamic_content_color.0.dart
══╡ EXCEPTION CAUGHT BY FLUTTER TEST FRAMEWORK ╞════════════════════════════════════════════════════
The following assertion was thrown running a test (but after the test had completed):
setState() called after dispose(): _DynamicColorExampleState#1cd37(lifecycle state: defunct, not
mounted)
This error happens if you call setState() on a State object for a widget that no longer appears in
the widget tree (e.g., whose parent widget no longer includes the widget in its build). This error
can occur when code calls setState() from a timer or an animation callback.
The preferred solution is to cancel the timer or stop listening to the animation in the dispose()
callback. Another solution is to check the "mounted" property of this object before calling
setState() to ensure the object is still in the tree.
This error might indicate a memory leak if setState() is being called because another object is
retaining a reference to this State object after it has been removed from the tree. To avoid memory
leaks, consider breaking the reference to this object during dispose().

When the exception was thrown, this was the stack:
#0      State.setState.<anonymous closure> (package:flutter/src/widgets/framework.dart:1167:9)
#1      State.setState (package:flutter/src/widgets/framework.dart:1202:6)
flutter#2      _DynamicColorExampleState._updateImage (package:flutter_api_samples/material/color_scheme/dynamic_content_color.0.dart:191:5)
<asynchronous suspension>
════════════════════════════════════════════════════════════════════════════════════════════════════
00:03 +81 -1: Smoke test material/context_menu/context_menu_controller.0.dart
00:03 +81 -1: Smoke test material/color_scheme/dynamic_content_color.0.dart [E]
  Test failed. See exception logs above.
  The test description was: Smoke test material/color_scheme/dynamic_content_color.0.dart
  
  This test failed after it had already completed.
  Make sure to use a matching library which informs the test runner
  of pending async work.
```
andrewkolos pushed a commit that referenced this pull request Mar 22, 2024
…r#144706)" (flutter#144970)

Reverts: flutter#144706
Initiated by: gspencergoog
Reason for reverting: This has broken the tree because some tests are still failing post completion. This particular one looks like it might have to do with a gold image not existing.
Original PR Author: goderbauer

Reviewed By: {Piinks}

This change reverts the following previous change:
A test was failing silently because of this (see flutter#144353 and fixed in flutter#144709). The failure went undetected for months. Ideally, this should have been a regular non-silent failure. This change makes that so. `package:test` can properly handle reported exceptions outside of test cases. With this change, the test fails as follows:

```
00:03 +82: Smoke test material/color_scheme/dynamic_content_color.0.dart
══╡ EXCEPTION CAUGHT BY FLUTTER TEST FRAMEWORK ╞════════════════════════════════════════════════════
The following assertion was thrown running a test (but after the test had completed):
setState() called after dispose(): _DynamicColorExampleState#1cd37(lifecycle state: defunct, not
mounted)
This error happens if you call setState() on a State object for a widget that no longer appears in
the widget tree (e.g., whose parent widget no longer includes the widget in its build). This error
can occur when code calls setState() from a timer or an animation callback.
The preferred solution is to cancel the timer or stop listening to the animation in the dispose()
callback. Another solution is to check the "mounted" property of this object before calling
setState() to ensure the object is still in the tree.
This error might indicate a memory leak if setState() is being called because another object is
retaining a reference to this State object after it has been removed from the tree. To avoid memory
leaks, consider breaking the reference to this object during dispose().

When the exception was thrown, this was the stack:
#0      State.setState.<anonymous closure> (package:flutter/src/widgets/framework.dart:1167:9)
#1      State.setState (package:flutter/src/widgets/framework.dart:1202:6)
flutter#2      _DynamicColorExampleState._updateImage (package:flutter_api_samples/material/color_scheme/dynamic_content_color.0.dart:191:5)
<asynchronous suspension>
════════════════════════════════════════════════════════════════════════════════════════════════════
00:03 +81 -1: Smoke test material/context_menu/context_menu_controller.0.dart
00:03 +81 -1: Smoke test material/color_scheme/dynamic_content_color.0.dart [E]
  Test failed. See exception logs above.
  The test description was: Smoke test material/color_scheme/dynamic_content_color.0.dart
  
  This test failed after it had already completed.
  Make sure to use a matching library which informs the test runner
  of pending async work.
```
andrewkolos pushed a commit that referenced this pull request Jun 29, 2024
New analyze error in an unrelated PR 
```
╔═╡ERROR #1╞════════════════════════════════════════════════════════════════════
║ /b/s/w/ir/x/w/flutter/CODEOWNERS:13: trailing U+0020 space character
╚═══════════════════════════════════════════════════════════════════════════════
```

https://logs.chromium.org/logs/flutter/buildbucket/cr-buildbucket/8744032390138579057/+/u/run_test.dart_for_analyze_shard_and_subshard_None/stdout

On this commit 

flutter@2537b49
andrewkolos pushed a commit that referenced this pull request Aug 20, 2024
When attempting to release the Flutter 3.24.1 hotfix, Flutter framework post submits failed due to the following error:

```
���ERROR #1���������������������������������������������������������������������
� UNEXPECTED ERROR!
� Exception: Found unexpected binary in cache: /Volumes/Work/s/w/ir/x/w/flutter/bin/cache/artifacts/engine/ios-release/extension_safe/Flutter.xcframework/ios-arm64_x86_64-simulator/dSYMs/Flutter.framework.dSYM/Contents/Resources/DWARF/Flutter
� #0      verifyExist (file:///Volumes/Work/s/w/ir/x/w/flutter/dev/bots/suite_runners/run_verify_binaries_codesigned_tests.dart:150:12)
� <asynchronous suspension>
� #1      verifyCodesignedTestRunner (file:///Volumes/Work/s/w/ir/x/w/flutter/dev/bots/suite_runners/run_verify_binaries_codesigned_tests.dart:28:3)
� <asynchronous suspension>
� flutter#2      _runFromList (file:///Volumes/Work/s/w/ir/x/w/flutter/dev/bots/utils.dart:601:5)
� <asynchronous suspension>
� flutter#3      main (file:///Volumes/Work/s/w/ir/x/w/flutter/dev/bots/test.dart:125:5)
� <asynchronous suspension>
� 
� The test.dart script should be corrected to catch this error and call foundError().
� Some tests are likely to have been skipped.
��������������������������������������������������������������������������������
```

I've updated the tests to include the listed artifact.  

### Open questions
1. Is it possible that the test failed only on the first binary?
2. Do we expect a need to add the remainder of the [entitlement changes](flutter/engine@c9b9d57)?
3. I am under the assumption that the bots pull from master and are not branch specific, is this a correct assumption?

CC @christopherfujino @cbracken
andrewkolos pushed a commit that referenced this pull request Sep 9, 2024
…lutter#154715)

Fixes: flutter#154580
Previous PR: flutter#154677
More info: flutter#154580 (comment)

The errors described in the original issue [are still occurring](flutter#154580 (comment)) after flutter#154677. Before this change, the repro [broken_demo](https://github.com/rajveermalviya/broken_demo) mentioned in the original issue logs:

```shell-session
$ flutter run --release
Launching lib/main.dart on sdk gphone64 arm64 in release mode...
Running Gradle task 'assembleRelease'...                           14.5s
� Built build/app/outputs/flutter-apk/app-release.apk (7.4MB)
Installing build/app/outputs/flutter-apk/app-release.apk...        739ms

Flutter run key commands.
h List all available interactive commands.
c Clear the screen
q Quit (terminate the application on the device).
W/FlutterEngineCxnRegstry(13284): Attempted to register plugin (a0.a@53b33b6) but it was already registered with this FlutterEngine (d0.c@8baa8b7).
E/flutter (13284): [ERROR:flutter/runtime/dart_vm_initializer.cc(40)] Unhandled Exception: PlatformException(channel-error, Unable to establish connection on channel., null, null)
E/flutter (13284): #0      PathProviderApi.getApplicationSupportPath (package:path_provider_android/messages.g.dart:65)
E/flutter (13284): <asynchronous suspension>
E/flutter (13284): #1      getApplicationSupportDirectory (package:path_provider/path_provider.dart:78)
E/flutter (13284): <asynchronous suspension>
E/flutter (13284): flutter#2      _BorkenDemoHomePageState.build.<anonymous closure> (package:broken_demo/main.dart:44)
E/flutter (13284): <asynchronous suspension>
E/flutter (13284): 
```

After this change:
```shell-session
$ flutter run --release
Launching lib/main.dart on sdk gphone64 arm64 in release mode...
Running Gradle task 'assembleRelease'...                           15.2s
� Built build/app/outputs/flutter-apk/app-release.apk (7.4MB)
Installing build/app/outputs/flutter-apk/app-release.apk...        857ms

Flutter run key commands.
h List all available interactive commands.
c Clear the screen
q Quit (terminate the application on the device).
I/flutter (13040): path_provider: Directory: '/data/user/0/com.example.broken_demo/files'
```
andrewkolos pushed a commit that referenced this pull request Sep 26, 2024
flutter#154645)

### Problem

Enabling the Swift Package Manager feature caused post-submit tests to fail on Mac x64 hosts:

<details>
<summary>Example error...</summary>

https://ci.chromium.org/ui/p/flutter/builders/prod/Mac_ios%20rrect_blur_perf_ios__timeline_summary/575/overview

```
� ... flutter --verbose assemble ... -dIosArchs=x86_64 ... profile_unpack_ios

Target profile_unpack_ios failed:
Exception: Binary ... build/ios/Profile-iphoneos/Flutter.framework/Flutter does not contain x86_64.

Running lipo -info:
Non-fat file: ... build/ios/Profile-iphoneos/Flutter.framework/Flutter is architecture: arm64

#0      UnpackIOS._thinFramework (package:flutter_tools/src/build_system/targets/ios.dart:351:7)
<asynchronous suspension>
#1      UnpackIOS.build (package:flutter_tools/src/build_system/targets/ios.dart:298:5)
<asynchronous suspension>
...
```

</details>

### Reproduction

On a mac x64 host:

1. Switch to the latest master channel: `flutter channel master ; flutter upgrade`
1. Disable the Swift Package Manager feature: `flutter config --no-enable-swift-package-manager`
2. Create a Flutter project
2. [Edit the Xcode project manually to add the prepare pre-action](https://docs.flutter.dev/packages-and-plugins/swift-package-manager/for-app-developers#step-2-add-run-prepare-flutter-framework-script-pre-action)
3. Run `flutter run` (`flutter build ios` does not reproduce this issue).

### Background

Previously, the Flutter framework was unpacked in the Xcode target's build. Unfortunately, this happens after Swift packages are built; this prevented Swift packages from using the Flutter framework.

To fix this, we added an Xcode pre-action that unpacks the Flutter framework _before_ Swift Package Manager builds packages. The Xcode target still runs the Flutter framework unpack step, but this step no-ops if the unpack step has the exact same inputs. 

```mermaid
flowchart LR
  A[flutter run -d iphone] --> B(Build Xcode project)
  B --> C(Xcode 'prepare framework' pre-action)
  B --> G[Build Swift packages]
  B --> D(Build 'Runner' target)
  C --> E[Unpack Flutter framework #1]
  D --> F["
  Unpack Flutter framework flutter#2
  (No-ops if inputs are same as #1)
  "]
```

flutter#150052 added an optimization that made it more likely the second unpack step no-ops by fixing a case where the target architecture input could be different:

> When using SwiftPM, we use `flutter assemble` in an Xcode Pre-action to run the `debug_unpack_macos` (or profile/release) target. This target is also later used in a Run Script build phase. Depending on `ARCHS` build setting, the Flutter/FlutterMacOS binary is thinned. In the Run Script build phase, `ARCHS` is filtered to the active arch. However, in the Pre-action it doesn't always filter to the active arch. As a workaround, assume arm64 if the [`NATIVE_ARCH`](https://developer.apple.com/documentation/xcode/build-settings-reference/#NATIVEARCH) is arm, otherwise assume x86_64.

This optimization is only applied if [`ONLY_ACTIVE_ARCH`](https://developer.apple.com/library/archive/documentation/DeveloperTools/Reference/XcodeBuildSettingRef/1-Build_Setting_Reference/build_setting_ref.html#//apple_ref/doc/uid/TP40003931-CH3-SW157) is `YES`.

> [!IMPORTANT]
> [`ONLY_ACTIVE_ARCH`](https://developer.apple.com/library/archive/documentation/DeveloperTools/Reference/XcodeBuildSettingRef/1-Build_Setting_Reference/build_setting_ref.html#//apple_ref/doc/uid/TP40003931-CH3-SW157)'s name is misleading. It specifies whether the product includes only object code for the native architecture.
>
> A value of `YES` means the product includes only code for the native architecture ([NATIVE_ARCH](https://developer.apple.com/library/archive/documentation/DeveloperTools/Reference/XcodeBuildSettingRef/1-Build_Setting_Reference/build_setting_ref.html#//apple_ref/doc/uid/TP40003931-CH3-SW59)).
>
> A value of `NO` means the product includes code for the architectures specified in [ARCHS (Architectures)](https://developer.apple.com/library/archive/documentation/DeveloperTools/Reference/XcodeBuildSettingRef/1-Build_Setting_Reference/build_setting_ref.html#//apple_ref/doc/uid/TP40003931-CH3-SW62).

### Problem

`buildXcodeProject` incorrectly always sets `ONLY_ACTIVE_ARCH` to `YES` if the Xcode built is for a single architecture:

https://github.com/flutter/flutter/blob/6abef222514e8039bde5c47ab7864abbc4caf7e8/packages/flutter_tools/lib/src/ios/mac.dart#L353-L361

This is incorrect! If the host architecture is `x64` but the target architecture is `arm64`, [`ONLY_ACTIVE_ARCH`](https://developer.apple.com/library/archive/documentation/DeveloperTools/Reference/XcodeBuildSettingRef/1-Build_Setting_Reference/build_setting_ref.html#//apple_ref/doc/uid/TP40003931-CH3-SW157) should be `NO`.

This caused the prepare pre-action to incorrectly use x64 as the target architecture for arm64 devices on an x64 host, which in turn caused builds to fail if Swift Package Manager was enabled.

### Solution

This change updates `buildXcodeProject` to set `ONLY_ACTIVE_ARCH` correctly.

This change also updates the prepare pre-action's to be more conservative in applying the optimization that filters the target architecture. This ensures that the build still works (but without the optimization) if `ONLY_ACTIVE_ARCH` is incorrectly set.

Follow-up PR: flutter#154649

This unblocks: flutter#151567

### DeviceLab test

This problem reproduces if you `flutter run` to an iPhone Arm64 device from an x64 mac host with the Swift Package Manager feature enabled.

I ran an affected DeviceLab test to verify the fix works as expected:

Description | CI test | Result
-- | -- | --
SwiftPM enabled without this fix: flutter#154750 | [Link](https://ci.chromium.org/ui/p/flutter/builders/try.shadow/Mac_ios%20rrect_blur_perf_ios__timeline_summary/7/overview) | � 
SwiftPM enabled with this fix: flutter#154749 | [Link](https://ci.chromium.org/ui/p/flutter/builders/try.shadow/Mac_ios%20rrect_blur_perf_ios__timeline_summary/8/overview) | â�
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants