Commit 6c9e57ed authored by Xida Chen's avatar Xida Chen Committed by Commit Bot

[OT-PW] Fix a crash in DrawImageRectOp::RasterWithFlags

It appears that most of the crash in off-thread paint worklet is due
to the paint_record is null in the ImageProvider::ScopedResult. The
reason is that at PaintWorkletImageCache::PaintImageInTask, the Record
from painter_->Paint could be null because the Paint function eventually
calls CSSPaintDefinition::Paint and that could return nullptr.

This CL ensures that all the entries in the records_ have non-null
PaintRecord.

Bug: 957458
Change-Id: I6ce22d3c754cc3daac4c8285554cfaecf2eb654d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1588360
Commit-Queue: Xida Chen <xidachen@chromium.org>
Reviewed-by: default avatarStephen McGruer <smcgruer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#656356}
parent 5da231b7
......@@ -1219,6 +1219,7 @@ void DrawImageOp::RasterWithFlags(const DrawImageOp* op,
DCHECK(IsScaleAdjustmentIdentity(op->scale_adjustment));
SkAutoCanvasRestore save_restore(canvas, true);
canvas->translate(op->left, op->top);
DCHECK(result && result.paint_record());
result.paint_record()->Playback(canvas, params);
return;
}
......@@ -1277,6 +1278,7 @@ void DrawImageRectOp::RasterWithFlags(const DrawImageRectOp* op,
canvas->concat(
SkMatrix::MakeRectToRect(op->src, op->dst, SkMatrix::kFill_ScaleToFit));
canvas->clipRect(op->src);
DCHECK(result && result.paint_record());
result.paint_record()->Playback(canvas, params);
return;
}
......
......@@ -74,6 +74,8 @@ void PaintWorkletImageCache::PaintImageInTask(const PaintImage& paint_image) {
// matches the PaintGeneratedImage::Draw.
sk_sp<PaintRecord> record =
painter_->Paint(paint_image.paint_worklet_input());
if (!record)
return;
{
base::AutoLock hold(records_lock_);
// It is possible for two or more threads to both pass through the first
......
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