Repository navigation
[tool][engine] Enable experimental VM service by default - #190100
Conversation
9a496a7 to
cd12dc3
Compare
c3efb03 to
c59ce47
Compare
755ad42 to
9704467
Compare
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.
b1729bf to
d70de97
Compare
…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
left a comment
There was a problem hiding this comment.
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!
| 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, | ||
| ); | ||
| } |
There was a problem hiding this comment.
Good call! Moved this into a dedicated UnpackIosVmService target extending UnpackDarwin.
| platform: TargetPlatform.ios, | ||
| mode: BuildMode.profile, | ||
| ); | ||
| copyDirectory( |
There was a problem hiding this comment.
Switched UnpackIosVmService over to copyFramework and thinFramework.
| 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, | ||
| ); | ||
| } |
There was a problem hiding this comment.
Moved this to UnpackMacOSVmService using copyFramework and thinFramework as well so the universal macOS framework gets thinned properly.
|
Ugh sorry @bkonyi, I forgot and just remembered, can you add test to |
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.
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
|
Successfully created revert PR: #197481 |
…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
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
…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
This change enables the new modular VM service (
pkg/dart_runtime_service_vm) by default across the engine andflutter_tools, transitioning its build and packaging to align with the app's execution mode:vmservice_snapshot.dill).libvmservice_snapshot.soon Android/Linux,libvmservice_snapshot.dllon Windows) or framework (VMService.frameworkon iOS/macOS).Engine changes:
vmservice_snapshot.dillin debug mode, andVMService.frameworkorlibvmservice_snapshotin profile mode).dart_isolate.ccanddart_service_isolate.ccto boot the VM service directly from its entrypoint root library withoutdart:vmservice_iolookups.DartIsolate::ResolveVMServiceKernel.Tool changes:
DebugIosApplicationBundle,ProfileIosApplicationBundle,DebugMacOSBundleFlutterAssets,ProfileMacOSBundleFlutterAssets,UnpackLinux,UnpackWindows) to bundlevmservice_snapshot.dillin debug mode andVMService.framework/libvmservice_snapshotin profile mode.Artifact.vmserviceFrameworkandArtifact.vmserviceKernelDill) to support cross-compilation bundling.Testing
dart_isolate_unittests.cc(CanCreateServiceIsolate,CanResolveVMServiceKernel) validates C++ service isolate bootstrap and kernel resolution.packages/flutter_tools/test/general.shard/build_system/targets/*_test.dartverify snapshot bundling for debug and profile across Android, iOS, macOS, Linux, and Windows;xcode_backend_test.dartverifies nested codesigning.flutter run/flutter attachconnecting to the VM service to drive the application on real devices and emulators.Fixes #191966