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 {
return it->second;
return CreateBuffer(shm_id);
}
void ReportProgress() override {}
private:
scoped_refptr<gpu::Buffer> CreateBuffer(uint32_t shm_id) {
......
......@@ -352,6 +352,7 @@ class RasterDecoderImpl final : public RasterDecoder,
// ServiceFontManager::Client implementation.
scoped_refptr<Buffer> GetShmBuffer(uint32_t shm_id) override;
void ReportProgress() override;
private:
gles2::ContextState* state() const {
......@@ -2126,6 +2127,11 @@ scoped_refptr<Buffer> RasterDecoderImpl::GetShmBuffer(uint32_t 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,
GLuint raster_shm_offset,
GLuint raster_shm_size,
......
......@@ -118,6 +118,7 @@ class ServiceFontManager::SkiaDiscardableManager
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 @@ bool ServiceFontManager::Deserialize(
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 @@ bool ServiceFontManager::DeleteHandle(SkDiscardableHandleId handle_id) {
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 @@ bool ServiceFontManager::DeleteHandle(SkDiscardableHandleId handle_id) {
return false;
discardable_handle_map_.erase(it);
if (report_progress)
client_->ReportProgress();
return true;
}
......
......@@ -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 @@ class GPU_GLES2_EXPORT ServiceFontManager
public:
virtual ~Client() {}
virtual scoped_refptr<Buffer> GetShmBuffer(uint32_t shm_id) = 0;
virtual void ReportProgress() = 0;
};
ServiceFontManager(Client* client);
......@@ -46,6 +48,7 @@ class GPU_GLES2_EXPORT ServiceFontManager
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_;
......
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