Skip to content

[flutter_tools] Check that dartaotruntime can run before starting the frontend server - #194206

Merged
auto-submit[bot] merged 4 commits into
flutter:masterfrom
BilalWalker:fix-frontend-server-start-toolexit
Nov 24, 2026
Merged

auto-submit[bot] merged 4 commits into
flutter:masterfrom
BilalWalker:fix-frontend-server-start-toolexit

Conversation

@BilalWalker

@BilalWalker BilalWalker commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

DefaultResidentCompiler._compile spawns the frontend server (dartaotruntime + frontend_server_aot.dart.snapshot) directly. When dartaotruntime is missing from bin/cache (partially downloaded or corrupted SDK, cache cleaned while a resident session is running, antivirus quarantine), the resulting ProcessException escapes 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.compile already guards against this with a _processManager.canRun check for dartaotruntime, exiting with Unable to find dartaotruntime binary at .... The resident compiler had no such check.

This PR extracts the frontend server startup command into a shared _commandToStartFrontendServer helper used by both KernelCompiler.compile and DefaultResidentCompiler._compile, so both paths get the same dartaotruntime check and the same message. Per review, the helper does not check canRun for the Dart binary in the frontendServerStarterPath branch (if dart can't run, flutter can'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: recompile exits the tool with the Unable to find dartaotruntime binary message when dartaotruntime is not runnable (fails on master); and with frontendServerStarterPath set, the frontend server is started with the Dart binary and the starter script, without requiring dartaotruntime.
  • compile_batch_test.dart: the same two cases for KernelCompiler.compile.

Fixes #193518

Pre-launch Checklist

@github-actions github-actions Bot added the tool Affects the "flutter" command-line tool. See also t: labels. label Oct 12, 2026
@google-cla

google-cla Bot commented Oct 12, 2026

Copy link
Copy Markdown

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.

@BilalWalker

Copy link
Copy Markdown
Contributor Author

@googlebot I signed it!

@BilalWalker
BilalWalker marked this pull request as ready for review October 12, 2026 10:41

@gemini-code-assist gemini-code-assist Bot 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.

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
jmagman requested a review from bkonyi October 29, 2026 16:16

@jmagman jmagman left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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
@BilalWalker
BilalWalker force-pushed the fix-frontend-server-start-toolexit branch from 4b28547 to d7f8bb9 Compare October 29, 2026 17:39
@BilalWalker BilalWalker changed the title [flutter_tools] Exit cleanly when the Dart frontend server cannot be started [flutter_tools] Check that dartaotruntime can run before starting the resident frontend server Oct 29, 2026
@BilalWalker

Copy link
Copy Markdown
Contributor Author

@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.

@BilalWalker
BilalWalker requested a review from jmagman October 29, 2026 17:44
@jmagman jmagman added the CICD Run CI/CD label Oct 30, 2026

@bkonyi bkonyi 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.

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.
@flutter-dashboard flutter-dashboard Bot removed the CICD Run CI/CD label Nov 3, 2026
@BilalWalker BilalWalker changed the title [flutter_tools] Check that dartaotruntime can run before starting the resident frontend server [flutter_tools] Check that dartaotruntime can run before starting the frontend server Nov 3, 2026
@BilalWalker

Copy link
Copy Markdown
Contributor Author

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.

@BilalWalker
BilalWalker requested review from bkonyi and jmagman November 3, 2026 05:02
@bkonyi bkonyi added the CICD Run CI/CD label Nov 4, 2026
@flutter-dashboard flutter-dashboard Bot removed the CICD Run CI/CD label Nov 4, 2026
@bkonyi bkonyi added the CICD Run CI/CD label Nov 4, 2026

@bkonyi bkonyi 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! We'll need one more review before this can land.

@BilalWalker

Copy link
Copy Markdown
Contributor Author

@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.

@jmagman jmagman added the autosubmit Merge PR when tree becomes green via auto submit App label Nov 19, 2026
@auto-submit auto-submit Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Nov 19, 2026
@auto-submit

auto-submit Bot commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

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.

@flutter-dashboard flutter-dashboard Bot removed the CICD Run CI/CD label Nov 20, 2026
@BilalWalker

Copy link
Copy Markdown
Contributor Author

Merged the latest master as auto-submit asked. @bkonyi @jmagman could one of you re-add the CICD and autosubmit labels when you get a chance? Thanks for the reviews!

@bkonyi bkonyi added CICD Run CI/CD autosubmit Merge PR when tree becomes green via auto submit App labels Nov 24, 2026
@auto-submit auto-submit Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Nov 24, 2026
@auto-submit

auto-submit Bot commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

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..

@bkonyi bkonyi added the autosubmit Merge PR when tree becomes green via auto submit App label Nov 24, 2026
@auto-submit
auto-submit Bot added this pull request to the merge queue Nov 24, 2026
Merged via the queue into flutter:master with commit af812ce Nov 24, 2026
24 checks passed
@flutter-dashboard flutter-dashboard Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Nov 24, 2026
@BilalWalker
BilalWalker deleted the fix-frontend-server-start-toolexit branch November 25, 2026 05:41
auto-submit Bot pushed a commit to flutter/packages that referenced this pull request Nov 25, 2026
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

...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CICD Run CI/CD tool Affects the "flutter" command-line tool. See also t: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[tool_crash] Unhandled ProcessPackageException in DefaultResidentCompiler._compile when dartaotruntime is missing

3 participants