From 54f9ebe7a937f42351843fa0e8ccb298c71dfc60 Mon Sep 17 00:00:00 2001 From: Chinmay Garde Date: Mon, 16 Dec 2019 16:55:08 -0800 Subject: [PATCH] Forward low memory notifications from the shell to DartVM. (flutter/engine#14517) --- engine/src/flutter/shell/common/shell.cc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/engine/src/flutter/shell/common/shell.cc b/engine/src/flutter/shell/common/shell.cc index bef72617c2..fc7833fcbf 100644 --- a/engine/src/flutter/shell/common/shell.cc +++ b/engine/src/flutter/shell/common/shell.cc @@ -393,6 +393,12 @@ Shell::~Shell() { } void Shell::NotifyLowMemoryWarning() const { + // This does not require a current isolate but does require a running VM. + // Since a valid shell will not be returned to the embedder without a valid + // DartVMRef, we can be certain that this is a safe spot to assume a VM is + // running. + ::Dart_NotifyLowMemory(); + task_runners_.GetGPUTaskRunner()->PostTask( [rasterizer = rasterizer_->GetWeakPtr()]() { if (rasterizer) {