Commit 39641b9e authored by Khushal's avatar Khushal Committed by Commit Bot

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

Bug: 969623
Change-Id: I36faa00db502e1b1cf0bbda262e5aaadd96f2cbe
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1641602
Auto-Submit: Khushal <khushalsagar@chromium.org>
Reviewed-by: default avatarAntoine Labour <piman@chromium.org>
Commit-Queue: Khushal <khushalsagar@chromium.org>
Cr-Commit-Position: refs/heads/master@{#665660}
parent f7fb5e3c
...@@ -35,6 +35,7 @@ class FontSupport : public gpu::ServiceFontManager::Client { ...@@ -35,6 +35,7 @@ class FontSupport : public gpu::ServiceFontManager::Client {
return it->second; return it->second;
return CreateBuffer(shm_id); return CreateBuffer(shm_id);
} }
void ReportProgress() override {}
private: private:
scoped_refptr<gpu::Buffer> CreateBuffer(uint32_t shm_id) { scoped_refptr<gpu::Buffer> CreateBuffer(uint32_t shm_id) {
......
...@@ -352,6 +352,7 @@ class RasterDecoderImpl final : public RasterDecoder, ...@@ -352,6 +352,7 @@ class RasterDecoderImpl final : public RasterDecoder,
// ServiceFontManager::Client implementation. // ServiceFontManager::Client implementation.
scoped_refptr<Buffer> GetShmBuffer(uint32_t shm_id) override; scoped_refptr<Buffer> GetShmBuffer(uint32_t shm_id) override;
void ReportProgress() override;
private: private:
gles2::ContextState* state() const { gles2::ContextState* state() const {
...@@ -2126,6 +2127,11 @@ scoped_refptr<Buffer> RasterDecoderImpl::GetShmBuffer(uint32_t shm_id) { ...@@ -2126,6 +2127,11 @@ scoped_refptr<Buffer> RasterDecoderImpl::GetShmBuffer(uint32_t shm_id) {
return GetSharedMemoryBuffer(shm_id); 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, void RasterDecoderImpl::DoRasterCHROMIUM(GLuint raster_shm_id,
GLuint raster_shm_offset, GLuint raster_shm_offset,
GLuint raster_shm_size, GLuint raster_shm_size,
......
...@@ -118,6 +118,7 @@ class ServiceFontManager::SkiaDiscardableManager ...@@ -118,6 +118,7 @@ class ServiceFontManager::SkiaDiscardableManager
ServiceFontManager::ServiceFontManager(Client* client) ServiceFontManager::ServiceFontManager(Client* client)
: client_(client), : client_(client),
client_thread_id_(base::PlatformThread::CurrentId()),
strike_client_(std::make_unique<SkStrikeClient>( strike_client_(std::make_unique<SkStrikeClient>(
sk_make_sp<SkiaDiscardableManager>(this))) {} sk_make_sp<SkiaDiscardableManager>(this))) {}
...@@ -139,6 +140,7 @@ bool ServiceFontManager::Deserialize( ...@@ -139,6 +140,7 @@ bool ServiceFontManager::Deserialize(
uint32_t memory_size, uint32_t memory_size,
std::vector<SkDiscardableHandleId>* locked_handles) { std::vector<SkDiscardableHandleId>* locked_handles) {
base::AutoLock hold(lock_); base::AutoLock hold(lock_);
DCHECK_EQ(client_thread_id_, base::PlatformThread::CurrentId());
DCHECK(locked_handles->empty()); DCHECK(locked_handles->empty());
DCHECK(!destroyed_); DCHECK(!destroyed_);
...@@ -225,10 +227,23 @@ bool ServiceFontManager::DeleteHandle(SkDiscardableHandleId handle_id) { ...@@ -225,10 +227,23 @@ bool ServiceFontManager::DeleteHandle(SkDiscardableHandleId handle_id) {
if (destroyed_) if (destroyed_)
return true; 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); auto it = discardable_handle_map_.find(handle_id);
if (it == discardable_handle_map_.end()) { if (it == discardable_handle_map_.end()) {
LOG(ERROR) << "Tried to delete invalid SkDiscardableHandleId: " LOG(ERROR) << "Tried to delete invalid SkDiscardableHandleId: "
<< handle_id; << handle_id;
if (report_progress)
client_->ReportProgress();
return true; return true;
} }
...@@ -237,6 +252,8 @@ bool ServiceFontManager::DeleteHandle(SkDiscardableHandleId handle_id) { ...@@ -237,6 +252,8 @@ bool ServiceFontManager::DeleteHandle(SkDiscardableHandleId handle_id) {
return false; return false;
discardable_handle_map_.erase(it); discardable_handle_map_.erase(it);
if (report_progress)
client_->ReportProgress();
return true; return true;
} }
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include "base/containers/flat_map.h" #include "base/containers/flat_map.h"
#include "base/memory/weak_ptr.h" #include "base/memory/weak_ptr.h"
#include "base/synchronization/lock.h" #include "base/synchronization/lock.h"
#include "base/threading/thread.h"
#include "gpu/command_buffer/common/discardable_handle.h" #include "gpu/command_buffer/common/discardable_handle.h"
#include "gpu/gpu_gles2_export.h" #include "gpu/gpu_gles2_export.h"
#include "third_party/skia/src/core/SkRemoteGlyphCache.h" #include "third_party/skia/src/core/SkRemoteGlyphCache.h"
...@@ -22,6 +23,7 @@ class GPU_GLES2_EXPORT ServiceFontManager ...@@ -22,6 +23,7 @@ class GPU_GLES2_EXPORT ServiceFontManager
public: public:
virtual ~Client() {} virtual ~Client() {}
virtual scoped_refptr<Buffer> GetShmBuffer(uint32_t shm_id) = 0; virtual scoped_refptr<Buffer> GetShmBuffer(uint32_t shm_id) = 0;
virtual void ReportProgress() = 0;
}; };
ServiceFontManager(Client* client); ServiceFontManager(Client* client);
...@@ -46,6 +48,7 @@ class GPU_GLES2_EXPORT ServiceFontManager ...@@ -46,6 +48,7 @@ class GPU_GLES2_EXPORT ServiceFontManager
base::Lock lock_; base::Lock lock_;
Client* client_; Client* client_;
const base::PlatformThreadId client_thread_id_;
std::unique_ptr<SkStrikeClient> strike_client_; std::unique_ptr<SkStrikeClient> strike_client_;
base::flat_map<SkDiscardableHandleId, ServiceDiscardableHandle> base::flat_map<SkDiscardableHandleId, ServiceDiscardableHandle>
discardable_handle_map_; discardable_handle_map_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment