From 800ea0a40397d53311715e0de94f0340195bfcea Mon Sep 17 00:00:00 2001 From: Chinmay Garde Date: Wed, 3 Apr 2019 17:08:56 -0700 Subject: [PATCH] Revert "Enable shutting down all root isolates in a VM. (#8402)" (#8431) This reverts commit b59c4436ce9fb8aa09bad6eb5ca729350a3ab272. --- ci/licenses_golden/licenses_flutter | 1 - common/settings.h | 8 +- runtime/BUILD.gn | 39 +---- runtime/dart_isolate.cc | 71 ++------- runtime/dart_isolate.h | 17 --- runtime/dart_lifecycle_unittests.cc | 142 ------------------ runtime/dart_vm.cc | 51 ------- runtime/dart_vm.h | 14 -- runtime/dart_vm_lifecycle.cc | 5 - runtime/dart_vm_lifecycle.h | 10 -- runtime/fixtures/simple_main.dart | 4 - runtime/runtime_test.cc | 7 - shell/common/isolate_configuration.cc | 30 ++-- shell/common/isolate_configuration.h | 10 +- .../android/platform_view_android_jni.cc | 2 +- 15 files changed, 39 insertions(+), 372 deletions(-) delete mode 100644 runtime/dart_lifecycle_unittests.cc diff --git a/ci/licenses_golden/licenses_flutter b/ci/licenses_golden/licenses_flutter index 5715a8445f803..312e6c329ab71 100644 --- a/ci/licenses_golden/licenses_flutter +++ b/ci/licenses_golden/licenses_flutter @@ -374,7 +374,6 @@ FILE: ../../../flutter/lib/ui/window/window.h FILE: ../../../flutter/runtime/dart_isolate.cc FILE: ../../../flutter/runtime/dart_isolate.h FILE: ../../../flutter/runtime/dart_isolate_unittests.cc -FILE: ../../../flutter/runtime/dart_lifecycle_unittests.cc FILE: ../../../flutter/runtime/dart_service_isolate.cc FILE: ../../../flutter/runtime/dart_service_isolate.h FILE: ../../../flutter/runtime/dart_service_isolate_unittests.cc diff --git a/common/settings.h b/common/settings.h index ff0315f8fc001..40b647de1f431 100644 --- a/common/settings.h +++ b/common/settings.h @@ -29,8 +29,6 @@ using UnhandledExceptionCallback = // callback that generates the mapping from these paths. // https://github.com/flutter/flutter/issues/26783 using MappingCallback = std::function(void)>; -using MappingsCallback = - std::function>(void)>; struct Settings { Settings(); @@ -55,10 +53,8 @@ struct Settings { MappingCallback dart_library_sources_kernel; std::string application_library_path; - - std::string application_kernel_asset; // deprecated - std::string application_kernel_list_asset; // deprecated - MappingsCallback application_kernels; + std::string application_kernel_asset; + std::string application_kernel_list_asset; std::string temp_directory_path; std::vector dart_flags; diff --git a/runtime/BUILD.gn b/runtime/BUILD.gn index 4ae61ac3b46e0..a906e589c223f 100644 --- a/runtime/BUILD.gn +++ b/runtime/BUILD.gn @@ -101,17 +101,18 @@ test_fixtures("runtime_fixtures") { fixtures = [ "fixtures/simple_main.dart" ] } -source_set("runtime_unittests_common") { - visibility = [ ":*" ] - +executable("runtime_unittests") { testonly = true sources = [ + "dart_isolate_unittests.cc", + "dart_service_isolate_unittests.cc", + "dart_vm_unittests.cc", "runtime_test.cc", "runtime_test.h", ] - public_deps = [ + deps = [ ":libdart", ":runtime", ":runtime_fixtures", @@ -123,36 +124,6 @@ source_set("runtime_unittests_common") { "//third_party/skia", "//third_party/tonic", ] -} - -executable("runtime_unittests") { - testonly = true - - sources = [ - "dart_isolate_unittests.cc", - "dart_service_isolate_unittests.cc", - "dart_vm_unittests.cc", - ] - - deps = [ - ":runtime_unittests_common", - ] - - if (is_linux) { - ldflags = [ "-rdynamic" ] - } -} - -executable("runtime_lifecycle_unittests") { - testonly = true - - sources = [ - "dart_lifecycle_unittests.cc", - ] - - deps = [ - ":runtime_unittests_common", - ] if (is_linux) { ldflags = [ "-rdynamic" ] diff --git a/runtime/dart_isolate.cc b/runtime/dart_isolate.cc index 91cd8bb5dd4aa..46df151f40b0e 100644 --- a/runtime/dart_isolate.cc +++ b/runtime/dart_isolate.cc @@ -162,8 +162,17 @@ bool DartIsolate::Initialize(Dart_Isolate dart_isolate, bool is_root_isolate) { tonic::DartIsolateScope scope(isolate()); - SetMessageHandlingTaskRunner(GetTaskRunners().GetUITaskRunner(), - is_root_isolate); + if (is_root_isolate) { + if (auto task_runner = GetTaskRunners().GetUITaskRunner()) { + // Isolates may not have any particular thread affinity. Only initialize + // the task dispatcher if a task runner is explicitly specified. + tonic::DartMessageHandler::TaskDispatcher dispatcher = + [task_runner](std::function task) { + task_runner->PostTask(task); + }; + message_handler().Initialize(dispatcher); + } + } if (tonic::LogIfError( Dart_SetLibraryTagHandler(tonic::DartState::HandleLibraryTag))) { @@ -178,23 +187,6 @@ bool DartIsolate::Initialize(Dart_Isolate dart_isolate, bool is_root_isolate) { return true; } -fml::RefPtr DartIsolate::GetMessageHandlingTaskRunner() const { - return message_handling_task_runner_; -} - -void DartIsolate::SetMessageHandlingTaskRunner( - fml::RefPtr runner, - bool is_root_isolate) { - if (!is_root_isolate || !runner) { - return; - } - - message_handling_task_runner_ = runner; - - message_handler().Initialize( - [runner](std::function task) { runner->PostTask(task); }); -} - // Updating thread names here does not change the underlying OS thread names. // Instead, this is just additional metadata for the Observatory to show the // thread name of the isolate. @@ -369,34 +361,6 @@ bool DartIsolate::PrepareForRunningFromKernel( return true; } -FML_WARN_UNUSED_RESULT -bool DartIsolate::PrepareForRunningFromKernels( - std::vector> kernels) { - const auto count = kernels.size(); - if (count == 0) { - return false; - } - - for (size_t i = 0; i < count; ++i) { - bool last = (i == (count - 1)); - if (!PrepareForRunningFromKernel(kernels[i], last)) { - return false; - } - } - - return true; -} - -FML_WARN_UNUSED_RESULT -bool DartIsolate::PrepareForRunningFromKernels( - std::vector> kernels) { - std::vector> shared_kernels; - for (auto& kernel : kernels) { - shared_kernels.emplace_back(std::move(kernel)); - } - return PrepareForRunningFromKernels(shared_kernels); -} - bool DartIsolate::MarkIsolateRunnable() { TRACE_EVENT0("flutter", "DartIsolate::MarkIsolateRunnable"); if (phase_ != Phase::LibrariesSetup) { @@ -520,6 +484,7 @@ bool DartIsolate::Shutdown() { // the isolate to shutdown as a parameter. FML_DCHECK(Dart_CurrentIsolate() == nullptr); Dart_EnterIsolate(vm_isolate); + shutdown_callbacks_.clear(); Dart_ShutdownIsolate(); FML_DCHECK(Dart_CurrentIsolate() == nullptr); } @@ -721,8 +686,6 @@ DartIsolate::CreateDartVMAndEmbedderObjectPair( } } - DartVMRef::GetRunningVM()->RegisterActiveIsolate(*embedder_isolate); - // The ownership of the embedder object is controlled by the Dart VM. So the // only reference returned to the caller is weak. embedder_isolate.release(); @@ -731,9 +694,7 @@ DartIsolate::CreateDartVMAndEmbedderObjectPair( // |Dart_IsolateShutdownCallback| void DartIsolate::DartIsolateShutdownCallback( - std::shared_ptr* embedder_isolate) { - embedder_isolate->get()->OnShutdownCallback(); -} + std::shared_ptr* embedder_isolate) {} // |Dart_IsolateCleanupCallback| void DartIsolate::DartIsolateCleanupCallback( @@ -758,12 +719,6 @@ void DartIsolate::AddIsolateShutdownCallback(fml::closure closure) { std::make_unique(std::move(closure))); } -void DartIsolate::OnShutdownCallback() { - shutdown_callbacks_.clear(); - DartVMRef::GetRunningVM()->UnregisterActiveIsolate( - std::static_pointer_cast(shared_from_this())); -} - DartIsolate::AutoFireClosure::AutoFireClosure(fml::closure closure) : closure_(std::move(closure)) {} diff --git a/runtime/dart_isolate.h b/runtime/dart_isolate.h index 96753830e0bb3..49c3df3c51082 100644 --- a/runtime/dart_isolate.h +++ b/runtime/dart_isolate.h @@ -5,7 +5,6 @@ #ifndef FLUTTER_RUNTIME_DART_ISOLATE_H_ #define FLUTTER_RUNTIME_DART_ISOLATE_H_ -#include #include #include @@ -76,14 +75,6 @@ class DartIsolate : public UIDartState { bool PrepareForRunningFromKernel(std::shared_ptr kernel, bool last_piece = true); - FML_WARN_UNUSED_RESULT - bool PrepareForRunningFromKernels( - std::vector> kernels); - - FML_WARN_UNUSED_RESULT - bool PrepareForRunningFromKernels( - std::vector> kernels); - FML_WARN_UNUSED_RESULT bool Run(const std::string& entrypoint, fml::closure on_run = nullptr); @@ -103,8 +94,6 @@ class DartIsolate : public UIDartState { std::weak_ptr GetWeakIsolatePtr(); - fml::RefPtr GetMessageHandlingTaskRunner() const; - private: bool LoadKernel(std::shared_ptr mapping, bool last_piece); @@ -127,14 +116,10 @@ class DartIsolate : public UIDartState { std::vector> kernel_buffers_; std::vector> shutdown_callbacks_; ChildIsolatePreparer child_isolate_preparer_ = nullptr; - fml::RefPtr message_handling_task_runner_; FML_WARN_UNUSED_RESULT bool Initialize(Dart_Isolate isolate, bool is_root_isolate); - void SetMessageHandlingTaskRunner(fml::RefPtr runner, - bool is_root_isolate); - FML_WARN_UNUSED_RESULT bool LoadLibraries(bool is_root_isolate); @@ -143,8 +128,6 @@ class DartIsolate : public UIDartState { FML_WARN_UNUSED_RESULT bool MarkIsolateRunnable(); - void OnShutdownCallback(); - // |Dart_IsolateCreateCallback| static Dart_Isolate DartIsolateCreateCallback( const char* advisory_script_uri, diff --git a/runtime/dart_lifecycle_unittests.cc b/runtime/dart_lifecycle_unittests.cc deleted file mode 100644 index 039d93793cb6d..0000000000000 --- a/runtime/dart_lifecycle_unittests.cc +++ /dev/null @@ -1,142 +0,0 @@ -// Copyright 2013 The Flutter Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "flutter/common/task_runners.h" -#include "flutter/fml/paths.h" -#include "flutter/fml/synchronization/waitable_event.h" -#include "flutter/runtime/dart_vm.h" -#include "flutter/runtime/dart_vm_lifecycle.h" -#include "flutter/runtime/runtime_test.h" - -namespace blink { -namespace testing { - -using DartLifecycleTest = RuntimeTest; - -TEST_F(DartLifecycleTest, CanStartAndShutdownVM) { - auto settings = CreateSettingsForFixture(); - settings.leak_vm = false; - settings.enable_observatory = false; - ASSERT_FALSE(DartVMRef::IsInstanceRunning()); - { - auto vm_ref = DartVMRef::Create(settings); - ASSERT_TRUE(DartVMRef::IsInstanceRunning()); - } - ASSERT_FALSE(DartVMRef::IsInstanceRunning()); -} - -TEST_F(DartLifecycleTest, CanStartAndShutdownVMOverAndOver) { - auto settings = CreateSettingsForFixture(); - settings.leak_vm = false; - settings.enable_observatory = false; - ASSERT_FALSE(DartVMRef::IsInstanceRunning()); - auto count = DartVM::GetVMLaunchCount(); - for (size_t i = 0; i < 10; i++) { - auto vm_ref = DartVMRef::Create(settings); - ASSERT_TRUE(DartVMRef::IsInstanceRunning()); - ASSERT_EQ(DartVM::GetVMLaunchCount(), count + 1); - count = DartVM::GetVMLaunchCount(); - } - ASSERT_FALSE(DartVMRef::IsInstanceRunning()); -} - -static void CreateAndRunRootIsolate( - std::shared_ptr& isolate_result, - const Settings& settings, - const DartVMData& vm, - fml::RefPtr task_runner, - std::string entrypoint) { - FML_CHECK(entrypoint.size() > 0); - TaskRunners runners("io.flutter.test", task_runner, task_runner, task_runner, - task_runner); - auto isolate_weak = DartIsolate::CreateRootIsolate( - vm.GetSettings(), // settings - vm.GetIsolateSnapshot(), // isolate_snapshot - vm.GetSharedSnapshot(), // shared_snapshot - runners, // task_runners - {}, // window - {}, // snapshot_delegate - {}, // io_manager - "main.dart", // advisory_script_uri - entrypoint.c_str(), // advisory_script_entrypoint - nullptr // flags - ); - - auto isolate = isolate_weak.lock(); - - if (!isolate) { - FML_LOG(ERROR) << "Could not create valid isolate."; - return; - } - - if (DartVM::IsRunningPrecompiledCode()) { - if (!isolate->PrepareForRunningFromPrecompiledCode()) { - FML_LOG(ERROR) - << "Could not prepare to run the isolate from precompiled code."; - return; - } - - } else { - if (!isolate->PrepareForRunningFromKernels( - settings.application_kernels())) { - FML_LOG(ERROR) << "Could not prepare isolate from application kernels."; - return; - } - } - - if (isolate->GetPhase() != DartIsolate::Phase::Ready) { - FML_LOG(ERROR) << "Isolate was not ready."; - return; - } - - if (!isolate->Run(entrypoint, settings.root_isolate_create_callback)) { - FML_LOG(ERROR) << "Could not run entrypoint: " << entrypoint << "."; - return; - } - - if (isolate->GetPhase() != DartIsolate::Phase::Running) { - FML_LOG(ERROR) << "Isolate was not Running."; - return; - } - - isolate_result = isolate; -} - -static std::shared_ptr CreateAndRunRootIsolate( - const Settings& settings, - const DartVMData& vm, - fml::RefPtr task_runner, - std::string entrypoint) { - fml::AutoResetWaitableEvent latch; - std::shared_ptr isolate; - fml::TaskRunner::RunNowOrPostTask(task_runner, [&]() { - CreateAndRunRootIsolate(isolate, settings, vm, task_runner, entrypoint); - latch.Signal(); - }); - latch.Wait(); - return isolate; -} - -TEST_F(DartLifecycleTest, ShuttingDownTheVMShutsDownTheIsolate) { - auto settings = CreateSettingsForFixture(); - settings.leak_vm = false; - settings.enable_observatory = false; - ASSERT_FALSE(DartVMRef::IsInstanceRunning()); - { - auto vm_ref = DartVMRef::Create(settings); - ASSERT_TRUE(DartVMRef::IsInstanceRunning()); - ASSERT_EQ(vm_ref->GetIsolateCount(), 0u); - auto isolate = - CreateAndRunRootIsolate(settings, *vm_ref.GetVMData(), - GetThreadTaskRunner(), "testIsolateShutdown"); - ASSERT_TRUE(isolate); - ASSERT_EQ(vm_ref->GetIsolateCount(), 1u); - vm_ref->ShutdownAllIsolates(); - ASSERT_EQ(vm_ref->GetIsolateCount(), 0u); - } - ASSERT_FALSE(DartVMRef::IsInstanceRunning()); -} - -} // namespace testing -} // namespace blink diff --git a/runtime/dart_vm.cc b/runtime/dart_vm.cc index db8acaaa46abc..110f7c2b27809 100644 --- a/runtime/dart_vm.cc +++ b/runtime/dart_vm.cc @@ -15,7 +15,6 @@ #include "flutter/fml/file.h" #include "flutter/fml/logging.h" #include "flutter/fml/mapping.h" -#include "flutter/fml/synchronization/count_down_latch.h" #include "flutter/fml/synchronization/thread_annotations.h" #include "flutter/fml/time/time_delta.h" #include "flutter/fml/trace_event.h" @@ -451,54 +450,4 @@ std::shared_ptr DartVM::GetIsolateNameServer() const { return isolate_name_server_; } -size_t DartVM::GetIsolateCount() const { - std::lock_guard lock(active_isolates_mutex_); - return active_isolates_.size(); -} - -void DartVM::ShutdownAllIsolates() { - std::set> isolates_to_shutdown; - // We may be shutting down isolates on the current thread. Shutting down the - // isolate calls the shutdown callback which removes the entry from the - // active isolate. The lock must be obtained to mutate that entry. To avoid a - // deadlock, collect the isolate is a seprate collection. - { - std::lock_guard lock(active_isolates_mutex_); - for (const auto& active_isolate : active_isolates_) { - if (auto task_runner = active_isolate->GetMessageHandlingTaskRunner()) { - isolates_to_shutdown.insert(active_isolate); - } - } - } - - fml::CountDownLatch latch(isolates_to_shutdown.size()); - - for (const auto& isolate : isolates_to_shutdown) { - fml::TaskRunner::RunNowOrPostTask( - isolate->GetMessageHandlingTaskRunner(), [&latch, isolate]() { - if (!isolate || !isolate->Shutdown()) { - FML_LOG(ERROR) << "Could not shutdown isolate."; - } - latch.CountDown(); - }); - } - latch.Wait(); -} - -void DartVM::RegisterActiveIsolate(std::shared_ptr isolate) { - if (!isolate) { - return; - } - std::lock_guard lock(active_isolates_mutex_); - active_isolates_.insert(isolate); -} - -void DartVM::UnregisterActiveIsolate(std::shared_ptr isolate) { - if (!isolate) { - return; - } - std::lock_guard lock(active_isolates_mutex_); - active_isolates_.erase(isolate); -} - } // namespace blink diff --git a/runtime/dart_vm.h b/runtime/dart_vm.h index bff23f7352a7e..6724abde0b828 100644 --- a/runtime/dart_vm.h +++ b/runtime/dart_vm.h @@ -36,27 +36,17 @@ class DartVM { std::shared_ptr GetVMData() const; - // This accessor is racy and only meant to the used in tests where there is a - // consistent threading mode. - size_t GetIsolateCount() const; - std::shared_ptr GetServiceProtocol() const; std::shared_ptr GetIsolateNameServer() const; - void ShutdownAllIsolates(); - private: const Settings settings_; std::shared_ptr vm_data_; const std::shared_ptr isolate_name_server_; const std::shared_ptr service_protocol_; - mutable std::mutex active_isolates_mutex_; - std::set> active_isolates_ - FML_GUARDED_BY(active_isolates_mutex_); friend class DartVMRef; - friend class DartIsolate; static std::shared_ptr Create( Settings settings, @@ -68,10 +58,6 @@ class DartVM { DartVM(std::shared_ptr data, std::shared_ptr isolate_name_server); - void RegisterActiveIsolate(std::shared_ptr isolate); - - void UnregisterActiveIsolate(std::shared_ptr isolate); - FML_DISALLOW_COPY_AND_ASSIGN(DartVM); }; diff --git a/runtime/dart_vm_lifecycle.cc b/runtime/dart_vm_lifecycle.cc index 07f88cbc83daf..1ed86e0250c4b 100644 --- a/runtime/dart_vm_lifecycle.cc +++ b/runtime/dart_vm_lifecycle.cc @@ -114,9 +114,4 @@ std::shared_ptr DartVMRef::GetIsolateNameServer() { return gVMIsolateNameServer.lock(); } -DartVM* DartVMRef::GetRunningVM() { - std::lock_guard lock(gVMMutex); - return gVM.lock().get(); -} - } // namespace blink diff --git a/runtime/dart_vm_lifecycle.h b/runtime/dart_vm_lifecycle.h index 44a6cdba7b8b1..cfe1f1b646469 100644 --- a/runtime/dart_vm_lifecycle.h +++ b/runtime/dart_vm_lifecycle.h @@ -49,11 +49,6 @@ class DartVMRef { operator bool() const { return static_cast(vm_); } - DartVM* get() { - FML_DCHECK(vm_); - return vm_.get(); - } - DartVM* operator->() { FML_DCHECK(vm_); return vm_.get(); @@ -65,15 +60,10 @@ class DartVMRef { } private: - friend class DartIsolate; - std::shared_ptr vm_; DartVMRef(std::shared_ptr vm); - // Only used by Dart Isolate to register itself with the VM. - static DartVM* GetRunningVM(); - FML_DISALLOW_COPY_AND_ASSIGN(DartVMRef); }; diff --git a/runtime/fixtures/simple_main.dart b/runtime/fixtures/simple_main.dart index bc2d880ff1427..594f69470bc2f 100644 --- a/runtime/fixtures/simple_main.dart +++ b/runtime/fixtures/simple_main.dart @@ -25,7 +25,3 @@ void canRegisterNativeCallback() async { } void NotifyNative() native "NotifyNative"; - - -@pragma('vm:entry-point') -void testIsolateShutdown() { } diff --git a/runtime/runtime_test.cc b/runtime/runtime_test.cc index adb345d85d33a..2613b133d241b 100644 --- a/runtime/runtime_test.cc +++ b/runtime/runtime_test.cc @@ -68,13 +68,6 @@ void RuntimeTest::SetSnapshotsAndAssets(Settings& settings) { return GetMapping(assets_dir_, "isolate_snapshot_instr", true); }; } - } else { - settings.application_kernels = [this]() { - std::vector> kernel_mappings; - kernel_mappings.emplace_back( - GetMapping(assets_dir_, "kernel_blob.bin", false)); - return kernel_mappings; - }; } } diff --git a/shell/common/isolate_configuration.cc b/shell/common/isolate_configuration.cc index e45b6ab15e5f9..173973b64e5b1 100644 --- a/shell/common/isolate_configuration.cc +++ b/shell/common/isolate_configuration.cc @@ -38,7 +38,7 @@ class AppSnapshotIsolateConfiguration final : public IsolateConfiguration { class KernelIsolateConfiguration : public IsolateConfiguration { public: - KernelIsolateConfiguration(std::unique_ptr kernel) + KernelIsolateConfiguration(std::unique_ptr kernel) : kernel_(std::move(kernel)) {} // |shell::IsolateConfiguration| @@ -50,7 +50,7 @@ class KernelIsolateConfiguration : public IsolateConfiguration { } private: - std::unique_ptr kernel_; + std::unique_ptr kernel_; FML_DISALLOW_COPY_AND_ASSIGN(KernelIsolateConfiguration); }; @@ -58,8 +58,7 @@ class KernelIsolateConfiguration : public IsolateConfiguration { class KernelListIsolateConfiguration final : public IsolateConfiguration { public: KernelListIsolateConfiguration( - std::vector>> - kernel_pieces) + std::vector>> kernel_pieces) : kernel_pieces_(std::move(kernel_pieces)) {} // |shell::IsolateConfiguration| @@ -81,7 +80,7 @@ class KernelListIsolateConfiguration final : public IsolateConfiguration { } private: - std::vector>> kernel_pieces_; + std::vector>> kernel_pieces_; FML_DISALLOW_COPY_AND_ASSIGN(KernelListIsolateConfiguration); }; @@ -113,15 +112,15 @@ static std::vector ParseKernelListPaths( return kernel_pieces_paths; } -static std::vector>> +static std::vector>> PrepareKernelMappings(std::vector kernel_pieces_paths, std::shared_ptr asset_manager, fml::RefPtr io_worker) { FML_DCHECK(asset_manager); - std::vector>> fetch_futures; + std::vector>> fetch_futures; for (const auto& kernel_pieces_path : kernel_pieces_paths) { - std::promise> fetch_promise; + std::promise> fetch_promise; fetch_futures.push_back(fetch_promise.get_future()); auto fetch_task = fml::MakeCopyable([asset_manager, kernel_pieces_path, @@ -154,10 +153,6 @@ std::unique_ptr IsolateConfiguration::InferFromSettings( return nullptr; } - if (settings.application_kernels) { - return CreateForKernelList(settings.application_kernels()); - } - if (settings.application_kernel_asset.empty() && settings.application_kernel_list_asset.empty()) { FML_DLOG(ERROR) << "application_kernel_asset or " @@ -197,15 +192,15 @@ IsolateConfiguration::CreateForAppSnapshot() { } std::unique_ptr IsolateConfiguration::CreateForKernel( - std::unique_ptr kernel) { + std::unique_ptr kernel) { return std::make_unique(std::move(kernel)); } std::unique_ptr IsolateConfiguration::CreateForKernelList( - std::vector> kernel_pieces) { - std::vector>> pieces; + std::vector> kernel_pieces) { + std::vector>> pieces; for (auto& piece : kernel_pieces) { - std::promise> promise; + std::promise> promise; pieces.push_back(promise.get_future()); promise.set_value(std::move(piece)); } @@ -213,8 +208,7 @@ std::unique_ptr IsolateConfiguration::CreateForKernelList( } std::unique_ptr IsolateConfiguration::CreateForKernelList( - std::vector>> - kernel_pieces) { + std::vector>> kernel_pieces) { return std::make_unique( std::move(kernel_pieces)); } diff --git a/shell/common/isolate_configuration.h b/shell/common/isolate_configuration.h index 0d2619e6068c1..e9f8d66b2e433 100644 --- a/shell/common/isolate_configuration.h +++ b/shell/common/isolate_configuration.h @@ -29,14 +29,16 @@ class IsolateConfiguration { static std::unique_ptr CreateForAppSnapshot(); static std::unique_ptr CreateForKernel( - std::unique_ptr kernel); + std::unique_ptr kernel); static std::unique_ptr CreateForKernelList( - std::vector>> - kernel_pieces); + std::vector>> kernel_pieces); + // TODO(chinmaygarde): Remove this variant in favor of the one using futures + // for parallelizing asset loads. This one is in place for API compatibility + // till Android is updated. static std::unique_ptr CreateForKernelList( - std::vector> kernel_pieces); + std::vector> kernel_pieces); IsolateConfiguration(); diff --git a/shell/platform/android/platform_view_android_jni.cc b/shell/platform/android/platform_view_android_jni.cc index cbddd1b9f81f4..b26f5939902f2 100644 --- a/shell/platform/android/platform_view_android_jni.cc +++ b/shell/platform/android/platform_view_android_jni.cc @@ -207,7 +207,7 @@ std::unique_ptr CreateIsolateConfiguration( auto blob = asset_manager.GetAsMapping(snapshot_name); auto delta = asset_manager.GetAsMapping("kernel_delta.bin"); if (blob && delta) { - std::vector> kernels; + std::vector> kernels; kernels.emplace_back(std::move(blob)); kernels.emplace_back(std::move(delta)); return IsolateConfiguration::CreateForKernelList(std::move(kernels));