Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit e836a5c

Browse files
committed
Address code review comments.
1 parent 67e6bde commit e836a5c

File tree

3 files changed

+12
-10
lines changed

3 files changed

+12
-10
lines changed

shell/common/fixtures/shell_test.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ void performanceModeImpactsNotifyIdle() {
214214

215215
@pragma('vm:entry-point')
216216
void callNotifyDestroyed() {
217-
notifyDestroyedBool();
217+
notifyDestroyed();
218218
}
219219

220220
@pragma('vm:external-name', 'NotifyMessage')
@@ -429,8 +429,8 @@ Future<void> runCallback(IsolateParam param) async {
429429
@pragma('vm:entry-point')
430430
@pragma('vm:external-name', 'NotifyNativeBool')
431431
external void notifyNativeBool(bool value);
432-
@pragma('vm:external-name', 'NotifyDestroyedBool')
433-
external void notifyDestroyedBool();
432+
@pragma('vm:external-name', 'NotifyDestroyed')
433+
external void notifyDestroyed();
434434

435435
@pragma('vm:entry-point')
436436
Future<void> testPluginUtilitiesCallbackHandle() async {

shell/common/shell.cc

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -851,6 +851,14 @@ void Shell::OnPlatformViewDestroyed() {
851851
// This incorrect assumption can lead to deadlock.
852852
rasterizer_->DisableThreadMergerIfNeeded();
853853

854+
// Notify the Dart VM that the PlatformView has been destroyed and some
855+
// cleanup activity can be done (e.g: garbage collect the Dart heap).
856+
task_runners_.GetUITaskRunner()->PostTask([engine = engine_->GetWeakPtr()]() {
857+
if (engine) {
858+
engine->NotifyDestroyed();
859+
}
860+
});
861+
854862
// Note:
855863
// This is a synchronous operation because certain platforms depend on
856864
// setup/suspension of all activities that may be interacting with the GPU in
@@ -899,12 +907,6 @@ void Shell::OnPlatformViewDestroyed() {
899907
// Overall, the longer term plan is to remove this implementation once
900908
// https://github.com/flutter/flutter/issues/96679 is fixed.
901909
rasterizer_->TeardownExternalViewEmbedder();
902-
903-
task_runners_.GetUITaskRunner()->PostTask([engine = engine_->GetWeakPtr()]() {
904-
if (engine) {
905-
engine->NotifyDestroyed();
906-
}
907-
});
908910
}
909911

910912
// |PlatformView::Delegate|

shell/common/shell_unittests.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3948,7 +3948,7 @@ TEST_F(ShellTest, NotifyDestroyed) {
39483948
ASSERT_TRUE(ValidateShell(shell.get()));
39493949

39503950
fml::CountDownLatch latch(1);
3951-
AddNativeCallback("NotifyDestroyedBool", CREATE_NATIVE_ENTRY([&](auto args) {
3951+
AddNativeCallback("NotifyDestroyed", CREATE_NATIVE_ENTRY([&](auto args) {
39523952
auto runtime_controller = const_cast<RuntimeController*>(
39533953
shell->GetEngine()->GetRuntimeController());
39543954
bool success = runtime_controller->NotifyDestroyed();

0 commit comments

Comments
 (0)