This repository was archived by the owner on Feb 25, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +12
-10
lines changed Expand file tree Collapse file tree 3 files changed +12
-10
lines changed Original file line number Diff line number Diff line change @@ -214,7 +214,7 @@ void performanceModeImpactsNotifyIdle() {
214214
215215@pragma ('vm:entry-point' )
216216void 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' )
431431external 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' )
436436Future <void > testPluginUtilitiesCallbackHandle () async {
Original file line number Diff line number Diff 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|
Original file line number Diff line number Diff 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 ();
You can’t perform that action at this time.
0 commit comments