From a788d4399f08008e93c80a1556082c9920939f05 Mon Sep 17 00:00:00 2001 From: Jason Simmons Date: Fri, 28 Aug 2020 16:03:53 -0700 Subject: [PATCH] Reset Shell::weak_factory_gpu_ on the raster thread weak_factory_gpu_ should only be accessed on the raster thread. If the Shell destructor running on the platform thread does a std::move of weak_factory_gpu_, then pending raster thread tasks may read it as null. Fixes internal bug b/166295661 --- shell/common/shell.cc | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/shell/common/shell.cc b/shell/common/shell.cc index f4651184c0e08..3c14d7594047c 100644 --- a/shell/common/shell.cc +++ b/shell/common/shell.cc @@ -400,13 +400,12 @@ Shell::~Shell() { fml::TaskRunner::RunNowOrPostTask( task_runners_.GetRasterTaskRunner(), - fml::MakeCopyable([rasterizer = std::move(rasterizer_), - weak_factory_gpu = std::move(weak_factory_gpu_), - &gpu_latch]() mutable { - rasterizer.reset(); - weak_factory_gpu.reset(); - gpu_latch.Signal(); - })); + fml::MakeCopyable( + [this, rasterizer = std::move(rasterizer_), &gpu_latch]() mutable { + rasterizer.reset(); + this->weak_factory_gpu_.reset(); + gpu_latch.Signal(); + })); gpu_latch.Wait(); fml::TaskRunner::RunNowOrPostTask(