From 68339b10cdc271eeae7fd7a9acb68e70f712c4cf Mon Sep 17 00:00:00 2001 From: Ryan Macnak Date: Mon, 23 Jul 2018 12:28:17 -0700 Subject: [PATCH] Reapply "Fix Dart 2 reload when running from a snapshot instead of platform.dill." (flutter/engine#5830) Without this flag, the VM will attempt to interpret a kernel file as source code. Affects Fuchsia (FL-71) and code-push. --- engine/src/flutter/runtime/dart_isolate.cc | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/engine/src/flutter/runtime/dart_isolate.cc b/engine/src/flutter/runtime/dart_isolate.cc index bd2c2350541..51073de2466 100644 --- a/engine/src/flutter/runtime/dart_isolate.cc +++ b/engine/src/flutter/runtime/dart_isolate.cc @@ -719,6 +719,20 @@ DartIsolate::CreateDartVMAndEmbedderObjectPair( (*raw_embedder_isolate)->child_isolate_preparer_)); } + // TODO(rmacnak): This flag setting business preserves a side effect of using + // Dart_CreateIsolateFromKernel. It should be removed when some of the + // internal logic in reload no longer uses this flag. + Dart_IsolateFlags nonnull_flags; + if (flags == nullptr) { + Dart_IsolateFlagsInitialize(&nonnull_flags); + flags = &nonnull_flags; + } + bool dart2 = (vm->GetPlatformKernel().GetSize() > 0) || + Dart_IsDart2Snapshot(embedder_isolate->GetIsolateSnapshot() + ->GetData() + ->GetSnapshotPointer()); + flags->use_dart_frontend = dart2; + // Create the Dart VM isolate and give it the embedder object as the baton. Dart_Isolate isolate = (vm->GetPlatformKernel().GetSize() > 0)