From d9392e7fbb19c1ac9c0a0ca2fb449d92f89bb437 Mon Sep 17 00:00:00 2001 From: Jason Simmons Date: Fri, 11 Nov 2016 13:43:23 -0800 Subject: [PATCH] Move destruction of PictureLayer's SkPicture to the IO thread (flutter/engine#3219) The picture may hold references to images backed by GPU textures that must be deleted on the IO thread. --- engine/src/flutter/flow/layers/picture_layer.cc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/engine/src/flutter/flow/layers/picture_layer.cc b/engine/src/flutter/flow/layers/picture_layer.cc index 021c54b8c15..8faaabc9a97 100644 --- a/engine/src/flutter/flow/layers/picture_layer.cc +++ b/engine/src/flutter/flow/layers/picture_layer.cc @@ -4,6 +4,7 @@ #include "flutter/flow/layers/picture_layer.h" +#include "flutter/common/threads.h" #include "flutter/flow/raster_cache.h" #include "lib/ftl/logging.h" @@ -11,7 +12,12 @@ namespace flow { PictureLayer::PictureLayer() {} -PictureLayer::~PictureLayer() {} +PictureLayer::~PictureLayer() { + // The picture may contain references to textures that are associated + // with the IO thread's context. + SkPicture* picture = picture_.release(); + blink::Threads::IO()->PostTask([picture]() { picture->unref(); }); +} void PictureLayer::Preroll(PrerollContext* context, const SkMatrix& matrix) { if (auto cache = context->raster_cache) {