mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00
![]() The link hooks (`hook/link.dart`) in Flutter have no access to the resource identifier experiment for tree-shaking yet. That means we can start running hooks earlier in the flutter build. When we do get around to adding tree-shaking information, we should only have a dependency on `KernelSnapshot` for AOT builds in which the Dart tree-shaker runs. Likely achieved by splitting the `DartBuildForNative` into two targets, one for Debug and one for Release. (Note, the names for these targets are somewhat weird, so we should address that in another PR as well. It should probably be called `RunDartHooks` or something.) I don't expect this PR to have any performance effect for fast hooks. Other targets already run concurrently with this target: ``` $ flutter build -d macos --verbose [ ] [ +278 ms] compile_macos_framework: Starting due to {InvalidatedReasonKind.inputChanged: The following inputs have updated contents: /Users/dacoharkes/flt/flutter/examples/hello_world/.dart_tool/flutter_build/ce2ba8b9e7204bce6beba11f20d6df36/app.dill,/Users/dacoharkes/flt/flutter/packages/flutter_tools/lib/src/build_system/targets/macos.dart,/Users/dacoharkes/flt/flutter/bin/cache/engine.stamp} [...] [ ] [ ] dart_build: Starting due to {} [ ] [ +20 ms] No packages with native assets. Skipping native assets compilation. [ ] [ +1 ms] dart_build: Complete [ ] [ +1 ms] install_code_assets: Starting due to {} [ ] [ +1 ms] Writing native assets json to file:///Users/dacoharkes/flt/flutter/examples/hello_world/.dart_tool/flutter_build/ce2ba8b9e7204bce6beba11f20d6df36/native_assets.json. [ ] [ +1 ms] Writing /Users/dacoharkes/flt/flutter/examples/hello_world/.dart_tool/flutter_build/ce2ba8b9e7204bce6beba11f20d6df36/native_assets.json done. [ ] [ ] install_code_assets: Complete [ ] [+1376 ms] Building App.framework for x86_64... [...] [ ] [ +41 ms] compile_macos_framework: Complete ``` However, this PR makes the hooks already run concurrently with kernel compilation, which always takes quite a while. ``` [ ] [ +2 ms] kernel_snapshot_program: Starting due to {} [...] [ ] [+2515 ms] release_unpack_macos: Complete [ ] [+2425 ms] kernel_snapshot_program: Complete ``` This means that if the hooks do actual work, and enough cores on the host are available for Dart compilation and hook execution, the result will be quicker than before. ### Context * https://github.com/dart-lang/native/issues/2236 ### Testing Existing native assets integration tests ### Benchmarks Currently _not_ benchmarked. This will be benchmarked by the `flutter build` and flutter-time-to-first-frame benchmarks once the experiment flag is removed. |
||
---|---|---|
.. | ||
flutter | ||
flutter_driver | ||
flutter_goldens | ||
flutter_localizations | ||
flutter_test | ||
flutter_tools | ||
flutter_web_plugins | ||
fuchsia_remote_debug_protocol | ||
integration_test | ||
analysis_options.yaml |