Repository navigation
[flutter_tools] Check that dartaotruntime can run before starting the frontend server - #194206
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
|
@googlebot I signed it! |
There was a problem hiding this comment.
Code Review
This pull request introduces robust error handling when starting the Dart frontend server by wrapping process startup in a helper function _startFrontendServer. This helper catches ProcessException and exits the tool with an actionable message suggesting the deletion of the 'bin/cache' directory if the SDK is missing or corrupted. Corresponding unit tests have been added to verify this behavior for both batch and incremental compilation. I have no feedback to provide.
jmagman
left a comment
There was a problem hiding this comment.
Ideally the tool would never ask the user to handle internal implementation downloads, it would just do it itself (most Flutter artifacts do via Cache.updateAll() / isUpToDate()). However this is a dart artifact which doesn't go through this flow. However that's a larger change (Maybe DartSdk extends CachedArtifact with implementations for location, stampName, updateInner, etc) .
This change looks redundant since KernelCompiler.compile already has a canRun check for dartaotruntime. I think what's missing is the same check in DefaultResidentCompiler._compile. Which still makes the user deal with whatever the problem is instead of self-healing, but it's a smaller change.
None of that explains why dartaotruntime is missing. Maybe a virus scanner quarantined it?
…nd server DefaultResidentCompiler._compile spawned the frontend server without first checking that the Dart AOT runtime (or the Dart binary, when a frontendServerStarterPath is used) exists. When dartaotruntime is missing from bin/cache, the ProcessException escaped as an unhandled tool crash. KernelCompiler.compile already guards the batch path with ProcessManager.canRun checks and a ToolExit. Add the same checks, with the same messages, to the resident compiler, and add a regression test. Fixes flutter#193518
4b28547 to
d7f8bb9
Compare
|
@jmagman Thanks for the review, you're right that KernelCompiler.compile already has the canRun check. I've dropped the helper and added the same checks (Dart binary and dartaotruntime) to DefaultResidentCompiler._compile, with the same messages, plus a regression test. Agreed that self-healing the Dart SDK artifact would be a larger change; happy to look into it separately if it's wanted. On why it goes missing: the linked reports mostly point at antivirus quarantine and interrupted downloads, I don't have a reproduction beyond that. |
bkonyi
left a comment
There was a problem hiding this comment.
Thanks for the fix! Left a couple of comments to deduplicate the startup command check with KernelCompiler.compile and cover the frontendServerStarterPath branch in tests, then this LGTM!
…compilers Address review feedback: - Extract _commandToStartFrontendServer and use it from both KernelCompiler.compile and DefaultResidentCompiler._compile. - Drop the canRun check for the Dart binary; if dart cannot run, flutter cannot run either. - Use MemoryFileSystem.test() in the new test. - Cover the frontendServerStarterPath branch for both compilers, and the missing-dartaotruntime case for the batch compiler.
|
Added tests for the frontendServerStarterPath branch in both compile_incremental_test.dart and compile_batch_test.dart, plus the missing-dartaotruntime case for the batch compiler. Should be ready for another look. |
bkonyi
left a comment
There was a problem hiding this comment.
LGTM! We'll need one more review before this can land.
|
@jmagman friendly ping when you have a moment: I addressed your comments (no SDK self-healing here, the canRun check for the Dart binary is gone, and the startup command is shared between both compilers) and bkonyi has approved. Would you mind taking another look? Thanks for your time. |
|
autosubmit label was removed for flutter/flutter/194206, because The base commit of the PR is older than 7 days and can not be merged. Please merge the latest changes from the main into this branch and resubmit the PR. |
|
auto label is removed for flutter/flutter/194206, Failed to enqueue flutter/flutter/194206 with HTTP 400: Pull request Required status check "Check Code Freeze" is expected.. |
Roll Flutter from b75c5b30406a to 06f1c24345a2 (37 revisions) flutter/flutter@b75c5b3...06f1c24 2026-11-25 [email protected] Roll Skia from a60d883b3fe3 to e84ecd98d9f2 (2 revisions) (flutter/flutter#197375) 2026-11-25 [email protected] Roll Skia from ca229e319550 to a60d883b3fe3 (4 revisions) (flutter/flutter#197371) 2026-11-25 [email protected] Roll Skia from 6f75212e5a23 to ca229e319550 (2 revisions) (flutter/flutter#197369) 2026-11-25 [email protected] Roll Skia from 75d95595f14e to 6f75212e5a23 (1 revision) (flutter/flutter#197364) 2026-11-25 [email protected] [Windows] Fix Korean 3-beolsik IME dropping space, digits and punctuation (flutter/flutter#194270) 2026-11-25 [email protected] [flutter_tools] Strip embedded credentials from repository URLs (flutter/flutter#197219) 2026-11-25 [email protected] [flutter_tools] Add structured extension.log notifications for tool extensions (flutter/flutter#196714) 2026-11-25 [email protected] [flutter_tools] Share Depfile in flutter_tools_core and make BuildTarget.targetPlatform optional (flutter/flutter#194965) 2026-11-25 [email protected] Reply null asynchronously to ignored web platform messages and unskip missing-asset tests (flutter/flutter#197267) 2026-11-25 [email protected] Roll Dart SDK from 87f515c52de9 to 5202130a51b8 (1 revision) (flutter/flutter#197363) 2026-11-25 [email protected] [web] Retain queued scene pictures via ContainerLayer render pinning (flutter/flutter#196748) 2026-11-25 [email protected] [flutter_tools] Include dependency manifests in copyAssets depfile (flutter/flutter#196596) 2026-11-25 [email protected] Print the Intel Mac deprecation warning on every command (flutter/flutter#194071) 2026-11-25 [email protected] Roll Skia from 243c0dc9f662 to 75d95595f14e (2 revisions) (flutter/flutter#197351) 2026-11-25 [email protected] iOS: Ignore platform messages after the engine is destroyed (flutter/flutter#197310) 2026-11-24 [email protected] Bump customer tests to pick up material_ui cache extent test updates (flutter/flutter#197266) 2026-11-24 [email protected] [flutter_tools] Use refreshed FlutterVersion for flutter doctor feature flags (flutter/flutter#196944) 2026-11-24 [email protected] [flutter_tools] Do not crash if buildXcodeProject temporary directory is deleted before cleanup (flutter/flutter#195918) 2026-11-24 [email protected] Fix some `parameter_assignments` warnings (flutter/flutter#196815) 2026-11-24 [email protected] [flutter_tools] Extract PlatformDebuggingOptions and move WebDebugConfig (flutter/flutter#197229) 2026-11-24 [email protected] Fix desktop apps installing to the system prefix after a failed build (flutter/flutter#196482) 2026-11-24 [email protected] [flutter_tools] Write flutter test native_assets.json outside targetDir (flutter/flutter#196300) 2026-11-24 [email protected] iOS: Check the presented composition order in platform view tests (flutter/flutter#197302) 2026-11-24 [email protected] Run the shared Vulkan embedder tests under Impeller as well as Skia (flutter/flutter#193004) 2026-11-24 [email protected] Roll Fuchsia Linux SDK from BOgXtIYxLYcCkRou2... to HtAKfFLbfAQ6g96RY... (flutter/flutter#197334) 2026-11-24 [email protected] Roll Skia from b3dec9325fe1 to 243c0dc9f662 (6 revisions) (flutter/flutter#197333) 2026-11-24 [email protected] [flutter_tools] Delete globals.dart and context_runner.dart (flutter/flutter#196095) 2026-11-24 [email protected] Update viewInsets docs for translucent and rounded system UI (flutter/flutter#196355) 2026-11-24 [email protected] [flutter_tools] Check that dartaotruntime can run before starting the frontend server (flutter/flutter#194206) 2026-11-24 [email protected] [framework] Fix DraggableScrollableSheet '_hold == null' assertion when touch lifts during snap (flutter/flutter#195771) 2026-11-24 [email protected] [web] Release ImageSource on GC and fix Picture finalizer cycles (flutter/flutter#197245) 2026-11-24 [email protected] [flutter_tools] Fix web compiler output tracking in web builds (flutter/flutter#196563) 2026-11-24 [email protected] Upgrade CI to Xcode 27.2 (flutter/flutter#196807) 2026-11-24 [email protected] Roll Packages from 5b93485 to f455dfa (6 revisions) (flutter/flutter#197316) 2026-11-24 [email protected] [Linux] Fix deadlock presenting to a Wayland subsurface (flutter/flutter#196945) 2026-11-24 [email protected] Roll Skia from 2140958ee284 to b3dec9325fe1 (1 revision) (flutter/flutter#197309) 2026-11-24 [email protected] Roll Fuchsia Test Scripts from oEU515sDqSTvD8Spx... to GPtykFNizlaauBqzs... (flutter/flutter#197313) If this roll has caused a breakage, revert this CL and set the roller to dry run mode using the controls here: https://autoroll.skia.org/r/flutter-packages Please CC [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 ...
DefaultResidentCompiler._compilespawns the frontend server (dartaotruntime+frontend_server_aot.dart.snapshot) directly. Whendartaotruntimeis missing frombin/cache(partially downloaded or corrupted SDK, cache cleaned while a resident session is running, antivirus quarantine), the resultingProcessExceptionescapes as an unhandled tool crash. It is the #9 tool crasher in the 3.47.5 crash report (see the linked issue).The batch
KernelCompiler.compilealready guards against this with a_processManager.canRuncheck fordartaotruntime, exiting withUnable to find dartaotruntime binary at .... The resident compiler had no such check.This PR extracts the frontend server startup command into a shared
_commandToStartFrontendServerhelper used by bothKernelCompiler.compileandDefaultResidentCompiler._compile, so both paths get the samedartaotruntimecheck and the same message. Per review, the helper does not checkcanRunfor the Dart binary in thefrontendServerStarterPathbranch (ifdartcan't run,fluttercan't run either), which also drops that pre-existing check from the batch path.As discussed in review, this does not make the tool self-heal the Dart SDK artifact (which does not go through the
CachedArtifact/Cache.updateAll()flow); that would be a larger change.Tests:
compile_incremental_test.dart:recompileexits the tool with theUnable to find dartaotruntime binarymessage whendartaotruntimeis not runnable (fails on master); and withfrontendServerStarterPathset, the frontend server is started with the Dart binary and the starter script, without requiringdartaotruntime.compile_batch_test.dart: the same two cases forKernelCompiler.compile.Fixes #193518
Pre-launch Checklist
///).