diff --git a/third_party/blink/renderer/core/offscreencanvas/offscreen_canvas.cc b/third_party/blink/renderer/core/offscreencanvas/offscreen_canvas.cc index d29d242c8526..c41ece4d1da3 100644 --- a/third_party/blink/renderer/core/offscreencanvas/offscreen_canvas.cc +++ b/third_party/blink/renderer/core/offscreencanvas/offscreen_canvas.cc @@ -50,6 +50,9 @@ #include "third_party/blink/renderer/platform/instrumentation/use_counter.h" #include "third_party/blink/renderer/platform/wtf/math_extras.h" #include "third_party/skia/include/core/SkSurface.h" +#include "base/logging.h" +#include "base/debug/stack_trace.h" +#include "base/threading/platform_thread.h" namespace blink { @@ -397,6 +400,8 @@ CanvasResourceDispatcher* OffscreenCanvas::GetOrCreateResourceDispatcher() { // If we don't have a valid placeholder_canvas_id_, then this is a standalone // OffscreenCanvas, and it should not have a placeholder. if (frame_dispatcher_ == nullptr || restoring_gpu_context_) { + LOG(ERROR)<<"(frame_dispatcher_ == nullptr || restoring_gpu_context_)\n"; + scoped_refptr agent_group_scheduler_compositor_task_runner; scoped_refptr dispatcher_task_runner; @@ -421,6 +426,7 @@ CanvasResourceDispatcher* OffscreenCanvas::GetOrCreateResourceDispatcher() { std::move(agent_group_scheduler_compositor_task_runner), client_id_, sink_id_, placeholder_canvas_id_, Size()); + LOG(ERROR)<<"HasPlaceholderCanvas-> "<SetPlaceholderCanvasDispatcher(placeholder_canvas_id_); } @@ -516,6 +522,8 @@ void OffscreenCanvas::DidDraw(const SkIRect& rect) { } bool OffscreenCanvas::BeginFrame() { + // base::debug::StackTrace st; + // st.Print(); DCHECK(HasPlaceholderCanvas()); GetOrCreateResourceDispatcher()->SetNeedsBeginFrame(false); return PushFrameIfNeeded(); @@ -532,6 +540,8 @@ void OffscreenCanvas::SetFilterQualityInResource( } bool OffscreenCanvas::PushFrameIfNeeded() { + + LOG(ERROR)<<"needs_push_frame_: "<PushFrame(); } @@ -542,6 +552,8 @@ bool OffscreenCanvas::PushFrame(scoped_refptr&& canvas_resource, const SkIRect& damage_rect) { TRACE_EVENT0("blink", "OffscreenCanvas::PushFrame"); DCHECK(needs_push_frame_); + // base::debug::StackTrace st; + // st.Print(); needs_push_frame_ = false; current_frame_damage_rect_.join(damage_rect); if (current_frame_damage_rect_.isEmpty() || !canvas_resource) @@ -586,8 +598,13 @@ void OffscreenCanvas::NotifyGpuContextLost() { void OffscreenCanvas::CheckForGpuContextLost() { // If the GPU has crashed, it is necessary to notify the OffscreenCanvas so // the context can be recovered. + LOG(ERROR) + << "[11000]OffscreenCanvas::CheckForGpuContextLost in ->> ClientId: " + << ClientId() << " tname-> " << base::PlatformThread::GetName(); + if (ResourceProvider() && ResourceProvider()->IsAccelerated() && - ResourceProvider()->IsGpuContextLost()) { + 1337==ClientId()) { + SetFrameSinkId(0,0); set_context_lost(true); ReplaceResourceProvider(nullptr); NotifyGpuContextLost(); diff --git a/third_party/blink/renderer/modules/canvas/canvas2d/base_rendering_context_2d.cc b/third_party/blink/renderer/modules/canvas/canvas2d/base_rendering_context_2d.cc index adbfc4d1660a..42ed4a1a0f88 100644 --- a/third_party/blink/renderer/modules/canvas/canvas2d/base_rendering_context_2d.cc +++ b/third_party/blink/renderer/modules/canvas/canvas2d/base_rendering_context_2d.cc @@ -68,6 +68,10 @@ #include "third_party/skia/include/core/SkPathBuilder.h" #include "ui/gfx/geometry/quad_f.h" #include "ui/gfx/geometry/skia_conversions.h" +#include "third_party/blink/renderer/core/offscreencanvas/offscreen_canvas.h" +#include "base/logging.h" +#include "base/debug/stack_trace.h" +#include "base/threading/platform_thread.h" namespace blink { @@ -451,11 +455,18 @@ void BaseRenderingContext2D::ResetInternal() { // Clear the frame in case a flush previously drew to the canvas surface. if (cc::PaintCanvas* c = GetPaintCanvas()) { + base::debug::StackTrace st; + st.Print(); int width = Width(); // Keeping results to avoid repetitive virtual calls. int height = Height(); + + LOG(ERROR)<<"=================begin draw==============\n"; + this->HostAsOffscreenCanvas()->SetFrameSinkId(1337,1337); WillDraw(SkIRect::MakeXYWH(0, 0, width, height), CanvasPerformanceMonitor::DrawType::kOther); + this->HostAsOffscreenCanvas()->SetFrameSinkId(0,0); c->drawRect(SkRect::MakeXYWH(0.0f, 0.0f, width, height), GetClearFlags()); + LOG(ERROR)<<"=================end draw==============\n"; } ValidateStateStack(); @@ -2795,6 +2806,8 @@ HTMLCanvasElement* BaseRenderingContext2D::HostAsHTMLCanvasElement() const { } OffscreenCanvas* BaseRenderingContext2D::HostAsOffscreenCanvas() const { + base::debug::StackTrace st; + st.Print(); return nullptr; } diff --git a/third_party/blink/renderer/modules/canvas/canvas2d/base_rendering_context_2d.h b/third_party/blink/renderer/modules/canvas/canvas2d/base_rendering_context_2d.h index 48efc0ec7671..e991afe508be 100644 --- a/third_party/blink/renderer/modules/canvas/canvas2d/base_rendering_context_2d.h +++ b/third_party/blink/renderer/modules/canvas/canvas2d/base_rendering_context_2d.h @@ -459,10 +459,11 @@ class MODULES_EXPORT BaseRenderingContext2D : public CanvasPath { dispatch_context_restored_event_timer_; HeapTaskRunnerTimer try_restore_context_event_timer_; unsigned try_restore_context_attempt_count_ = 0; - + virtual OffscreenCanvas* HostAsOffscreenCanvas() const; + protected: virtual HTMLCanvasElement* HostAsHTMLCanvasElement() const; - virtual OffscreenCanvas* HostAsOffscreenCanvas() const; + virtual FontSelector* GetFontSelector() const; const Font& AccessFont(HTMLCanvasElement* canvas); diff --git a/third_party/blink/renderer/modules/canvas/offscreencanvas2d/offscreen_canvas_rendering_context_2d.h b/third_party/blink/renderer/modules/canvas/offscreencanvas2d/offscreen_canvas_rendering_context_2d.h index 2e982218826d..34181294f406 100644 --- a/third_party/blink/renderer/modules/canvas/offscreencanvas2d/offscreen_canvas_rendering_context_2d.h +++ b/third_party/blink/renderer/modules/canvas/offscreencanvas2d/offscreen_canvas_rendering_context_2d.h @@ -146,9 +146,9 @@ class MODULES_EXPORT OffscreenCanvasRenderingContext2D final } absl::optional FlushCanvas(FlushReason) override; - - protected: OffscreenCanvas* HostAsOffscreenCanvas() const final; + + protected: FontSelector* GetFontSelector() const final; PredefinedColorSpace GetDefaultImageDataColorSpace() const final {