ui/gl: Ping GPU watchdog thread during strike deletion.
Ping the watchdog thread for Gpu_main during strike deletion to avoid
hangs on mac.
R=​piman@chromium.org
(cherry picked from commit 39641b9ee613ec96fa55b423dcad85ee7baa237d)
Bug: 969623
Change-Id: I36faa00db502e1b1cf0bbda262e5aaadd96f2cbe
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1641602
Auto-Submit: Khushal <khushalsagar@chromium.org>
Reviewed-by: Antoine Labour <piman@chromium.org>
Commit-Queue: Khushal <khushalsagar@chromium.org>
Cr-Original-Commit-Position: refs/heads/master@{#665660}
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1662598
Reviewed-by: Khushal <khushalsagar@chromium.org>
Cr-Commit-Position: refs/branch-heads/3809@{#350}
Cr-Branched-From: d82dec1a818f378c464ba307ddd9c92133eac355-refs/heads/master@{#665002}
diff --git a/cc/paint/paint_op_buffer_fuzzer.cc b/cc/paint/paint_op_buffer_fuzzer.cc
index d7fcd2ed..7e03386 100644
--- a/cc/paint/paint_op_buffer_fuzzer.cc
+++ b/cc/paint/paint_op_buffer_fuzzer.cc
@@ -35,6 +35,7 @@
return it->second;
return CreateBuffer(shm_id);
}
+ void ReportProgress() override {}
private:
scoped_refptr<gpu::Buffer> CreateBuffer(uint32_t shm_id) {
diff --git a/gpu/command_buffer/service/raster_decoder.cc b/gpu/command_buffer/service/raster_decoder.cc
index 385af960..208fb4b5 100644
--- a/gpu/command_buffer/service/raster_decoder.cc
+++ b/gpu/command_buffer/service/raster_decoder.cc
@@ -352,6 +352,7 @@
// ServiceFontManager::Client implementation.
scoped_refptr<Buffer> GetShmBuffer(uint32_t shm_id) override;
+ void ReportProgress() override;
private:
gles2::ContextState* state() const {
@@ -2126,6 +2127,11 @@
return GetSharedMemoryBuffer(shm_id);
}
+void RasterDecoderImpl::ReportProgress() {
+ if (shared_context_state_->progress_reporter())
+ shared_context_state_->progress_reporter()->ReportProgress();
+}
+
void RasterDecoderImpl::DoRasterCHROMIUM(GLuint raster_shm_id,
GLuint raster_shm_offset,
GLuint raster_shm_size,
diff --git a/gpu/command_buffer/service/service_font_manager.cc b/gpu/command_buffer/service/service_font_manager.cc
index 196c2934..3feef451 100644
--- a/gpu/command_buffer/service/service_font_manager.cc
+++ b/gpu/command_buffer/service/service_font_manager.cc
@@ -118,6 +118,7 @@
ServiceFontManager::ServiceFontManager(Client* client)
: client_(client),
+ client_thread_id_(base::PlatformThread::CurrentId()),
strike_client_(std::make_unique<SkStrikeClient>(
sk_make_sp<SkiaDiscardableManager>(this))) {}
@@ -139,6 +140,7 @@
uint32_t memory_size,
std::vector<SkDiscardableHandleId>* locked_handles) {
base::AutoLock hold(lock_);
+ DCHECK_EQ(client_thread_id_, base::PlatformThread::CurrentId());
DCHECK(locked_handles->empty());
DCHECK(!destroyed_);
@@ -225,10 +227,23 @@
if (destroyed_)
return true;
+ // If this method returns true, the strike associated with the handle will be
+ // deleted which deletes the memory for all glyphs cached by the strike. On
+ // mac this is resulting in hangs during strike deserialization when a bunch
+ // of strikes may be deleted in bulk. Try to avoid that by pinging the
+ // progress reporter before deleting each strike.
+ // Note that this method should generally only run on the Gpu main thread,
+ // where skia is used, except for single process webview where the renderer
+ // and GPU run in the same process.
+ const bool report_progress =
+ base::PlatformThread::CurrentId() == client_thread_id_;
+
auto it = discardable_handle_map_.find(handle_id);
if (it == discardable_handle_map_.end()) {
LOG(ERROR) << "Tried to delete invalid SkDiscardableHandleId: "
<< handle_id;
+ if (report_progress)
+ client_->ReportProgress();
return true;
}
@@ -237,6 +252,8 @@
return false;
discardable_handle_map_.erase(it);
+ if (report_progress)
+ client_->ReportProgress();
return true;
}
diff --git a/gpu/command_buffer/service/service_font_manager.h b/gpu/command_buffer/service/service_font_manager.h
index 198c54f..69a8087 100644
--- a/gpu/command_buffer/service/service_font_manager.h
+++ b/gpu/command_buffer/service/service_font_manager.h
@@ -8,6 +8,7 @@
#include "base/containers/flat_map.h"
#include "base/memory/weak_ptr.h"
#include "base/synchronization/lock.h"
+#include "base/threading/thread.h"
#include "gpu/command_buffer/common/discardable_handle.h"
#include "gpu/gpu_gles2_export.h"
#include "third_party/skia/src/core/SkRemoteGlyphCache.h"
@@ -22,6 +23,7 @@
public:
virtual ~Client() {}
virtual scoped_refptr<Buffer> GetShmBuffer(uint32_t shm_id) = 0;
+ virtual void ReportProgress() = 0;
};
ServiceFontManager(Client* client);
@@ -46,6 +48,7 @@
base::Lock lock_;
Client* client_;
+ const base::PlatformThreadId client_thread_id_;
std::unique_ptr<SkStrikeClient> strike_client_;
base::flat_map<SkDiscardableHandleId, ServiceDiscardableHandle>
discardable_handle_map_;