@@ -577,6 +577,7 @@ bool DartIsolate::LoadKernel(std::shared_ptr<const fml::Mapping> mapping,
577577
578578[[nodiscard]] bool DartIsolate::PrepareForRunningFromKernel (
579579 std::shared_ptr<const fml::Mapping> mapping,
580+ bool child_isolate,
580581 bool last_piece) {
581582 TRACE_EVENT0 (" flutter" , " DartIsolate::PrepareForRunningFromKernel" );
582583 if (phase_ != Phase::LibrariesSetup) {
@@ -593,11 +594,13 @@ bool DartIsolate::LoadKernel(std::shared_ptr<const fml::Mapping> mapping,
593594
594595 tonic::DartState::Scope scope (this );
595596
596- // Use root library provided by kernel in favor of one provided by snapshot.
597- Dart_SetRootLibrary (Dart_Null ());
597+ if (!child_isolate || !Dart_IsVMFlagSet (" --enable-isolate-groups" )) {
598+ // Use root library provided by kernel in favor of one provided by snapshot.
599+ Dart_SetRootLibrary (Dart_Null ());
598600
599- if (!LoadKernel (mapping, last_piece)) {
600- return false ;
601+ if (!LoadKernel (mapping, last_piece)) {
602+ return false ;
603+ }
601604 }
602605
603606 if (!last_piece) {
@@ -622,7 +625,9 @@ bool DartIsolate::LoadKernel(std::shared_ptr<const fml::Mapping> mapping,
622625 for (uint64_t i = 0 ; i < buffers.size (); i++) {
623626 bool last_piece = i + 1 == buffers.size ();
624627 const std::shared_ptr<const fml::Mapping>& buffer = buffers.at (i);
625- if (!isolate->PrepareForRunningFromKernel (buffer, last_piece)) {
628+ if (!isolate->PrepareForRunningFromKernel (buffer,
629+ /* child_isolate=*/ true ,
630+ last_piece)) {
626631 return false ;
627632 }
628633 }
@@ -650,7 +655,8 @@ bool DartIsolate::LoadKernel(std::shared_ptr<const fml::Mapping> mapping,
650655
651656 for (size_t i = 0 ; i < count; ++i) {
652657 bool last = (i == (count - 1 ));
653- if (!PrepareForRunningFromKernel (kernels[i], last)) {
658+ if (!PrepareForRunningFromKernel (kernels[i], /* child_isolate=*/ false ,
659+ last)) {
654660 return false ;
655661 }
656662 }
0 commit comments