Skip to content

[iOS] fix hot restart with native assets - #148752

Merged
knopp merged 10 commits into
flutter:masterfrom
knopp:native_asset_integration_test_simulator
May 23, 2024
Merged

knopp merged 10 commits into
flutter:masterfrom
knopp:native_asset_integration_test_simulator

Conversation

@knopp

@knopp knopp commented May 21, 2024 •

Copy link
Copy Markdown
Member

Fixes #148687

Adds support for running the hot restart and reload integration test on iOS simulator.

Pre-launch Checklist

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

@github-actions github-actions Bot added the tool Affects the "flutter" command-line tool. See also t: labels. label May 21, 2024
@knopp
knopp force-pushed the native_asset_integration_test_simulator branch 2 times, most recently from 93cd0b9 to 297c0eb Compare May 21, 2024 09:53
@knopp knopp changed the title Run native assets integration tests on iOS simulator [iOS] fix hot reload with native assets May 21, 2024
@knopp knopp changed the title [iOS] fix hot reload with native assets [iOS] fix hot restart with native assets May 21, 2024
@knopp

knopp commented May 21, 2024

Copy link
Copy Markdown
Member Author

@dcharkes, I think this should work, but the tree is currently broken and the integration tests are currently failing for unrelated reason.

@knopp
knopp force-pushed the native_asset_integration_test_simulator branch from 29571ba to 8cef4c2 Compare May 21, 2024 16:21
@knopp

knopp commented May 21, 2024

Copy link
Copy Markdown
Member Author

@dcharkes, it seems that the hot reload test (with the fix) passes successfully on simulator on CI:

21:26 +72 ~1: test/integration.shard/isolated/native_assets_test.dart: flutter run hot reload and hot restart with native assets 873FC224-4044-471E-9CFA-9739B82F3105 debug

@knopp
knopp requested a review from dcharkes May 21, 2024 17:08
@knopp
knopp force-pushed the native_asset_integration_test_simulator branch from 8cef4c2 to 6552cec Compare May 22, 2024 11:24

@dcharkes dcharkes left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great!

Before merging, could you check the existing device lab test? That already spin up a simulator.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have all this logic already in the device lab tests.

https://github.com/flutter/flutter/blob/e6fa8655819e9b92740911b49e8215efc6e52dab/dev/devicelab/bin/tasks/native_assets_ios_simulator.dart

$ cd <...>/flutter/dev/devicelab && dart bin/test_runner.dart test -t native_assets_ios_simulator

Would you be able to check why the existing hot integration test was not failing on the ios simulator?

(I don't feel strongly opposed to adding the logic also here, but since we already have it in the device lab tests it feels a bit like unnecessary code duplication.)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the problem is that when hot restart happens this is in the logs

Performing hot restart...
Restarted application in 325ms.

══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
The following ArgumentError was thrown building _FocusInheritedScope:

The test only checks for Restarted application, which is there, so it assumes it passed, the exception is printed after. I think this is handled bit differently in the integration tests that's why those catch the issue.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is present in the integration test

expect(stdout, isNot(contains('EXCEPTION CAUGHT BY WIDGETS LIBRARY')));

Probably should be added to device lab tool

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But even if I detect the exception and return TaskResult.failure the task still exits with success for some reason.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dcharkes, this should fix the device lab test: eb6b04c

Should I remove the simulator from integration tests?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wouldn't mind having it there, it's easier to run locally than the devicelab test.

However, I believe we shouldn't be using infinite resources on CI. And the test coverage should be similar between the integration test with the simulator and the devicelab test with the simulator.

cc @jmagman @vashworth What's our policy on how much testing resources we use? And what's the policy on where simulator tests should run? (Integration suite vs device lab. I'm added the simulator to the device lab based on existing device lab tests that run the simulator.)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for diving into this @knopp! ❤️

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The 4/4 shard already takes long time to complete (in fact it did timeout in previous run and I had to restart it). I think maybe it's a good idea to remove it.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah that test runs long already. We don't want to introduce flakes due to timeouts. Let's remove it from this PR.

That means that this PR will just be a test fix and a fix 👍

@knopp
knopp force-pushed the native_asset_integration_test_simulator branch 2 times, most recently from 343cf29 to eb6b04c Compare May 23, 2024 08:32

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please also fix dev/devicelab/bin/tasks/native_assets_ios.dart

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That one seems fine? I looked at it and it seems to propagate the result of createNativeAssetsTest correctly.

@dcharkes dcharkes left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with simulator removed again from integration test.

@knopp

knopp commented May 23, 2024

Copy link
Copy Markdown
Member Author

@dcharkes flutter run hot reload and hot restart with native assets macos debug failed:

34:35 +84 ~1 -2: test/integration.shard/isolated/native_assets_test.dart: flutter run hot reload and hot restart with native assets macos debug [E]
  Expected: not contains 'Invalid argument(s): Couldn\'t resolve native function \'sum\''
    Actual: 'warning: Run script build phase \'Run Script\' will be run during every build because it does not specify any outputs. To address this warning, either add output dependencies to the script phase, or configure it to run in every build by unchecking "Based on dependency analysis" in the script phase. (in target \'Flutter Assemble\' from project \'Runner\')\n'
              'Performing hot reload...                                        \n'
              'The Flutter DevTools debugger and profiler on macOS is available at: http://127.0.0.1:9106?uri=http://127.0.0.1:53308/xYohxuqAUcQ=/\n'
              'Reloaded 0 libraries in 520ms (compile: 8 ms, reload: 0 ms, reassemble: 492 ms).\n'
              '\n'
              'Performing hot restart...                                       \n'
              'Restarted application in 5,343ms.\n'
              '\n'
              'Performing hot reload...                                        \n'
              '\n'
              '══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════\n'
              'The following ArgumentError was thrown building _FocusInheritedScope:\n'
              'Invalid argument(s): Couldn\'t resolve native function \'sum\' in\n'
              '\'package:package_with_native_assets/package_with_native_assets_bindings_generated.dart\' : Failed to\n'
              'load dynamic library \'package_with_native_assets1.framework/package_with_native_assets1\': Failed to\n'
              'load dynamic library \'package_with_native_assets1.framework/package_with_native_assets1\':\n'
              'dlopen(package_with_native_assets1.framework/package_with_native_assets1, 0x0001): tried:\n'
              '\'package_with_native_assets1.framework/package_with_native_assets1\' (no such file),\n'
              '\'/System/Volumes/Preboot/Cryptexes/OSpackage_with_native_assets1.framework/package_with_native_assets1\'\n'
              '(no such file),\n'
              

I don't think it is related to this PR. I'm going to restart the test to see if it passes, but I think it might be flaky?

@knopp
knopp force-pushed the native_asset_integration_test_simulator branch from edf78f0 to 8eca905 Compare May 23, 2024 14:29
@knopp
knopp merged commit 02d5286 into flutter:master May 23, 2024
@knopp
knopp deleted the native_asset_integration_test_simulator branch May 23, 2024 16:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

tool Affects the "flutter" command-line tool. See also t: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[iOS] Hot restart fails with native assets

2 participants