Skip to content

[tool][engine] Enable experimental VM service by default - #190100

Merged
auto-submit[bot] merged 46 commits into
flutter:masterfrom
bkonyi:enable_experimental_vm_service
Nov 26, 2026
Merged

auto-submit[bot] merged 46 commits into
flutter:masterfrom
bkonyi:enable_experimental_vm_service

Conversation

@bkonyi

@bkonyi bkonyi commented Jul 27, 2026 •

Copy link
Copy Markdown
Contributor

This change enables the new modular VM service (pkg/dart_runtime_service_vm) by default across the engine and flutter_tools, transitioning its build and packaging to align with the app's execution mode:

  • Debug (JIT): The VM service is built and delivered as a kernel snapshot (vmservice_snapshot.dill).
  • Profile (AOT): The VM service is built and delivered as a native shared library (libvmservice_snapshot.so on Android/Linux, libvmservice_snapshot.dll on Windows) or framework (VMService.framework on iOS/macOS).

Engine changes:

  • Updates GN build rules across Android, iOS, macOS, Windows, Linux, and Fuchsia to compile and package the VM service snapshots (vmservice_snapshot.dill in debug mode, and VMService.framework or libvmservice_snapshot in profile mode).
  • Updates dart_isolate.cc and dart_service_isolate.cc to boot the VM service directly from its entrypoint root library without dart:vmservice_io lookups.
  • Extracts kernel path probing into DartIsolate::ResolveVMServiceKernel.

Tool changes:

  • Updates build targets (DebugIosApplicationBundle, ProfileIosApplicationBundle, DebugMacOSBundleFlutterAssets, ProfileMacOSBundleFlutterAssets, UnpackLinux, UnpackWindows) to bundle vmservice_snapshot.dill in debug mode and VMService.framework / libvmservice_snapshot in profile mode.
  • Transitions artifact resolution (Artifact.vmserviceFramework and Artifact.vmserviceKernelDill) to support cross-compilation bundling.

