From 4c2448d1591a5fab033de3885ad34d1fdf5474f1 Mon Sep 17 00:00:00 2001 From: Ryan Macnak Date: Fri, 7 Sep 2018 15:44:46 -0700 Subject: [PATCH] Some cleanups enabled by removing support for Dart. (#5621) - Switch core snapshot to Dart 2 and remove support for loading platform.dill. - Remove support for loading script snapshots. - Remove support for loading source. - Remove settings and fix names to reflect the above. - Remove support for loading the service isolate from source. --- common/settings.cc | 1 - common/settings.h | 3 - lib/snapshot/BUILD.gn | 326 ++++++++---------- runtime/dart_isolate.cc | 140 +------- runtime/dart_isolate.h | 16 +- runtime/dart_isolate_unittests.cc | 66 ---- runtime/dart_service_isolate.cc | 168 +-------- runtime/dart_service_isolate.h | 14 - runtime/dart_vm.cc | 16 +- runtime/dart_vm.h | 3 - runtime/dart_vm_unittests.cc | 1 - shell/common/engine.cc | 5 - shell/common/engine.h | 3 - shell/common/isolate_configuration.cc | 71 +--- shell/common/isolate_configuration.h | 8 +- shell/common/shell.cc | 8 +- shell/common/switches.cc | 3 - shell/common/switches.h | 1 - shell/platform/android/flutter_main.cc | 5 - .../android/io/flutter/view/FlutterMain.java | 14 +- .../android/platform_view_android_jni.cc | 7 +- .../framework/Source/FlutterDartProject.mm | 31 +- shell/platform/embedder/embedder.cc | 7 +- shell/testing/tester_main.cc | 9 +- 24 files changed, 195 insertions(+), 731 deletions(-) diff --git a/common/settings.cc b/common/settings.cc index 8123b1d321ef6..9aa8997ba947b 100644 --- a/common/settings.cc +++ b/common/settings.cc @@ -11,7 +11,6 @@ namespace blink { std::string Settings::ToString() const { std::stringstream stream; stream << "Settings: " << std::endl; - stream << "script_snapshot_path: " << script_snapshot_path << std::endl; stream << "vm_snapshot_data_path: " << vm_snapshot_data_path << std::endl; stream << "vm_snapshot_instr_path: " << vm_snapshot_instr_path << std::endl; stream << "isolate_snapshot_data_path: " << isolate_snapshot_data_path diff --git a/common/settings.h b/common/settings.h index 124529b90c57d..1c0002e7ad7d6 100644 --- a/common/settings.h +++ b/common/settings.h @@ -23,9 +23,6 @@ using TaskObserverRemove = std::function; struct Settings { // VM settings - std::string script_snapshot_path; - std::string platform_kernel_path; - std::string vm_snapshot_data_path; std::string vm_snapshot_instr_path; std::string isolate_snapshot_data_path; diff --git a/lib/snapshot/BUILD.gn b/lib/snapshot/BUILD.gn index d257830ebd6ba..99e3c2f9638aa 100644 --- a/lib/snapshot/BUILD.gn +++ b/lib/snapshot/BUILD.gn @@ -25,197 +25,143 @@ copy("generate_dart_ui") { ] } -action("generate_snapshot_bin") { - if (is_fuchsia) { - snapshot_dart = "snapshot_fuchsia.dart" - - # TODO(rmacnak): Fuchsia cross builds use the wrong Dart target - # architecture, and have added steps that depend on this error for - # reasonable build times (e.g., invoking the analyzer). - if (target_cpu == host_cpu) { - snapshot_kind = "core-jit" - } else { - snapshot_kind = "core" - } - } else { - snapshot_dart = "snapshot.dart" - snapshot_kind = "core" - } +# Fuchsia's snapshot requires a different platform with extra dart: libraries. +if (!is_fuchsia) { + compiled_action("generate_snapshot_bin") { + tool = "//third_party/dart/runtime/bin:gen_snapshot" - deps = [ - ":generate_dart_ui", - "//third_party/dart/runtime/bin:gen_snapshot($host_toolchain)", - ] - depfile = "$target_gen_dir/core_snapshot.d" - - inputs = [ - "//third_party/dart/runtime/tools/create_snapshot_bin.py", - snapshot_dart, - ] + dart_ui_files - if (is_fuchsia) { - inputs += [ "fuchsia_compilation_trace.txt" ] - } + platform_kernel = "$root_out_dir/flutter_patched_sdk/platform_strong.dill" + inputs = [ + platform_kernel, + ] + deps = [ + ":kernel_platform_files", + ] - vm_snapshot_data = "$target_gen_dir/vm_isolate_snapshot.bin" - vm_snapshot_instructions = "$target_gen_dir/vm_snapshot_instructions.bin" - isolate_snapshot_data = "$target_gen_dir/isolate_snapshot.bin" - isolate_snapshot_instructions = - "$target_gen_dir/isolate_snapshot_instructions.bin" - outputs = [ - vm_snapshot_data, - vm_snapshot_instructions, - isolate_snapshot_data, - isolate_snapshot_instructions, - ] + vm_snapshot_data = "$target_gen_dir/vm_isolate_snapshot.bin" + vm_snapshot_instructions = "$target_gen_dir/vm_snapshot_instructions.bin" + isolate_snapshot_data = "$target_gen_dir/isolate_snapshot.bin" + isolate_snapshot_instructions = + "$target_gen_dir/isolate_snapshot_instructions.bin" + outputs = [ + vm_snapshot_data, + vm_snapshot_instructions, + isolate_snapshot_data, + isolate_snapshot_instructions, + ] - rebased_dart_ui_path = rebase_path(dart_ui_path) + args = [ + "--snapshot_kind=core", + "--await_is_keyword", + "--enable_mirrors=false", + "--vm_snapshot_data=" + rebase_path(vm_snapshot_data), + "--vm_snapshot_instructions=" + rebase_path(vm_snapshot_instructions), + "--isolate_snapshot_data=" + rebase_path(isolate_snapshot_data), + "--isolate_snapshot_instructions=" + + rebase_path(isolate_snapshot_instructions), + rebase_path(platform_kernel), + ] - gen_snapshot_dir = get_label_info( - "//third_party/dart/runtime/bin:gen_snapshot($host_toolchain)", - "root_out_dir") - script = "//third_party/dart/runtime/tools/create_snapshot_bin.py" + if (is_debug) { + args += [ + "--enable_asserts", + "--enable_type_checks", + "--error_on_bad_type", + "--error_on_bad_override", + ] + } + } - args = [ - "--executable", - rebase_path("$gen_snapshot_dir/gen_snapshot"), - "--script", - rebase_path(snapshot_dart), - "--snapshot_kind", - snapshot_kind, - "--vm_flag", - "--await_is_keyword", - "--vm_flag", - "--enable_mirrors=false", - "--vm_output_bin", - rebase_path(vm_snapshot_data, root_build_dir), - "--vm_instructions_output_bin", - rebase_path(vm_snapshot_instructions, root_build_dir), - "--isolate_output_bin", - rebase_path(isolate_snapshot_data, root_build_dir), - "--isolate_instructions_output_bin", - rebase_path(isolate_snapshot_instructions, root_build_dir), - "--url_mapping=dart:ui,$rebased_dart_ui_path", - "--vm_flag", - "--dependencies=" + rebase_path(depfile), - ] + # Generates an assembly file defining a given symbol with the bytes from a + # binary file. Places the symbol in a text section if 'executable' is true, + # otherwise places the symbol in a read-only data section. + template("bin_to_assembly") { + assert(defined(invoker.deps), "Must define deps") + assert(defined(invoker.input), "Must define input binary file") + assert(defined(invoker.output), "Must define output assembly file") + assert(defined(invoker.symbol), "Must define symbol name") + assert(defined(invoker.executable), "Must define boolean executable") + + action(target_name) { + deps = invoker.deps + script = "//third_party/dart/runtime/tools/bin_to_assembly.py" + args = [ + "--input", + rebase_path(invoker.input), + "--output", + rebase_path(invoker.output), + "--symbol_name", + invoker.symbol, + "--target_os", + current_os, + ] + if (invoker.executable) { + args += [ "--executable" ] + } + inputs = [ + script, + invoker.input, + ] + outputs = [ + invoker.output, + ] + } + } - if (is_debug) { - args += [ - "--vm_flag", - "--enable_asserts", - "--vm_flag", - "--enable_type_checks", - "--vm_flag", - "--error_on_bad_type", - "--vm_flag", - "--error_on_bad_override", + bin_to_assembly("vm_snapshot_data_assembly") { + deps = [ + ":generate_snapshot_bin", ] + input = "$target_gen_dir/vm_isolate_snapshot.bin" + output = "$target_gen_dir/vm_snapshot_data.S" + symbol = "kDartVmSnapshotData" + executable = false } - if (is_fuchsia) { - inputs += zircon_sdk_ext_files + mozart_dart_sdk_ext_files - zircon_path = rebase_path(zircon_sdk_ext_lib) - fuchsia_path = rebase_path(fuchsia_sdk_ext_lib) - mozart_internal_path = rebase_path(mozart_dart_sdk_ext_lib) - args += [ - "--url_mapping=dart:zircon,$zircon_path", - "--url_mapping=dart:fuchsia,$fuchsia_path", - "--url_mapping=dart:mozart.internal,$mozart_internal_path", - "--load_compilation_trace", - rebase_path("fuchsia_compilation_trace.txt"), + bin_to_assembly("vm_snapshot_instructions_assembly") { + deps = [ + ":generate_snapshot_bin", ] + input = "$target_gen_dir/vm_snapshot_instructions.bin" + output = "$target_gen_dir/vm_snapshot_instructions.S" + symbol = "kDartVmSnapshotInstructions" + executable = true } -} -# Generates an assembly file defining a given symbol with the bytes from a -# binary file. Places the symbol in a text section if 'executable' is true, -# otherwise places the symbol in a read-only data section. -template("bin_to_assembly") { - assert(defined(invoker.deps), "Must define deps") - assert(defined(invoker.input), "Must define input binary file") - assert(defined(invoker.output), "Must define output assembly file") - assert(defined(invoker.symbol), "Must define symbol name") - assert(defined(invoker.executable), "Must define boolean executable") - - action(target_name) { - deps = invoker.deps - script = "//third_party/dart/runtime/tools/bin_to_assembly.py" - args = [ - "--input", - rebase_path(invoker.input), - "--output", - rebase_path(invoker.output), - "--symbol_name", - invoker.symbol, - "--target_os", - current_os, - ] - if (invoker.executable) { - args += [ "--executable" ] - } - inputs = [ - script, - invoker.input, - ] - outputs = [ - invoker.output, + bin_to_assembly("isolate_snapshot_data_assembly") { + deps = [ + ":generate_snapshot_bin", ] + input = "$target_gen_dir/isolate_snapshot.bin" + output = "$target_gen_dir/isolate_snapshot_data.S" + symbol = "kDartIsolateSnapshotData" + executable = false } -} - -bin_to_assembly("vm_snapshot_data_assembly") { - deps = [ - ":generate_snapshot_bin", - ] - input = "$target_gen_dir/vm_isolate_snapshot.bin" - output = "$target_gen_dir/vm_snapshot_data.S" - symbol = "kDartVmSnapshotData" - executable = false -} - -bin_to_assembly("vm_snapshot_instructions_assembly") { - deps = [ - ":generate_snapshot_bin", - ] - input = "$target_gen_dir/vm_snapshot_instructions.bin" - output = "$target_gen_dir/vm_snapshot_instructions.S" - symbol = "kDartVmSnapshotInstructions" - executable = true -} - -bin_to_assembly("isolate_snapshot_data_assembly") { - deps = [ - ":generate_snapshot_bin", - ] - input = "$target_gen_dir/isolate_snapshot.bin" - output = "$target_gen_dir/isolate_snapshot_data.S" - symbol = "kDartIsolateSnapshotData" - executable = false -} -bin_to_assembly("isolate_snapshot_instructions_assembly") { - deps = [ - ":generate_snapshot_bin", - ] - input = "$target_gen_dir/isolate_snapshot_instructions.bin" - output = "$target_gen_dir/isolate_snapshot_instructions.S" - symbol = "kDartIsolateSnapshotInstructions" - executable = true -} + bin_to_assembly("isolate_snapshot_instructions_assembly") { + deps = [ + ":generate_snapshot_bin", + ] + input = "$target_gen_dir/isolate_snapshot_instructions.bin" + output = "$target_gen_dir/isolate_snapshot_instructions.S" + symbol = "kDartIsolateSnapshotInstructions" + executable = true + } -source_set("snapshot") { - deps = [ - ":isolate_snapshot_data_assembly", - ":isolate_snapshot_instructions_assembly", - ":vm_snapshot_data_assembly", - ":vm_snapshot_instructions_assembly", - ] - sources = [ - "$target_gen_dir/isolate_snapshot_data.S", - "$target_gen_dir/isolate_snapshot_instructions.S", - "$target_gen_dir/vm_snapshot_data.S", - "$target_gen_dir/vm_snapshot_instructions.S", - ] + source_set("snapshot") { + deps = [ + ":isolate_snapshot_data_assembly", + ":isolate_snapshot_instructions_assembly", + ":vm_snapshot_data_assembly", + ":vm_snapshot_instructions_assembly", + ] + sources = [ + "$target_gen_dir/isolate_snapshot_data.S", + "$target_gen_dir/isolate_snapshot_instructions.S", + "$target_gen_dir/vm_snapshot_data.S", + "$target_gen_dir/vm_snapshot_instructions.S", + ] + } } compile_platform("non_strong_platform") { @@ -282,22 +228,28 @@ template("generate_entry_points_json_with_gen_snapshot") { output = invoker.output tool = "//third_party/dart/runtime/bin:gen_snapshot" - inputs = [ - input, - ] + extra_inputs + inputs = [ input ] + extra_inputs outputs = [ output, + + # Though they are not consumed, GN needs to know to create the output directory. + "$target_gen_dir/dummy.vm_data.snapshot", + "$target_gen_dir/dummy.vm_instr.snapshot", + "$target_gen_dir/dummy.isolate_data.snapshot", + "$target_gen_dir/dummy.isolate_instr.snapshot", ] args = [ - "--print-precompiler-entry-points=" + rebase_path(output), - "--snapshot-kind=app-aot-blobs", - "--vm_snapshot_data=" + rebase_path("$target_gen_dir/dummy.vm_data.snapshot"), - "--vm_snapshot_instructions=" + rebase_path("$target_gen_dir/dummy.vm_instr.snapshot"), - "--isolate_snapshot_data=" + rebase_path("$target_gen_dir/dummy.isolate_data.snapshot"), - "--isolate_snapshot_instructions=" + rebase_path("$target_gen_dir/dummy.isolate_instr.snapshot"), - ] + extra_args + [ - rebase_path(input), - ] + "--print-precompiler-entry-points=" + rebase_path(output), + "--snapshot-kind=app-aot-blobs", + "--vm_snapshot_data=" + + rebase_path("$target_gen_dir/dummy.vm_data.snapshot"), + "--vm_snapshot_instructions=" + + rebase_path("$target_gen_dir/dummy.vm_instr.snapshot"), + "--isolate_snapshot_data=" + + rebase_path("$target_gen_dir/dummy.isolate_data.snapshot"), + "--isolate_snapshot_instructions=" + + rebase_path("$target_gen_dir/dummy.isolate_instr.snapshot"), + ] + extra_args + [ rebase_path(input) ] } } diff --git a/runtime/dart_isolate.cc b/runtime/dart_isolate.cc index e48c542c11d61..34962593ea1f5 100644 --- a/runtime/dart_isolate.cc +++ b/runtime/dart_isolate.cc @@ -282,20 +282,12 @@ bool DartIsolate::PrepareForRunningFromPrecompiledCode() { return true; } -bool DartIsolate::LoadScriptSnapshot( - std::shared_ptr mapping, - bool last_piece) { - FML_CHECK(last_piece) << "Script snapshots cannot be divided"; - if (tonic::LogIfError(Dart_LoadScriptFromSnapshot(mapping->GetMapping(), - mapping->GetSize()))) { +bool DartIsolate::LoadKernel(std::shared_ptr mapping, + bool last_piece) { + if (!Dart_IsKernel(mapping->GetMapping(), mapping->GetSize())) { return false; } - return true; -} -bool DartIsolate::LoadKernelSnapshot( - std::shared_ptr mapping, - bool last_piece) { // Mapping must be retained until isolate shutdown. kernel_buffers_.push_back(mapping); @@ -317,21 +309,11 @@ bool DartIsolate::LoadKernelSnapshot( return true; } -bool DartIsolate::LoadSnapshot(std::shared_ptr mapping, - bool last_piece) { - if (Dart_IsKernel(mapping->GetMapping(), mapping->GetSize())) { - return LoadKernelSnapshot(std::move(mapping), last_piece); - } else { - return LoadScriptSnapshot(std::move(mapping), last_piece); - } - return false; -} - FML_WARN_UNUSED_RESULT -bool DartIsolate::PrepareForRunningFromSnapshot( +bool DartIsolate::PrepareForRunningFromKernel( std::shared_ptr mapping, bool last_piece) { - TRACE_EVENT0("flutter", "DartIsolate::PrepareForRunningFromSnapshot"); + TRACE_EVENT0("flutter", "DartIsolate::PrepareForRunningFromKernel"); if (phase_ != Phase::LibrariesSetup) { return false; } @@ -349,7 +331,7 @@ bool DartIsolate::PrepareForRunningFromSnapshot( // Use root library provided by kernel in favor of one provided by snapshot. Dart_SetRootLibrary(Dart_Null()); - if (!LoadSnapshot(mapping, last_piece)) { + if (!LoadKernel(mapping, last_piece)) { return false; } @@ -367,61 +349,7 @@ bool DartIsolate::PrepareForRunningFromSnapshot( } child_isolate_preparer_ = [mapping](DartIsolate* isolate) { - return isolate->PrepareForRunningFromSnapshot(mapping); - }; - phase_ = Phase::Ready; - return true; -} - -bool DartIsolate::PrepareForRunningFromSource( - const std::string& main_source_file, - const std::string& packages) { - TRACE_EVENT0("flutter", "DartIsolate::PrepareForRunningFromSource"); - if (phase_ != Phase::LibrariesSetup) { - return false; - } - - if (DartVM::IsRunningPrecompiledCode()) { - return false; - } - - if (main_source_file.empty()) { - return false; - } - - tonic::DartState::Scope scope(this); - - if (!Dart_IsNull(Dart_RootLibrary())) { - return false; - } - - auto& loader = file_loader(); - - if (!packages.empty()) { - auto packages_absolute_path = fml::paths::AbsolutePath(packages); - FML_DLOG(INFO) << "Loading from packages: " << packages_absolute_path; - if (!loader.LoadPackagesMap(packages_absolute_path)) { - return false; - } - } - - auto main_source_absolute_path = fml::paths::AbsolutePath(main_source_file); - FML_DLOG(INFO) << "Loading from source: " << main_source_absolute_path; - - if (tonic::LogIfError(loader.LoadScript(main_source_absolute_path))) { - return false; - } - - if (Dart_IsNull(Dart_RootLibrary())) { - return false; - } - - if (!MarkIsolateRunnable()) { - return false; - } - - child_isolate_preparer_ = [main_source_file, packages](DartIsolate* isolate) { - return isolate->PrepareForRunningFromSource(main_source_file, packages); + return isolate->PrepareForRunningFromKernel(mapping); }; phase_ = Phase::Ready; return true; @@ -608,22 +536,11 @@ Dart_Isolate DartIsolate::DartCreateAndStartServiceIsolate( return nullptr; } - // The engine never holds a strong reference to the VM service isolate. Since - // we are about to lose our last weak reference to it, start the VM service - // while we have this reference. - const bool isolate_snapshot_is_dart_2 = Dart_IsDart2Snapshot( - vm->GetIsolateSnapshot()->GetData()->GetSnapshotPointer()); - const bool is_preview_dart2 = - (vm->GetPlatformKernel().GetSize() > 0) || isolate_snapshot_is_dart_2; - const bool running_from_sources = - !DartVM::IsRunningPrecompiledCode() && !is_preview_dart2; - tonic::DartState::Scope scope(service_isolate); if (!DartServiceIsolate::Startup( settings.ipv6 ? "::1" : "127.0.0.1", // server IP address settings.observatory_port, // server observatory port tonic::DartState::HandleLibraryTag, // embedder library tag handler - running_from_sources, // running from source code false, // disable websocket origin check error // error (out) )) { @@ -727,39 +644,20 @@ DartIsolate::CreateDartVMAndEmbedderObjectPair( 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; + flags->use_dart_frontend = true; // Create the Dart VM isolate and give it the embedder object as the baton. - Dart_Isolate isolate = - (vm->GetPlatformKernel().GetSize() > 0) - ? Dart_CreateIsolateFromKernel( - advisory_script_uri, // - advisory_script_entrypoint, // - vm->GetPlatformKernel().GetMapping(), // - vm->GetPlatformKernel().GetSize(), // - flags, // - embedder_isolate.get(), // - error // - ) - : Dart_CreateIsolate( - advisory_script_uri, advisory_script_entrypoint, - (*embedder_isolate) - ->GetIsolateSnapshot() - ->GetData() - ->GetSnapshotPointer(), - (*embedder_isolate) - ->GetIsolateSnapshot() - ->GetInstructionsIfPresent(), - (*embedder_isolate)->GetSharedSnapshot()->GetDataIfPresent(), - (*embedder_isolate) - ->GetSharedSnapshot() - ->GetInstructionsIfPresent(), - flags, embedder_isolate.get(), error); + Dart_Isolate isolate = Dart_CreateIsolate( + advisory_script_uri, // + advisory_script_entrypoint, // + (*embedder_isolate) + ->GetIsolateSnapshot() + ->GetData() + ->GetSnapshotPointer(), + (*embedder_isolate)->GetIsolateSnapshot()->GetInstructionsIfPresent(), + (*embedder_isolate)->GetSharedSnapshot()->GetDataIfPresent(), + (*embedder_isolate)->GetSharedSnapshot()->GetInstructionsIfPresent(), + flags, embedder_isolate.get(), error); if (isolate == nullptr) { FML_DLOG(ERROR) << *error; diff --git a/runtime/dart_isolate.h b/runtime/dart_isolate.h index df9a9f66d1b46..f2167364effdd 100644 --- a/runtime/dart_isolate.h +++ b/runtime/dart_isolate.h @@ -68,13 +68,8 @@ class DartIsolate : public UIDartState { bool PrepareForRunningFromPrecompiledCode(); FML_WARN_UNUSED_RESULT - bool PrepareForRunningFromSnapshot( - std::shared_ptr snapshot, - bool last_piece = true); - - FML_WARN_UNUSED_RESULT - bool PrepareForRunningFromSource(const std::string& main_source_file, - const std::string& packages); + bool PrepareForRunningFromKernel(std::shared_ptr kernel, + bool last_piece = true); FML_WARN_UNUSED_RESULT bool Run(const std::string& entrypoint); @@ -96,12 +91,7 @@ class DartIsolate : public UIDartState { std::weak_ptr GetWeakIsolatePtr(); private: - bool LoadScriptSnapshot(std::shared_ptr mapping, - bool last_piece); - bool LoadKernelSnapshot(std::shared_ptr mapping, - bool last_piece); - bool LoadSnapshot(std::shared_ptr mapping, - bool last_piece); + bool LoadKernel(std::shared_ptr mapping, bool last_piece); class AutoFireClosure { public: diff --git a/runtime/dart_isolate_unittests.cc b/runtime/dart_isolate_unittests.cc index 02cbbaf8cf5f2..cb7797abdcb74 100644 --- a/runtime/dart_isolate_unittests.cc +++ b/runtime/dart_isolate_unittests.cc @@ -46,70 +46,4 @@ TEST_F(DartIsolateTest, RootIsolateCreationAndShutdown) { ASSERT_TRUE(root_isolate->Shutdown()); } -TEST_F(DartIsolateTest, IsolateCanAssociateSnapshot) { - Settings settings = {}; - settings.task_observer_add = [](intptr_t, fml::closure) {}; - settings.task_observer_remove = [](intptr_t) {}; - auto vm = DartVM::ForProcess(settings); - ASSERT_TRUE(vm); - TaskRunners task_runners(CURRENT_TEST_NAME, // - GetCurrentTaskRunner(), // - GetCurrentTaskRunner(), // - GetCurrentTaskRunner(), // - GetCurrentTaskRunner() // - ); - auto weak_isolate = DartIsolate::CreateRootIsolate( - vm.get(), // vm - vm->GetIsolateSnapshot(), // isolate snapshot - vm->GetSharedSnapshot(), // shared snapshot - std::move(task_runners), // task runners - nullptr, // window - {}, // resource context - nullptr, // unref qeueue - "main.dart", // advisory uri - "main" // advisory entrypoint - ); - auto root_isolate = weak_isolate.lock(); - ASSERT_TRUE(root_isolate); - ASSERT_EQ(root_isolate->GetPhase(), DartIsolate::Phase::LibrariesSetup); - ASSERT_TRUE(root_isolate->PrepareForRunningFromSource( - testing::GetFixturesPath() + std::string{"/simple_main.dart"}, "")); - ASSERT_EQ(root_isolate->GetPhase(), DartIsolate::Phase::Ready); - ASSERT_TRUE(root_isolate->Shutdown()); -} - -TEST_F(DartIsolateTest, CanResolveAndInvokeMethod) { - Settings settings = {}; - settings.task_observer_add = [](intptr_t, fml::closure) {}; - settings.task_observer_remove = [](intptr_t) {}; - auto vm = DartVM::ForProcess(settings); - ASSERT_TRUE(vm); - TaskRunners task_runners(CURRENT_TEST_NAME, // - GetCurrentTaskRunner(), // - GetCurrentTaskRunner(), // - GetCurrentTaskRunner(), // - GetCurrentTaskRunner() // - ); - auto weak_isolate = DartIsolate::CreateRootIsolate( - vm.get(), // vm - vm->GetIsolateSnapshot(), // isolate snapshot - vm->GetSharedSnapshot(), // shared snapshot - std::move(task_runners), // task runners - nullptr, // window - {}, // resource context - nullptr, // unref qeueue - "main.dart", // advisory uri - "main" // advisory entrypoint - ); - auto root_isolate = weak_isolate.lock(); - ASSERT_TRUE(root_isolate); - ASSERT_EQ(root_isolate->GetPhase(), DartIsolate::Phase::LibrariesSetup); - ASSERT_TRUE(root_isolate->PrepareForRunningFromSource( - testing::GetFixturesPath() + std::string{"/simple_main.dart"}, "")); - ASSERT_EQ(root_isolate->GetPhase(), DartIsolate::Phase::Ready); - ASSERT_TRUE(root_isolate->Run("simple_main")); - ASSERT_EQ(root_isolate->GetPhase(), DartIsolate::Phase::Running); - ASSERT_TRUE(root_isolate->Shutdown()); -} - } // namespace blink diff --git a/runtime/dart_service_isolate.cc b/runtime/dart_service_isolate.cc index d1a699869959a..05da4c48fc2dd 100644 --- a/runtime/dart_service_isolate.cc +++ b/runtime/dart_service_isolate.cc @@ -26,21 +26,11 @@ return false; \ } -#define kLibrarySourceNamePrefix "/vmservice" -static const char* kServiceIsolateScript = "vmservice_io.dart"; - -namespace flutter { -namespace runtime { -extern ResourcesEntry __flutter_embedded_service_isolate_resources_[]; -} -} // namespace flutter - namespace blink { namespace { static Dart_LibraryTagHandler g_embedder_tag_handler; static tonic::DartLibraryNatives* g_natives; -static EmbedderResources* g_resources; static std::string observatory_uri_; Dart_NativeFunction GetNativeFunction(Dart_Handle name, @@ -57,13 +47,6 @@ const uint8_t* GetSymbol(Dart_NativeFunction native_function) { } // namespace -void DartServiceIsolate::TriggerResourceLoad(Dart_NativeArguments args) { - Dart_Handle library = Dart_RootLibrary(); - FML_DCHECK(!Dart_IsError(library)); - Dart_Handle result = LoadResources(library); - FML_DCHECK(!Dart_IsError(result)); -} - void DartServiceIsolate::NotifyServerState(Dart_NativeArguments args) { Dart_Handle exception = nullptr; std::string uri = @@ -84,7 +67,6 @@ void DartServiceIsolate::Shutdown(Dart_NativeArguments args) { bool DartServiceIsolate::Startup(std::string server_ip, intptr_t server_port, Dart_LibraryTagHandler embedder_tag_handler, - bool running_from_sources, bool disable_origin_check, char** error) { Dart_Isolate isolate = Dart_CurrentIsolate(); @@ -103,36 +85,13 @@ bool DartServiceIsolate::Startup(std::string server_ip, }); } - if (!g_resources) { - g_resources = new EmbedderResources( - &flutter::runtime::__flutter_embedded_service_isolate_resources_[0]); - } - - Dart_Handle result; - - if (running_from_sources) { - // Use our own library tag handler when loading service isolate sources. - Dart_SetLibraryTagHandler(DartServiceIsolate::LibraryTagHandler); - // Load main script. - Dart_Handle library = LoadScript(kServiceIsolateScript); - FML_DCHECK(library != Dart_Null()); - SHUTDOWN_ON_ERROR(library); - // Setup native entry resolution. - result = Dart_SetNativeResolver(library, GetNativeFunction, GetSymbol); - - SHUTDOWN_ON_ERROR(result); - // Finalize loading. - result = Dart_FinalizeLoading(false); - SHUTDOWN_ON_ERROR(result); - } else { - Dart_Handle uri = Dart_NewStringFromCString("dart:vmservice_io"); - Dart_Handle library = Dart_LookupLibrary(uri); - SHUTDOWN_ON_ERROR(library); - result = Dart_SetRootLibrary(library); - SHUTDOWN_ON_ERROR(result); - result = Dart_SetNativeResolver(library, GetNativeFunction, GetSymbol); - SHUTDOWN_ON_ERROR(result); - } + Dart_Handle uri = Dart_NewStringFromCString("dart:vmservice_io"); + Dart_Handle library = Dart_LookupLibrary(uri); + SHUTDOWN_ON_ERROR(library); + Dart_Handle result = Dart_SetRootLibrary(library); + SHUTDOWN_ON_ERROR(result); + result = Dart_SetNativeResolver(library, GetNativeFunction, GetSymbol); + SHUTDOWN_ON_ERROR(result); // Make runnable. Dart_ExitScope(); @@ -146,7 +105,7 @@ bool DartServiceIsolate::Startup(std::string server_ip, Dart_EnterIsolate(isolate); Dart_EnterScope(); - Dart_Handle library = Dart_RootLibrary(); + library = Dart_RootLibrary(); SHUTDOWN_ON_ERROR(library); // Set the HTTP server's ip. @@ -174,115 +133,4 @@ bool DartServiceIsolate::Startup(std::string server_ip, return true; } -Dart_Handle DartServiceIsolate::GetSource(const char* name) { - const intptr_t kBufferSize = 512; - char buffer[kBufferSize]; - snprintf(&buffer[0], kBufferSize - 1, "%s/%s", kLibrarySourceNamePrefix, - name); - const char* vmservice_source = NULL; - int r = g_resources->ResourceLookup(buffer, &vmservice_source); - FML_DCHECK(r != EmbedderResources::kNoSuchInstance); - return Dart_NewStringFromCString(vmservice_source); -} - -Dart_Handle DartServiceIsolate::LoadScript(const char* name) { - Dart_Handle url = Dart_NewStringFromCString("dart:vmservice_io"); - Dart_Handle source = GetSource(name); - return Dart_LoadScript(url, Dart_Null(), source, 0, 0); -} - -Dart_Handle DartServiceIsolate::LoadSource(Dart_Handle library, - const char* name) { - Dart_Handle url = Dart_NewStringFromCString(name); - Dart_Handle source = GetSource(name); - return Dart_LoadSource(library, url, Dart_Null(), source, 0, 0); -} - -Dart_Handle DartServiceIsolate::LoadResource(Dart_Handle library, - const char* resource_name) { - // Prepare for invoke call. - Dart_Handle name = Dart_NewStringFromCString(resource_name); - RETURN_ERROR_HANDLE(name); - const char* data_buffer = NULL; - int data_buffer_length = - g_resources->ResourceLookup(resource_name, &data_buffer); - FML_DCHECK(data_buffer_length != EmbedderResources::kNoSuchInstance); - Dart_Handle data_list = - Dart_NewTypedData(Dart_TypedData_kUint8, data_buffer_length); - RETURN_ERROR_HANDLE(data_list); - Dart_TypedData_Type type = Dart_TypedData_kInvalid; - void* data_list_buffer = NULL; - intptr_t data_list_buffer_length = 0; - Dart_Handle result = Dart_TypedDataAcquireData( - data_list, &type, &data_list_buffer, &data_list_buffer_length); - RETURN_ERROR_HANDLE(result); - FML_DCHECK(data_buffer_length == data_list_buffer_length); - FML_DCHECK(data_list_buffer != NULL); - FML_DCHECK(type = Dart_TypedData_kUint8); - memmove(data_list_buffer, &data_buffer[0], data_buffer_length); - result = Dart_TypedDataReleaseData(data_list); - RETURN_ERROR_HANDLE(result); - - // Make invoke call. - const intptr_t kNumArgs = 2; - Dart_Handle args[kNumArgs] = {name, data_list}; - result = Dart_Invoke(library, Dart_NewStringFromCString("_addResource"), - kNumArgs, args); - return result; -} - -Dart_Handle DartServiceIsolate::LoadResources(Dart_Handle library) { - Dart_Handle result = Dart_Null(); - intptr_t prefixLen = strlen(kLibrarySourceNamePrefix); - for (intptr_t i = 0; g_resources->Path(i) != NULL; i++) { - const char* path = g_resources->Path(i); - // If it doesn't begin with kLibrarySourceNamePrefix it is a frontend - // resource. - if (strncmp(path, kLibrarySourceNamePrefix, prefixLen) != 0) { - result = LoadResource(library, path); - if (Dart_IsError(result)) { - break; - } - } - } - return result; -} - -Dart_Handle DartServiceIsolate::LibraryTagHandler(Dart_LibraryTag tag, - Dart_Handle library, - Dart_Handle url) { - if (!Dart_IsLibrary(library)) { - return Dart_NewApiError("not a library"); - } - if (!Dart_IsString(url)) { - return Dart_NewApiError("url is not a string"); - } - const char* url_string = NULL; - Dart_Handle result = Dart_StringToCString(url, &url_string); - if (Dart_IsError(result)) { - return result; - } - Dart_Handle library_url = Dart_LibraryUrl(library); - const char* library_url_string = NULL; - result = Dart_StringToCString(library_url, &library_url_string); - if (Dart_IsError(result)) { - return result; - } - if (tag == Dart_kImportTag) { - // Embedder handles all requests for external libraries. - return g_embedder_tag_handler(tag, library, url); - } - FML_DCHECK((tag == Dart_kSourceTag) || (tag == Dart_kCanonicalizeUrl)); - if (tag == Dart_kCanonicalizeUrl) { - // url is already canonicalized. - return url; - } - // Get source from builtin resources. - Dart_Handle source = GetSource(url_string); - if (Dart_IsError(source)) { - return source; - } - return Dart_LoadSource(library, url, Dart_Null(), source, 0, 0); -} - } // namespace blink diff --git a/runtime/dart_service_isolate.h b/runtime/dart_service_isolate.h index 59a02e2e9d495..3d672dc83bb4c 100644 --- a/runtime/dart_service_isolate.h +++ b/runtime/dart_service_isolate.h @@ -16,7 +16,6 @@ class DartServiceIsolate { static bool Startup(std::string server_ip, intptr_t server_port, Dart_LibraryTagHandler embedder_tag_handler, - bool running_from_sources, bool disable_origin_check, char** error); @@ -24,21 +23,8 @@ class DartServiceIsolate { private: // Native entries. - static void TriggerResourceLoad(Dart_NativeArguments args); static void NotifyServerState(Dart_NativeArguments args); static void Shutdown(Dart_NativeArguments args); - - // Script loading. - static Dart_Handle GetSource(const char* name); - static Dart_Handle LoadScript(const char* name); - static Dart_Handle LoadSource(Dart_Handle library, const char* name); - static Dart_Handle LibraryTagHandler(Dart_LibraryTag tag, - Dart_Handle library, - Dart_Handle url); - - // Observatory resource loading. - static Dart_Handle LoadResources(Dart_Handle library); - static Dart_Handle LoadResource(Dart_Handle library, const char* name); }; } // namespace blink diff --git a/runtime/dart_vm.cc b/runtime/dart_vm.cc index b263914538217..4fa0d3a3ea1ba 100644 --- a/runtime/dart_vm.cc +++ b/runtime/dart_vm.cc @@ -310,8 +310,6 @@ DartVM::DartVM(const Settings& settings, vm_snapshot_(std::move(vm_snapshot)), isolate_snapshot_(std::move(isolate_snapshot)), shared_snapshot_(std::move(shared_snapshot)), - platform_kernel_mapping_( - std::make_unique(settings.platform_kernel_path)), weak_factory_(this) { TRACE_EVENT0("flutter", "DartVMInitializer"); FML_DLOG(INFO) << "Attempting Dart VM launch for mode: " @@ -368,17 +366,11 @@ DartVM::DartVM(const Settings& settings, arraysize(kDartWriteProtectCodeArgs)); #endif - const bool isolate_snapshot_is_dart_2 = - Dart_IsDart2Snapshot(isolate_snapshot_->GetData()->GetSnapshotPointer()); - const bool is_preview_dart2 = - (platform_kernel_mapping_->GetSize() > 0) || isolate_snapshot_is_dart_2; + Dart_IsDart2Snapshot(isolate_snapshot_->GetData()->GetSnapshotPointer()); FML_DLOG(INFO) << "Dart 2 " << (is_preview_dart2 ? "is" : "is NOT") - << " enabled. Platform kernel: " - << static_cast(platform_kernel_mapping_->GetSize() > 0) - << " Isolate Snapshot is Dart 2: " - << isolate_snapshot_is_dart_2; + << " enabled."; if (is_preview_dart2) { PushBackAll(&args, kDartStrongModeArgs, arraysize(kDartStrongModeArgs)); @@ -485,10 +477,6 @@ const Settings& DartVM::GetSettings() const { return settings_; } -const fml::Mapping& DartVM::GetPlatformKernel() const { - return *platform_kernel_mapping_.get(); -} - const DartSnapshot& DartVM::GetVMSnapshot() const { return *vm_snapshot_.get(); } diff --git a/runtime/dart_vm.h b/runtime/dart_vm.h index ebb41edadb479..b853f026c328f 100644 --- a/runtime/dart_vm.h +++ b/runtime/dart_vm.h @@ -42,8 +42,6 @@ class DartVM : public fml::RefCountedThreadSafe { const Settings& GetSettings() const; - const fml::Mapping& GetPlatformKernel() const; - const DartSnapshot& GetVMSnapshot() const; IsolateNameServer* GetIsolateNameServer(); @@ -62,7 +60,6 @@ class DartVM : public fml::RefCountedThreadSafe { IsolateNameServer isolate_name_server_; const fml::RefPtr isolate_snapshot_; const fml::RefPtr shared_snapshot_; - std::unique_ptr platform_kernel_mapping_; ServiceProtocol service_protocol_; fml::WeakPtrFactory weak_factory_; diff --git a/runtime/dart_vm_unittests.cc b/runtime/dart_vm_unittests.cc index d0e247836410b..94d5dadaaec1f 100644 --- a/runtime/dart_vm_unittests.cc +++ b/runtime/dart_vm_unittests.cc @@ -15,7 +15,6 @@ TEST(DartVM, SimpleInitialization) { ASSERT_TRUE(vm); ASSERT_EQ(vm, DartVM::ForProcess(settings)); ASSERT_FALSE(DartVM::IsRunningPrecompiledCode()); - ASSERT_EQ(vm->GetPlatformKernel().GetSize(), 0u); } TEST(DartVM, SimpleIsolateNameServer) { diff --git a/shell/common/engine.cc b/shell/common/engine.cc index 1b9d3657b6ece..b79dbfae33555 100644 --- a/shell/common/engine.cc +++ b/shell/common/engine.cc @@ -47,7 +47,6 @@ Engine::Engine(Delegate& delegate, : delegate_(delegate), settings_(std::move(settings)), animator_(std::move(animator)), - load_script_error_(tonic::kNoError), activity_running_(false), have_surface_(false), weak_factory_(this) { @@ -205,10 +204,6 @@ tonic::DartErrorHandleType Engine::GetUIIsolateLastError() { return runtime_controller_->GetLastError(); } -tonic::DartErrorHandleType Engine::GetLoadScriptError() { - return load_script_error_; -} - void Engine::OnOutputSurfaceCreated() { have_surface_ = true; StartAnimatorIfPossible(); diff --git a/shell/common/engine.h b/shell/common/engine.h index 259f73514b67d..f35b9ba421113 100644 --- a/shell/common/engine.h +++ b/shell/common/engine.h @@ -79,8 +79,6 @@ class Engine final : public blink::RuntimeDelegate { tonic::DartErrorHandleType GetUIIsolateLastError(); - tonic::DartErrorHandleType GetLoadScriptError(); - std::pair GetUIIsolateReturnCode(); void OnOutputSurfaceCreated(); @@ -111,7 +109,6 @@ class Engine final : public blink::RuntimeDelegate { const blink::Settings settings_; std::unique_ptr animator_; std::unique_ptr runtime_controller_; - tonic::DartErrorHandleType load_script_error_; std::string initial_route_; blink::ViewportMetrics viewport_metrics_; fml::RefPtr asset_manager_; diff --git a/shell/common/isolate_configuration.cc b/shell/common/isolate_configuration.cc index 66dd53fb1b59c..57c38bef9f8d8 100644 --- a/shell/common/isolate_configuration.cc +++ b/shell/common/isolate_configuration.cc @@ -39,45 +39,23 @@ class AppSnapshotIsolateConfiguration final : public IsolateConfiguration { FML_DISALLOW_COPY_AND_ASSIGN(AppSnapshotIsolateConfiguration); }; -class SnapshotIsolateConfiguration : public IsolateConfiguration { +class KernelIsolateConfiguration : public IsolateConfiguration { public: - SnapshotIsolateConfiguration(std::unique_ptr snapshot) - : snapshot_(std::move(snapshot)) {} + KernelIsolateConfiguration(std::unique_ptr kernel) + : kernel_(std::move(kernel)) {} // |shell::IsolateConfiguration| bool DoPrepareIsolate(blink::DartIsolate& isolate) override { if (blink::DartVM::IsRunningPrecompiledCode()) { return false; } - return isolate.PrepareForRunningFromSnapshot(std::move(snapshot_)); + return isolate.PrepareForRunningFromKernel(std::move(kernel_)); } private: - std::unique_ptr snapshot_; + std::unique_ptr kernel_; - FML_DISALLOW_COPY_AND_ASSIGN(SnapshotIsolateConfiguration); -}; - -class SourceIsolateConfiguration final : public IsolateConfiguration { - public: - SourceIsolateConfiguration(std::string main_path, std::string packages_path) - : main_path_(std::move(main_path)), - packages_path_(std::move(packages_path)) {} - - // |shell::IsolateConfiguration| - bool DoPrepareIsolate(blink::DartIsolate& isolate) override { - if (blink::DartVM::IsRunningPrecompiledCode()) { - return false; - } - return isolate.PrepareForRunningFromSource(std::move(main_path_), - std::move(packages_path_)); - } - - private: - std::string main_path_; - std::string packages_path_; - - FML_DISALLOW_COPY_AND_ASSIGN(SourceIsolateConfiguration); + FML_DISALLOW_COPY_AND_ASSIGN(KernelIsolateConfiguration); }; class KernelListIsolateConfiguration final : public IsolateConfiguration { @@ -94,8 +72,8 @@ class KernelListIsolateConfiguration final : public IsolateConfiguration { for (size_t i = 0; i < kernel_pieces_.size(); i++) { bool last_piece = i + 1 == kernel_pieces_.size(); - if (!isolate.PrepareForRunningFromSnapshot(std::move(kernel_pieces_[i]), - last_piece)) { + if (!isolate.PrepareForRunningFromKernel(std::move(kernel_pieces_[i]), + last_piece)) { return false; } } @@ -117,30 +95,12 @@ std::unique_ptr IsolateConfiguration::InferFromSettings( return CreateForAppSnapshot(); } - // Run from sources. - { - const auto& main = settings.main_dart_file_path; - const auto& packages = settings.packages_file_path; - if (main.size() != 0 && packages.size() != 0) { - return CreateForSource(std::move(main), std::move(packages)); - } - } - // Running from kernel snapshot. if (asset_manager) { std::unique_ptr kernel = asset_manager->GetAsMapping(settings.application_kernel_asset); if (kernel) { - return CreateForSnapshot(std::move(kernel)); - } - } - - // Running from script snapshot. - if (asset_manager) { - std::unique_ptr script_snapshot = - asset_manager->GetAsMapping(settings.script_snapshot_path); - if (script_snapshot) { - return CreateForSnapshot(std::move(script_snapshot)); + return CreateForKernel(std::move(kernel)); } } @@ -189,16 +149,9 @@ IsolateConfiguration::CreateForAppSnapshot() { return std::make_unique(); } -std::unique_ptr IsolateConfiguration::CreateForSnapshot( - std::unique_ptr snapshot) { - return std::make_unique(std::move(snapshot)); -} - -std::unique_ptr IsolateConfiguration::CreateForSource( - std::string main_path, - std::string packages_path) { - return std::make_unique(std::move(main_path), - std::move(packages_path)); +std::unique_ptr IsolateConfiguration::CreateForKernel( + std::unique_ptr kernel) { + return std::make_unique(std::move(kernel)); } std::unique_ptr IsolateConfiguration::CreateForKernelList( diff --git a/shell/common/isolate_configuration.h b/shell/common/isolate_configuration.h index ba8752273d6de..7dd54ccf3b3b7 100644 --- a/shell/common/isolate_configuration.h +++ b/shell/common/isolate_configuration.h @@ -26,12 +26,8 @@ class IsolateConfiguration { static std::unique_ptr CreateForAppSnapshot(); - static std::unique_ptr CreateForSnapshot( - std::unique_ptr snapshot); - - static std::unique_ptr CreateForSource( - std::string main_path, - std::string packages_path); + static std::unique_ptr CreateForKernel( + std::unique_ptr kernel); static std::unique_ptr CreateForKernelList( std::vector> kernel_pieces); diff --git a/shell/common/shell.cc b/shell/common/shell.cc index 59272e11c0539..7d434cb055be4 100644 --- a/shell/common/shell.cc +++ b/shell/common/shell.cc @@ -875,12 +875,8 @@ bool Shell::OnServiceProtocolRunInView( auto main_script_file_mapping = std::make_unique(main_script_path, false); - auto isolate_configuration = - blink::DartVM::IsKernelMapping(main_script_file_mapping.get()) - ? IsolateConfiguration::CreateForSnapshot( - std::move(main_script_file_mapping)) - : IsolateConfiguration::CreateForSource(main_script_path, - packages_path); + auto isolate_configuration = IsolateConfiguration::CreateForKernel( + std::move(main_script_file_mapping)); RunConfiguration configuration(std::move(isolate_configuration)); diff --git a/shell/common/switches.cc b/shell/common/switches.cc index 80ae36a7e5776..98f0bb353015f 100644 --- a/shell/common/switches.cc +++ b/shell/common/switches.cc @@ -170,9 +170,6 @@ blink::Settings SettingsFromCommandLine(const fml::CommandLine& command_line) { command_line.GetOptionValue(FlagForSwitch(Switch::FlutterAssetsDir), &settings.assets_path); - command_line.GetOptionValue(FlagForSwitch(Switch::Snapshot), - &settings.script_snapshot_path); - command_line.GetOptionValue(FlagForSwitch(Switch::MainDartFile), &settings.main_dart_file_path); diff --git a/shell/common/switches.h b/shell/common/switches.h index 6bae9047e0e3d..644b02f2cbce5 100644 --- a/shell/common/switches.h +++ b/shell/common/switches.h @@ -93,7 +93,6 @@ DEF_SWITCH(Help, "help", "Display this help text.") DEF_SWITCH(LogTag, "log-tag", "Tag associated with log messages.") DEF_SWITCH(MainDartFile, "dart-main", "The path to the main Dart file.") DEF_SWITCH(Packages, "packages", "Specify the path to the packages.") -DEF_SWITCH(Snapshot, "snapshot-blob", "Specify the path to the snapshot blob") DEF_SWITCH(StartPaused, "start-paused", "Start the application paused in the Dart debugger.") diff --git a/shell/platform/android/flutter_main.cc b/shell/platform/android/flutter_main.cc index b8931e6e46753..0bcf75d76feca 100644 --- a/shell/platform/android/flutter_main.cc +++ b/shell/platform/android/flutter_main.cc @@ -66,16 +66,11 @@ void FlutterMain::Init(JNIEnv* env, if (!blink::DartVM::IsRunningPrecompiledCode()) { // Check to see if the appropriate kernel files are present and configure // settings accordingly. - auto platform_kernel_path = - fml::paths::JoinPaths({settings.assets_path, "platform_strong.dill"}); auto application_kernel_path = fml::paths::JoinPaths({settings.assets_path, "kernel_blob.bin"}); if (fml::IsFile(application_kernel_path)) { settings.application_kernel_asset = application_kernel_path; - if (fml::IsFile(platform_kernel_path)) { - settings.platform_kernel_path = platform_kernel_path; - } } } diff --git a/shell/platform/android/io/flutter/view/FlutterMain.java b/shell/platform/android/io/flutter/view/FlutterMain.java index 49d3b01707633..198bcade69ae8 100644 --- a/shell/platform/android/io/flutter/view/FlutterMain.java +++ b/shell/platform/android/io/flutter/view/FlutterMain.java @@ -31,7 +31,6 @@ public class FlutterMain { private static final String AOT_ISOLATE_SNAPSHOT_DATA_KEY = "isolate-snapshot-data"; private static final String AOT_ISOLATE_SNAPSHOT_INSTR_KEY = "isolate-snapshot-instr"; private static final String FLX_KEY = "flx"; - private static final String SNAPSHOT_BLOB_KEY = "snapshot-blob"; private static final String FLUTTER_ASSETS_DIR_KEY = "flutter-assets-dir"; // XML Attribute keys supported in AndroidManifest.xml @@ -47,8 +46,6 @@ public class FlutterMain { FlutterMain.class.getName() + '.' + AOT_ISOLATE_SNAPSHOT_INSTR_KEY; public static final String PUBLIC_FLX_KEY = FlutterMain.class.getName() + '.' + FLX_KEY; - public static final String PUBLIC_SNAPSHOT_BLOB_KEY = - FlutterMain.class.getName() + '.' + SNAPSHOT_BLOB_KEY; public static final String PUBLIC_FLUTTER_ASSETS_DIR_KEY = FlutterMain.class.getName() + '.' + FLUTTER_ASSETS_DIR_KEY; @@ -59,9 +56,7 @@ public class FlutterMain { private static final String DEFAULT_AOT_ISOLATE_SNAPSHOT_DATA = "isolate_snapshot_data"; private static final String DEFAULT_AOT_ISOLATE_SNAPSHOT_INSTR = "isolate_snapshot_instr"; private static final String DEFAULT_FLX = "app.flx"; - private static final String DEFAULT_SNAPSHOT_BLOB = "snapshot_blob.bin"; private static final String DEFAULT_KERNEL_BLOB = "kernel_blob.bin"; - private static final String DEFAULT_PLATFORM_DILL = "platform_strong.dill"; private static final String DEFAULT_FLUTTER_ASSETS_DIR = "flutter_assets"; // Assets that are shared among all Flutter apps within an APK. @@ -79,7 +74,6 @@ private static String fromFlutterAssets(String filePath) { private static String sAotIsolateSnapshotData = DEFAULT_AOT_ISOLATE_SNAPSHOT_DATA; private static String sAotIsolateSnapshotInstr = DEFAULT_AOT_ISOLATE_SNAPSHOT_INSTR; private static String sFlx = DEFAULT_FLX; - private static String sSnapshotBlob = DEFAULT_SNAPSHOT_BLOB; private static String sFlutterAssetsDir = DEFAULT_FLUTTER_ASSETS_DIR; private static boolean sInitialized = false; @@ -248,7 +242,6 @@ private static void initConfig(Context applicationContext) { sAotIsolateSnapshotData = metadata.getString(PUBLIC_AOT_ISOLATE_SNAPSHOT_DATA_KEY, DEFAULT_AOT_ISOLATE_SNAPSHOT_DATA); sAotIsolateSnapshotInstr = metadata.getString(PUBLIC_AOT_ISOLATE_SNAPSHOT_INSTR_KEY, DEFAULT_AOT_ISOLATE_SNAPSHOT_INSTR); sFlx = metadata.getString(PUBLIC_FLX_KEY, DEFAULT_FLX); - sSnapshotBlob = metadata.getString(PUBLIC_SNAPSHOT_BLOB_KEY, DEFAULT_SNAPSHOT_BLOB); sFlutterAssetsDir = metadata.getString(PUBLIC_FLUTTER_ASSETS_DIR_KEY, DEFAULT_FLUTTER_ASSETS_DIR); } } catch (PackageManager.NameNotFoundException e) { @@ -268,13 +261,11 @@ private static void initResources(Context applicationContext) { sResourceExtractor .addResource(fromFlutterAssets(sFlx)) - .addResource(fromFlutterAssets(sSnapshotBlob)) .addResource(fromFlutterAssets(sAotVmSnapshotData)) .addResource(fromFlutterAssets(sAotVmSnapshotInstr)) .addResource(fromFlutterAssets(sAotIsolateSnapshotData)) .addResource(fromFlutterAssets(sAotIsolateSnapshotInstr)) - .addResource(fromFlutterAssets(DEFAULT_KERNEL_BLOB)) - .addResource(fromFlutterAssets(DEFAULT_PLATFORM_DILL)); + .addResource(fromFlutterAssets(DEFAULT_KERNEL_BLOB)); if (sIsPrecompiledAsSharedLibrary) { sResourceExtractor .addResource(sAotSharedLibraryPath); @@ -283,8 +274,7 @@ private static void initResources(Context applicationContext) { .addResource(sAotVmSnapshotData) .addResource(sAotVmSnapshotInstr) .addResource(sAotIsolateSnapshotData) - .addResource(sAotIsolateSnapshotInstr) - .addResource(sSnapshotBlob); + .addResource(sAotIsolateSnapshotInstr); } sResourceExtractor.start(); } diff --git a/shell/platform/android/platform_view_android_jni.cc b/shell/platform/android/platform_view_android_jni.cc index 6dd4b9ab3350a..d93f9357144a6 100644 --- a/shell/platform/android/platform_view_android_jni.cc +++ b/shell/platform/android/platform_view_android_jni.cc @@ -217,10 +217,10 @@ std::unique_ptr CreateIsolateConfiguration( return IsolateConfiguration::CreateForKernelList(std::move(kernels)); } if (blob) { - return IsolateConfiguration::CreateForSnapshot(std::move(blob)); + return IsolateConfiguration::CreateForKernel(std::move(blob)); } if (delta) { - return IsolateConfiguration::CreateForSnapshot(std::move(delta)); + return IsolateConfiguration::CreateForKernel(std::move(delta)); } return nullptr; }; @@ -228,9 +228,6 @@ std::unique_ptr CreateIsolateConfiguration( if (auto kernel = configuration_from_blob("kernel_blob.bin")) { return kernel; } - if (auto script = configuration_from_blob("snapshot_blob.bin")) { - return script; - } // This happens when starting isolate directly from CoreJIT snapshot. return IsolateConfiguration::CreateForAppSnapshot(); diff --git a/shell/platform/darwin/ios/framework/Source/FlutterDartProject.mm b/shell/platform/darwin/ios/framework/Source/FlutterDartProject.mm index 64eb73650dcc1..f5d5d80dfe41a 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterDartProject.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterDartProject.mm @@ -15,8 +15,6 @@ #include "flutter/shell/platform/darwin/common/command_line.h" #include "flutter/shell/platform/darwin/ios/framework/Headers/FlutterViewController.h" -static const char* kScriptSnapshotFileName = "snapshot_blob.bin"; -static const char* kVMKernelSnapshotFileName = "platform_strong.dill"; static const char* kApplicationKernelSnapshotFileName = "kernel_blob.bin"; static blink::Settings DefaultSettingsForProcess(NSBundle* bundle = nil) { @@ -83,8 +81,8 @@ // In case the application bundle is still not specified, look for the App.framework in the // Frameworks directory. if (settings.application_library_path.size() == 0) { - NSString* applicationFrameworkPath = - [mainBundle pathForResource:@"Frameworks/App.framework" ofType:@""]; + NSString* applicationFrameworkPath = [mainBundle pathForResource:@"Frameworks/App.framework" + ofType:@""]; if (applicationFrameworkPath.length > 0) { NSString* executablePath = [NSBundle bundleWithPath:applicationFrameworkPath].executablePath; @@ -106,25 +104,6 @@ if (!blink::DartVM::IsRunningPrecompiledCode()) { // Looking for the various script and kernel snapshot buffers only makes sense if we have a // VM that can use these buffers. - { - // Check if there is a script snapshot in the assets directory we could potentially use. - NSURL* scriptSnapshotURL = [NSURL URLWithString:@(kScriptSnapshotFileName) - relativeToURL:[NSURL fileURLWithPath:assetsPath]]; - if ([[NSFileManager defaultManager] fileExistsAtPath:scriptSnapshotURL.path]) { - settings.script_snapshot_path = scriptSnapshotURL.path.UTF8String; - } - } - - { - // Check if there is a VM kernel snapshot in the assets directory we could potentially - // use. - NSURL* vmKernelSnapshotURL = [NSURL URLWithString:@(kVMKernelSnapshotFileName) - relativeToURL:[NSURL fileURLWithPath:assetsPath]]; - if ([[NSFileManager defaultManager] fileExistsAtPath:vmKernelSnapshotURL.path]) { - settings.platform_kernel_path = vmKernelSnapshotURL.path.UTF8String; - } - } - { // Check if there is an application kernel snapshot in the assets directory we could // potentially use. @@ -196,12 +175,6 @@ - (instancetype)initWithFlutterAssetsWithScriptSnapshot:(NSURL*)flutterAssetsURL if (flutterAssetsURL != nil && [[NSFileManager defaultManager] fileExistsAtPath:flutterAssetsURL.path]) { _settings.assets_path = flutterAssetsURL.path.UTF8String; - - NSURL* scriptSnapshotPath = - [NSURL URLWithString:@(kScriptSnapshotFileName) relativeToURL:flutterAssetsURL]; - if ([[NSFileManager defaultManager] fileExistsAtPath:scriptSnapshotPath.path]) { - _settings.script_snapshot_path = scriptSnapshotPath.path.UTF8String; - } } } diff --git a/shell/platform/embedder/embedder.cc b/shell/platform/embedder/embedder.cc index bd685a86b6876..c4df169639aec 100644 --- a/shell/platform/embedder/embedder.cc +++ b/shell/platform/embedder/embedder.cc @@ -268,16 +268,11 @@ FlutterResult FlutterEngineRun(size_t version, // Check whether the assets path contains Dart 2 kernel assets. const std::string kApplicationKernelSnapshotFileName = "kernel_blob.bin"; - std::string platform_kernel_path = - fml::paths::JoinPaths({settings.assets_path, "platform_strong.dill"}); std::string application_kernel_path = fml::paths::JoinPaths( {settings.assets_path, kApplicationKernelSnapshotFileName}); if (fml::IsFile(application_kernel_path)) { // Run from a kernel snapshot. - settings.platform_kernel_path = platform_kernel_path; - if (fml::IsFile(platform_kernel_path)) { - settings.application_kernel_asset = kApplicationKernelSnapshotFileName; - } + settings.application_kernel_asset = kApplicationKernelSnapshotFileName; } else { // Run from a main Dart file. settings.main_dart_file_path = args->main_path; diff --git a/shell/testing/tester_main.cc b/shell/testing/tester_main.cc index 274ef7bb64a6c..4e10dab16f25c 100644 --- a/shell/testing/tester_main.cc +++ b/shell/testing/tester_main.cc @@ -133,11 +133,7 @@ int RunTester(const blink::Settings& settings, bool run_forever) { fml::paths::AbsolutePath(settings.main_dart_file_path), false); auto isolate_configuration = - blink::DartVM::IsKernelMapping(main_dart_file_mapping.get()) - ? IsolateConfiguration::CreateForSnapshot( - std::move(main_dart_file_mapping)) - : IsolateConfiguration::CreateForSource(settings.main_dart_file_path, - settings.packages_file_path); + IsolateConfiguration::CreateForKernel(std::move(main_dart_file_mapping)); if (!isolate_configuration) { FML_LOG(ERROR) << "Could create isolate configuration."; @@ -242,9 +238,6 @@ int main(int argc, char* argv[]) { settings.icu_data_path = "icudtl.dat"; - settings.platform_kernel_path = - fml::paths::JoinPaths({settings.assets_path, "platform_strong.dill"}); - // The tools that read logs get confused if there is a log tag specified. settings.log_tag = "";