diff --git a/runtime/runtime_controller.cc b/runtime/runtime_controller.cc index 9870d5e7804cac6949eb105dee2346bc702ee731..357654958e54fad23faecda232eafec66a765147 100644 --- a/runtime/runtime_controller.cc +++ b/runtime/runtime_controller.cc @@ -243,19 +243,6 @@ bool RuntimeController::NotifyIdle(fml::TimeDelta deadline) { return true; } -bool RuntimeController::NotifyDestroyed() { - std::shared_ptr root_isolate = root_isolate_.lock(); - if (!root_isolate) { - return false; - } - - tonic::DartState::Scope scope(root_isolate); - - Dart_NotifyDestroyed(); - - return true; -} - bool RuntimeController::DispatchPlatformMessage( std::unique_ptr message) { if (auto* platform_configuration = GetPlatformConfigurationIfAvailable()) { diff --git a/runtime/runtime_controller.h b/runtime/runtime_controller.h index 3f8fa2dcb3ab4d8fd8e83dd1a594ef9a95d642c0..d4a6ab6c0abfa1cbc7adbc12d2a9e19d780f4d5c 100644 --- a/runtime/runtime_controller.h +++ b/runtime/runtime_controller.h @@ -360,17 +360,6 @@ class RuntimeController : public PlatformConfigurationClient { /// virtual bool NotifyIdle(fml::TimeDelta deadline); - //---------------------------------------------------------------------------- - /// @brief Notify the Dart VM that the attached flutter view has been - /// destroyed. This gives the Dart VM to perform some cleanup - /// activities e.g: perform garbage collection to free up any - /// unused memory. - /// - /// NotifyDestroyed is advisory. The VM may or may not perform any clean up - /// activities. - /// - virtual bool NotifyDestroyed(); - //---------------------------------------------------------------------------- /// @brief Returns if the root isolate is running. The isolate must be /// transitioned to the running phase manually. The isolate can diff --git a/shell/common/engine.cc b/shell/common/engine.cc index bbdf61cac7194f7b779497f4e7d85ee76d0a8b14..88be4b15dce3b287ca1e5e745ea475fc5200bb5d 100644 --- a/shell/common/engine.cc +++ b/shell/common/engine.cc @@ -261,11 +261,6 @@ void Engine::NotifyIdle(fml::TimeDelta deadline) { runtime_controller_->NotifyIdle(deadline); } -void Engine::NotifyDestroyed() { - TRACE_EVENT0("flutter", "Engine::NotifyDestroyed"); - runtime_controller_->NotifyDestroyed(); -} - std::optional Engine::GetUIIsolateReturnCode() { return runtime_controller_->GetRootIsolateReturnCode(); } diff --git a/shell/common/engine.h b/shell/common/engine.h index 70402c24a7876b11c98480af5c9b442e84bc969a..e08fc0a20d28e0781406237ce40dd60b248b1239 100644 --- a/shell/common/engine.h +++ b/shell/common/engine.h @@ -554,13 +554,6 @@ class Engine final : public RuntimeDelegate, PointerDataDispatcher::Delegate { /// void NotifyIdle(fml::TimeDelta deadline); - //---------------------------------------------------------------------------- - /// @brief Notifies the engine that the attached flutter view has been - /// destroyed. - /// This enables the engine to notify the Dart VM so it can do - /// some cleanp activities. - void NotifyDestroyed(); - //---------------------------------------------------------------------------- /// @brief Dart code cannot fully measure the time it takes for a /// specific frame to be rendered. This is because Dart code only diff --git a/shell/common/fixtures/shell_test.dart b/shell/common/fixtures/shell_test.dart index 605e3d951d230e68aeca3cc5afaa661284975fc8..9a7c02179fd6b476cb05f1c1112a102e4ff9b354 100644 --- a/shell/common/fixtures/shell_test.dart +++ b/shell/common/fixtures/shell_test.dart @@ -212,11 +212,6 @@ void performanceModeImpactsNotifyIdle() { PlatformDispatcher.instance.requestDartPerformanceMode(DartPerformanceMode.balanced); } -@pragma('vm:entry-point') -void callNotifyDestroyed() { - notifyDestroyed(); -} - @pragma('vm:external-name', 'NotifyMessage') external void notifyMessage(String string); @@ -429,8 +424,6 @@ Future runCallback(IsolateParam param) async { @pragma('vm:entry-point') @pragma('vm:external-name', 'NotifyNativeBool') external void notifyNativeBool(bool value); -@pragma('vm:external-name', 'NotifyDestroyed') -external void notifyDestroyed(); @pragma('vm:entry-point') Future testPluginUtilitiesCallbackHandle() async { diff --git a/shell/common/shell.cc b/shell/common/shell.cc index bdaf8c234d889328cd00e64a223024d12589585d..de1fbb6e19de4f1952d61d1dc39c7ae9463b6f36 100644 --- a/shell/common/shell.cc +++ b/shell/common/shell.cc @@ -851,14 +851,6 @@ void Shell::OnPlatformViewDestroyed() { // This incorrect assumption can lead to deadlock. rasterizer_->DisableThreadMergerIfNeeded(); - // Notify the Dart VM that the PlatformView has been destroyed and some - // cleanup activity can be done (e.g: garbage collect the Dart heap). - task_runners_.GetUITaskRunner()->PostTask([engine = engine_->GetWeakPtr()]() { - if (engine) { - engine->NotifyDestroyed(); - } - }); - // Note: // This is a synchronous operation because certain platforms depend on // setup/suspension of all activities that may be interacting with the GPU in diff --git a/shell/common/shell_unittests.cc b/shell/common/shell_unittests.cc index d850eab6880120970a7c509f6342dc66b85bf80f..64504b70ba713cec363b5622082e43ec4c9bd4b9 100644 --- a/shell/common/shell_unittests.cc +++ b/shell/common/shell_unittests.cc @@ -3979,40 +3979,6 @@ TEST_F(ShellTest, NotifyIdleNotCalledInLatencyMode) { ASSERT_FALSE(DartVMRef::IsInstanceRunning()); } -TEST_F(ShellTest, NotifyDestroyed) { - ASSERT_FALSE(DartVMRef::IsInstanceRunning()); - Settings settings = CreateSettingsForFixture(); - ThreadHost thread_host("io.flutter.test." + GetCurrentTestName() + ".", - ThreadHost::Type::Platform | ThreadHost::UI | - ThreadHost::IO | ThreadHost::RASTER); - auto platform_task_runner = thread_host.platform_thread->GetTaskRunner(); - TaskRunners task_runners("test", thread_host.platform_thread->GetTaskRunner(), - thread_host.raster_thread->GetTaskRunner(), - thread_host.ui_thread->GetTaskRunner(), - thread_host.io_thread->GetTaskRunner()); - auto shell = CreateShell(settings, task_runners); - ASSERT_TRUE(DartVMRef::IsInstanceRunning()); - ASSERT_TRUE(ValidateShell(shell.get())); - - fml::CountDownLatch latch(1); - AddNativeCallback("NotifyDestroyed", CREATE_NATIVE_ENTRY([&](auto args) { - auto runtime_controller = const_cast( - shell->GetEngine()->GetRuntimeController()); - bool success = runtime_controller->NotifyDestroyed(); - EXPECT_TRUE(success); - latch.CountDown(); - })); - - auto configuration = RunConfiguration::InferFromSettings(settings); - configuration.SetEntrypoint("callNotifyDestroyed"); - RunEngine(shell.get(), std::move(configuration)); - - latch.Wait(); - - DestroyShell(std::move(shell), task_runners); - ASSERT_FALSE(DartVMRef::IsInstanceRunning()); -} - } // namespace testing } // namespace flutter