Testing

  • Engine: dart_isolate_unittests.cc (CanCreateServiceIsolate, CanResolveVMServiceKernel) validates C++ service isolate bootstrap and kernel resolution.
  • Flutter Tools: Unit tests in packages/flutter_tools/test/general.shard/build_system/targets/*_test.dart verify snapshot bundling for debug and profile across Android, iOS, macOS, Linux, and Windows; xcode_backend_test.dart verifies nested codesigning.
  • E2E / Integration: Existing integration tests, driver tests, and devicelab runs rely on flutter run / flutter attach connecting to the VM service to drive the application on real devices and emulators.

Fixes #191966

@github-actions github-actions Bot added platform-ios iOS applications specifically tool Affects the "flutter" command-line tool. See also t: labels. engine flutter/engine related. See also e: labels. platform-macos Building on or for macOS specifically platform-windows Building on or for Windows specifically platform-linux Building on or for Linux specifically a: desktop Running on desktop team-android Owned by Android platform team team-macos Owned by the macOS platform team team-windows Owned by the Windows platform team team-linux Owned by the Linux platform team labels Jul 27, 2026
@bkonyi bkonyi added the CICD Run CI/CD label Jul 27, 2026
@bkonyi
bkonyi force-pushed the enable_experimental_vm_service branch from 9a496a7 to cd12dc3 Compare July 29, 2026 16:55
@github-actions github-actions Bot added platform-android Android applications specifically team-ios Owned by iOS platform team labels Jul 30, 2026
@bkonyi
bkonyi force-pushed the enable_experimental_vm_service branch from c3efb03 to c59ce47 Compare August 19, 2026 01:06
@github-actions github-actions Bot added the platform-fuchsia Fuchsia code specifically label Aug 20, 2026
@bkonyi
bkonyi force-pushed the enable_experimental_vm_service branch from 755ad42 to 9704467 Compare August 21, 2026 16:46
Enables the experimental VM service by default across the engine and flutter_tools, transitioning its build and packaging to align with the application runtime mode:

- Debug (JIT): The VM service is built and delivered as a kernel snapshot (vmservice_snapshot.dill).
- Profile (AOT): The VM service is built and delivered as a native shared library (libvmservice_snapshot.so, libvmservice_snapshot.dylib, or vmservice_snapshot.dll).

Engine changes:
- Updates GN build rules across Android, iOS, macOS, Windows, Linux, and Fuchsia to compile and package the VM service as an AOT shared library during Profile builds and as a kernel snapshot during Debug builds.
- Updates dart_isolate.cc and dart_snapshot.cc to support loading the VM service kernel snapshot in debug builds and dynamic shared library in profile builds.
- Resolves VM service isolate startup, fallback paths relative to executable and assets, and ephemeral port binding (--vm-service-port=0).
- Packages vmservice_snapshot.dill in Fuchsia runtime_unittests assets.

Tool changes:
- Packages vmservice_snapshot.dill into Android, iOS, macOS, Linux, and Windows debug application bundles and asset directories.
- Removes obsolete --experimental-vm-service flag as it is now enabled by default.
- Updates Artifact.vmserviceSharedLibrary and Artifact.vmserviceKernelDill paths across target platforms.
- Requires explicit Artifacts dependency injection across DesktopDevice and desktop discovery classes.
- Updates tests and mock fakes across all affected platforms.
@bkonyi
bkonyi force-pushed the enable_experimental_vm_service branch from b1729bf to d70de97 Compare August 22, 2026 16:52
@bkonyi
bkonyi marked this pull request as ready for review August 22, 2026 21:37
@bkonyi
bkonyi requested review from a team as code owners August 22, 2026 21:37
@bkonyi
bkonyi requested review from jesswrd and removed request for a team August 22, 2026 21:37
…d UnpackMacOS

`BUILT_PRODUCTS_DIR` is already configuration-scoped in Xcode, shared
`--output` directories evict prior declared outputs via
`FlutterBuildSystem.trackSharedBuildDirectory`, and `xcode_backend.dart`
guards `$xcodeFrameworksDir` embedding outside profile mode.
Removes unnecessary self-referencing `Source.pattern` inputs from
`UnpackIosVmService` and `UnpackMacOSVmService`, which already track
`Artifact.vmserviceFramework`, and tightens the `inputs` unit test
assertions.

@bkonyi bkonyi left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added profile mode coverage to ios_content_validation_test.dart to verify VMService.framework is embedded with the expected arm64 architecture in profile mode and absent in debug and release!

Comment on lines +770 to +786
if (buildMode == BuildMode.profile) {
final String vmServiceArtifactPath = environment.artifacts.getArtifactPath(
Artifact.vmserviceFramework,
platform: TargetPlatform.ios,
mode: BuildMode.profile,
);
copyDirectory(
environment.fileSystem.directory(vmServiceArtifactPath),
vmServiceFrameworkDir,
followLinks: false,
);
await _signFramework(
environment,
vmServiceFrameworkDir.childFile(_kVmServiceExecutableName),
buildMode,
);
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good call! Moved this into a dedicated UnpackIosVmService target extending UnpackDarwin.

platform: TargetPlatform.ios,
mode: BuildMode.profile,
);
copyDirectory(

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Switched UnpackIosVmService over to copyFramework and thinFramework.

Comment on lines +581 to +592
if (buildMode == BuildMode.profile) {
final String vmServiceArtifactPath = environment.artifacts.getArtifactPath(
Artifact.vmserviceFramework,
platform: TargetPlatform.darwin,
mode: BuildMode.profile,
);
copyDirectory(
environment.fileSystem.directory(vmServiceArtifactPath),
vmServiceRootDir,
followLinks: false,
);
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Moved this to UnpackMacOSVmService using copyFramework and thinFramework as well so the universal macOS framework gets thinned properly.

@vashworth

Copy link
Copy Markdown
Contributor

Ugh sorry @bkonyi, I forgot and just remembered, can you add test to macos_content_validation_test.dart too? Other than that I think it LGTM

Validate that `VMService.framework` is present in the `darwin-x64-profile` engine cache and embedded in `Contents/Frameworks/VMService.framework` with expected versioned bundle symlinks and universal `x86_64` and `arm64` binaries during `flutter build macos --profile`, and absent in `Debug` and `Release` builds. Also verify that `vmservice_snapshot.dill` is bundled only in `Debug` builds and keep `FlutterMacOS.framework.dSYM` validation scoped to `Release` builds.
vashworth
vashworth previously approved these changes Nov 11, 2026
vashworth
vashworth previously approved these changes Nov 19, 2026
Pass `TestFeatureFlags()` to `Environment.test` call sites added in
`ios_test.dart`, `linux_test.dart`, `macos_test.dart`, and
`windows_test.dart` after merging `master`.
# Conflicts:
#	packages/flutter_tools/test/commands.shard/hermetic/assemble_test.dart
#	packages/flutter_tools/test/general.shard/build_system/targets/android_test.dart
#	packages/flutter_tools/test/general.shard/build_system/targets/ios_test.dart
#	packages/flutter_tools/test/general.shard/build_system/targets/linux_test.dart
#	packages/flutter_tools/test/general.shard/build_system/targets/macos_test.dart
#	packages/flutter_tools/test/general.shard/build_system/targets/windows_test.dart

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

@bkonyi bkonyi added the autosubmit Merge PR when tree becomes green via auto submit App label Nov 26, 2026
@auto-submit
auto-submit Bot added this pull request to the merge queue Nov 26, 2026
Merged via the queue into flutter:master with commit ee48e4f Nov 26, 2026
21 checks passed
@flutter-dashboard flutter-dashboard Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Nov 26, 2026
@cbracken

Copy link
Copy Markdown
Member

@cbracken cbracken added the revert Autorevert PR (with "Reason for revert:" comment) label Nov 26, 2026
@flutteractionsbot

Copy link
Copy Markdown
Contributor

Successfully created revert PR: #197481

@flutteractionsbot flutteractionsbot removed the revert Autorevert PR (with "Reason for revert:" comment) label Nov 26, 2026
DiegoYeyoDev pushed a commit to DiegoYeyoDev/flutter that referenced this pull request Nov 26, 2026
…tter#197481)

Reverts: [[tool][engine] Enable experimental VM service by
default](flutter#190100)

Initiated by: @cbracken

Reason for reverting: Windows bots all failing
https://ci.chromium.org/ui/p/flutter/builders/prod/Windows%20flutter_gallery_win_desktop__start_up/24708/overview

Original PR Author: @bkonyi

Reviewed By: @jyameo

The original PR description is provided below:

This change enables the new modular VM service
(`pkg/dart_runtime_service_vm`) by default across the engine and
`flutter_tools`, transitioning its build and packaging to align with the
app's execution mode:

- Debug (JIT): The VM service is built and delivered as a kernel
snapshot (`vmservice_snapshot.dill`).
- Profile (AOT): The VM service is built and delivered as a native
shared library (`libvmservice_snapshot.so` on Android/Linux,
`libvmservice_snapshot.dll` on Windows) or framework
(`VMService.framework` on iOS/macOS).

Engine changes:
- Updates GN build rules across Android, iOS, macOS, Windows, Linux, and
Fuchsia to compile and package the VM service snapshots
(`vmservice_snapshot.dill` in debug mode, and `VMService.framework` or
`libvmservice_snapshot` in profile mode).
- Updates `dart_isolate.cc` and `dart_service_isolate.cc` to boot the VM
service directly from its entrypoint root library without
`dart:vmservice_io` lookups.
- Extracts kernel path probing into
`DartIsolate::ResolveVMServiceKernel`.

Tool changes:
- Updates build targets (`DebugIosApplicationBundle`,
`ProfileIosApplicationBundle`, `DebugMacOSBundleFlutterAssets`,
`ProfileMacOSBundleFlutterAssets`, `UnpackLinux`, `UnpackWindows`) to
bundle `vmservice_snapshot.dill` in debug mode and `VMService.framework`
/ `libvmservice_snapshot` in profile mode.
- Transitions artifact resolution (`Artifact.vmserviceFramework` and
`Artifact.vmserviceKernelDill`) to support cross-compilation bundling.

## Testing
- **Engine**: `dart_isolate_unittests.cc` (`CanCreateServiceIsolate`,
`CanResolveVMServiceKernel`) validates C++ service isolate bootstrap and
kernel resolution.
- **Flutter Tools**: Unit tests in
`packages/flutter_tools/test/general.shard/build_system/targets/*_test.dart`
verify snapshot bundling for debug and profile across Android, iOS,
macOS, Linux, and Windows; `xcode_backend_test.dart` verifies nested
codesigning.
- **E2E / Integration**: Existing integration tests, driver tests, and
devicelab runs rely on `flutter run` / `flutter attach` connecting to
the VM service to drive the application on real devices and emulators.

Fixes flutter#191966
auto-submit Bot pushed a commit to flutter/packages that referenced this pull request Nov 27, 2026
flutter/flutter@82ec424...43150a8

2026-11-27 [email protected] Windows: fix for popup descendent of popup closing the whole tree when the 2nd popup gains focus (flutter/flutter#196911)
2026-11-27 [email protected] Roll Skia from d693d85a4b77 to fe34f20b9689 (1 revision) (flutter/flutter#197491)
2026-11-27 [email protected] Roll Dart SDK from 691817e0ec3b to 5c3e102fc422 (1 revision) (flutter/flutter#197489)
2026-11-27 [email protected] Roll Fuchsia Linux SDK from 0bgCrr76CM4IqPO0v... to cBAjguERWwvY6tFtz... (flutter/flutter#197488)
2026-11-27 [email protected] [flutter_tools] Delete AppContext and legacy test context shims (flutter/flutter#197412)
2026-11-26 [email protected] Revert: [tool][engine] Enable experimental VM service by default (flutter/flutter#197481)
2026-11-26 [email protected] iOS: Remove engine includes from the platform views controller headers (flutter/flutter#197429)
2026-11-26 [email protected] [tool][engine] Enable experimental VM service by default (flutter/flutter#190100)
2026-11-26 [email protected] Add trust gate flags for "flutter analyze" (flutter/flutter#196415)
2026-11-26 [email protected] Roll Dart SDK from 7fcaf46b0308 to 691817e0ec3b (1 revision) (flutter/flutter#197475)
2026-11-26 [email protected] [Windows] Fix MASM flags in Windows GN `tool("asm")` (flutter/flutter#197464)
2026-11-26 [email protected] Roll Skia from cef5963c1bb2 to d693d85a4b77 (2 revisions) (flutter/flutter#197469)
2026-11-26 [email protected] Roll Packages from 105a874 to da586f5 (3 revisions) (flutter/flutter#197471)

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

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
opensource-fork-sync Bot pushed a commit to cla7aye15I4nd/opensource-flutter__flutter that referenced this pull request Nov 27, 2026
…ter#197483)

Relands [flutter#190100](flutter#190100)
(reverted in [flutter#197481](flutter#197481))
with a fix for Windows and Linux desktop profile-mode bundling on
existing projects.

### Root cause
[flutter#190100](flutter#190100) added the
`install(FILES ... libvmservice_snapshot.{dll,so} ...)` rule only to the
new-project `CMakeLists.txt.tmpl` templates. Existing Windows and Linux
apps (including DeviceLab apps such as `flutter_gallery` and
`flutter_view`) have checked-in `CMakeLists.txt` files without that
rule, so `UnpackWindows`/`UnpackLinux` unpacked the library into
`flutter/ephemeral/`, but CMake `INSTALL` never copied it to the app
bundle. At startup, `DartVMData::GetServiceIsolateSnapshot()` fell back
to the app snapshot and failed in `DartServiceIsolate::Startup`. The
template rule also omitted `CONFIGURATIONS Profile`, risking stale
bundling into subsequent Release builds.

### Fix
- Emit the `install(FILES ...)` rule in `writeGeneratedCmakeConfig`
(`packages/flutter_tools/lib/src/cmake.dart`) for `WindowsProject`
(`data/libvmservice_snapshot.dll`) and `LinuxProject`
(`lib/libvmservice_snapshot.so`) with `CONFIGURATIONS Profile`,
`COMPONENT Runtime`, and `OPTIONAL`.
- On CMake 3.19+, defer the `install()` call to `${PROJECT_SOURCE_DIR}`
via `cmake_language(DEFER ...)` so it runs after parent bundle cleanup
rules (such as Linux `file(REMOVE_RECURSE ...)` when
`cmake_minimum_required` is 3.14+ / `CMP0082` NEW).
- Revert the `CMakeLists.txt.tmpl` changes from
[flutter#190100](flutter#190100).
- Add unit tests in
`packages/flutter_tools/test/general.shard/cmake_test.dart` and
integration tests in
`packages/flutter_tools/test/integration.shard/flutter_build_windows_test.dart`
and
`packages/flutter_tools/test/integration.shard/flutter_build_linux_test.dart`
(covering profile bundling, release exclusion, and CMake 3.14 ordering).

Previous output:
```
[IMPORTANT:flutter/shell/platform/embedder/embedder_surface_gl_impeller.cc(127)] Using the Impeller rendering backend (OpenGLESSDF).
[ERROR:flutter/runtime/dart_isolate.cc(1095)] DartServiceIsolate::Startup failed: Unhandled exception:
NoSuchMethodError: No top-level setter '_ip=' declared.
Receiver: top-level
Tried calling: _ip="127.0.0.1"
#0      NoSuchMethodError._throwNew (dart:core-patch/errors_patch.dart:174)
```

Current output:
```
[IMPORTANT:flutter/shell/platform/embedder/embedder_surface_gl_impeller.cc(127)] Using the Impeller rendering backend (OpenGLESSDF).
The Dart VM service is listening on http://127.0.0.1:45591/3O4DhxOyHcE=/
```

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

Labels

a: desktop Running on desktop a: tests "flutter test", flutter_test, or one of our tests CICD Run CI/CD engine flutter/engine related. See also e: labels. f: integration_test The flutter/packages/integration_test plugin framework flutter/packages/flutter repository. See also f: labels. platform-android Android applications specifically platform-fuchsia Fuchsia code specifically platform-ios iOS applications specifically platform-linux Building on or for Linux specifically platform-macos Building on or for macOS specifically platform-windows Building on or for Windows specifically team-android Owned by Android platform team team-ios Owned by iOS platform team team-linux Owned by the Linux platform team team-macos Owned by the macOS platform team team-windows Owned by the Windows platform team tool Affects the "flutter" command-line tool. See also t: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[engine] Enable new modular VM service (dart_runtime_service_vm) by default

8 participants