Skip to content

Conversation

@andrewkolos
Copy link
Contributor

@andrewkolos andrewkolos commented Apr 5, 2024

From #143348 (comment):

before we ship, we should add a printTrace to the tool about each asset transformer we're invoking and the path/arguments we called it with

I think this is a good idea since asset transformers can be arbitrary Dart programs—meaning that a lot can go wrong when running them. For example, they can hang indefinitely or perform some sort of I/O that later results in a tool crash. Knowing that asset transformation was involved when debugging a crash (or a slow/stuck flutter build) could be useful, so I think adding a printTrace or two is a good idea (or at least not a bad one).

Pre-launch Checklist

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

@andrewkolos andrewkolos added the tool Affects the "flutter" command-line tool. See also t: labels. label Apr 5, 2024
@andrewkolos
Copy link
Contributor Author

Example of what this looks like (excerpt from running flutter run -vv -d macos using https://github.com/andrewkolos/asset_transformers_test):

[        ] [   +3 ms] /Users/andrewkolos/Documents/GitHub/flutter/bin/cache/dart-sdk/bin/dartaotruntime --disable-dart-dev /Users/andrewkolos/Documents/GitHub/flutter/bin/cache/dart-sdk/bin/snapshots/frontend_server_aot.dart.snapshot --sdk-root /Users/andrewkolos/Documents/GitHub/flutter/bin/cache/artifacts/engine/common/flutter_patched_sdk/ --target=flutter --no-print-incremental-dependencies -DFLUTTER_WEB_CANVASKIT_URL=https://www.gstatic.com/flutter-canvaskit/6974dbac35a175a337ec2a56045b00dc55d3e261/ -Ddart.vm.profile=false -Ddart.vm.product=false --enable-asserts --track-widget-creation --packages /Users/andrewkolos/Desktop/asset_transformers_test/.dart_tool/package_config.json --output-dill /Users/andrewkolos/Desktop/asset_transformers_test/.dart_tool/flutter_build/b69fff6f08b8bfabd439391362a2e8e7/app.dill --depfile /Users/andrewkolos/Desktop/asset_transformers_test/.dart_tool/flutter_build/b69fff6f08b8bfabd439391362a2e8e7/kernel_snapshot.d --incremental --initialize-from-dill /Users/andrewkolos/Desktop/asset_transformers_test/.dart_tool/flutter_build/b69fff6f08b8bfabd439391362a2e8e7/app.dill --native-assets /Users/andrewkolos/Desktop/asset_transformers_test/.dart_tool/flutter_build/b69fff6f08b8bfabd439391362a2e8e7/native_assets.yaml --verbosity=error package:asset_transformers_test/main.dart
[        ] [+3443 ms] kernel_snapshot: Complete
[        ] [ +471 ms] debug_macos_bundle_flutter_assets: Starting due to {}
[        ] [  +94 ms] shaderc command: [/Users/andrewkolos/Documents/GitHub/flutter/bin/cache/artifacts/engine/darwin-x64/impellerc, --sksl, --runtime-stage-metal, --iplr, --sl=/Users/andrewkolos/Desktop/asset_transformers_test/build/macos/Build/Products/Debug/App.framework/Versions/A/Resources/flutter_assets/shaders/ink_sparkle.frag, --spirv=/Users/andrewkolos/Desktop/asset_transformers_test/build/macos/Build/Products/Debug/App.framework/Versions/A/Resources/flutter_assets/shaders/ink_sparkle.frag.spirv, --input=/Users/andrewkolos/Documents/GitHub/flutter/packages/flutter/lib/src/material/shaders/ink_sparkle.frag, --input-type=frag, --include=/Users/andrewkolos/Documents/GitHub/flutter/packages/flutter/lib/src/material/shaders, --include=/Users/andrewkolos/Documents/GitHub/flutter/bin/cache/artifacts/engine/darwin-x64/shader_lib]
[        ] [  +18 ms] Transforming asset file at path '/Users/andrewkolos/Desktop/asset_transformers_test/assets/svg.svg'...
[        ] [        ] Transforming asset using command '/Users/andrewkolos/Documents/GitHub/flutter/bin/cache/dart-sdk/bin/dart run vector_graphics_compiler --input=/var/folders/qh/m_ckdxls0xvfc7ccjj13yjjw010s5h/T/flutter_tools.SdyGAv/svg.svg-transformOutput0.svg --output=/var/folders/qh/m_ckdxls0xvfc7ccjj13yjjw010s5h/T/flutter_tools.SdyGAv/svg.svg-transformOutput1.svg'
[        ] [        ] Transforming asset file at path '/Users/andrewkolos/Desktop/asset_transformers_test/assets/sparrow.jpeg'...
[        ] [        ] Transforming asset using command '/Users/andrewkolos/Documents/GitHub/flutter/bin/cache/dart-sdk/bin/dart run blur_transformer --input=/var/folders/qh/m_ckdxls0xvfc7ccjj13yjjw010s5h/T/flutter_tools.SdyGAv/sparrow.jpeg-transformOutput0.jpeg --output=/var/folders/qh/m_ckdxls0xvfc7ccjj13yjjw010s5h/T/flutter_tools.SdyGAv/sparrow.jpeg-transformOutput1.jpeg'
[        ] [        ] Transforming asset file at path '/Users/andrewkolos/Desktop/asset_transformers_test/dependency_with_assets/asset-from-dependency-pubspec.png'...
[        ] [        ] Transforming asset using command '/Users/andrewkolos/Documents/GitHub/flutter/bin/cache/dart-sdk/bin/dart run blur_transformer --input=/var/folders/qh/m_ckdxls0xvfc7ccjj13yjjw010s5h/T/flutter_tools.SdyGAv/asset-from-dependency-pubspec.png-transformOutput0.png --output=/var/folders/qh/m_ckdxls0xvfc7ccjj13yjjw010s5h/T/flutter_tools.SdyGAv/asset-from-dependency-pubspec.png-transformOutput1.png'
[        ] [+15683 ms] Finished transforming asset at path '/Users/andrewkolos/Desktop/asset_transformers_test/assets/svg.svg' (15685ms)
[+1341 ms] [  +16 ms] Finished transforming asset at path '/Users/andrewkolos/Desktop/asset_transformers_test/dependency_with_assets/asset-from-dependency-pubspec.png' (15700ms)
[        ] [ +684 ms] Finished transforming asset at path '/Users/andrewkolos/Desktop/asset_transformers_test/assets/sparrow.jpeg' (16385ms)
[        ] [  +44 ms] debug_macos_bundle_flutter_assets: Complete
[        ] [ +589 ms] Persisting file store
[        ] [   +4 ms] Done persisting file store
[        ] [   +4 ms] build succeeded.
[        ] [   +9 ms] "flutter assemble" took 22,350ms.

@andrewkolos andrewkolos changed the title print a trace when beginning transformation of an asset print traces when transforming an asset Apr 6, 2024
@andrewkolos andrewkolos marked this pull request as ready for review April 6, 2024 00:30
} finally {
ErrorHandlingFileSystem.deleteIfExists(tempInputFile);
ErrorHandlingFileSystem.deleteIfExists(tempOutputFile);
logger.printTrace("Finished transforming asset at path '${asset.path}' (${stopwatch.elapsedMilliseconds}ms)");
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we move this line to right before the finally?

Copy link
Contributor

@christopherfujino christopherfujino left a comment

Choose a reason for hiding this comment

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

LGTM

@christopherfujino
Copy link
Contributor

@andrewkolos what's the status on this PR?

@andrewkolos andrewkolos added the autosubmit Merge PR when tree becomes green via auto submit App label Apr 22, 2024
@auto-submit auto-submit bot merged commit 4c46030 into flutter:master Apr 22, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Apr 22, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Apr 22, 2024
auto-submit bot pushed a commit to flutter/packages that referenced this pull request Apr 22, 2024
flutter/flutter@1a905d5...140edb9

2024-04-22 [email protected] Fixed few typos (flutter/flutter#147087)
2024-04-22 [email protected] Add Amir Panahandeh to AUTHORS (flutter/flutter#147052)
2024-04-22 [email protected] print traces when transforming an asset (flutter/flutter#146374)
2024-04-22 [email protected] Roll Packages from 88a3a56 to 01a32c4 (5 revisions) (flutter/flutter#147164)
2024-04-22 [email protected] Reland "Expose build mode in environment of asset transformer processes" (flutter/flutter#144958)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages
Please CC [email protected],[email protected],[email protected] on the revert to ensure that a human
is aware of the problem.

To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
gilnobrega pushed a commit to gilnobrega/flutter that referenced this pull request Apr 22, 2024
From flutter#143348 (comment):

> before we ship, we should add a printTrace to the tool about each asset transformer we're invoking and the path/arguments we called it with

I think this is a good idea since asset transformers can be arbitrary Dart programs�meaning that a lot can go wrong when running them. For example, they can hang indefinitely or perform some sort of I/O that later results in a tool crash. Knowing that asset transformation was involved when debugging a crash (or a slow/stuck `flutter build`) could be useful, so I think adding a `printTrace` or two is a good idea (or at least not a bad one).
@andrewkolos andrewkolos deleted the add-print-trace-for-asset-transformation branch April 29, 2024 18:17
TecHaxter pushed a commit to TecHaxter/flutter_packages that referenced this pull request May 22, 2024
flutter/flutter@1a905d5...140edb9

2024-04-22 [email protected] Fixed few typos (flutter/flutter#147087)
2024-04-22 [email protected] Add Amir Panahandeh to AUTHORS (flutter/flutter#147052)
2024-04-22 [email protected] print traces when transforming an asset (flutter/flutter#146374)
2024-04-22 [email protected] Roll Packages from 88a3a56 to 01a32c4 (5 revisions) (flutter/flutter#147164)
2024-04-22 [email protected] Reland "Expose build mode in environment of asset transformer processes" (flutter/flutter#144958)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages
Please CC [email protected],[email protected],[email protected] on the revert to ensure that a human
is aware of the problem.

To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

autosubmit Merge PR when tree becomes green via auto submit App tool Affects the "flutter" command-line tool. See also t: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants