Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(194)

Issue 662033002: Potential bug on drawing video on SkCanvas (Closed)

Created:
6 years, 2 months ago by dshwang
Modified:
6 years, 1 month ago
CC:
chromium-reviews, feature-media-reviews_chromium.org
Base URL:
https://chromium.googlesource.com/chromium/src.git@master
Project:
chromium
Visibility:
Public.

Description

Potential bug on drawing video on SkCanvas When drawing video frame on SkCanvas, chromium reuse the same cached SkBitmap on both software SkCanvas and accelerated SkCanvas. After SkBitmap is used on both SkCanvas, SkBitmap includes both GrTexture and system memory buffer. It's weird and looks error-prone. Fortunately, it works well. In detail, SkCanvasVideoRenderer::Paint(VideoFrame* frame, SkCanvas* canvas, ..) draws |frame| on |canvas|. Paint() makes SkBitmap by |frame| via YUV conversion or texture uploading and then caches SkBitmap as |last_frame_|. Paint() can be used by both software SkCanvas and accelerated SkCanvas, and |last_frame_| is used by both. |last_frame_| is based on SkImageGenerator, so it's not defined to software SkBitmap or accelerated SkBitmap at the creation time. When |last_frame_| is drawn on software canvas, system memory cache is allocated and kept by |last_frame_|. When |last_frame_| is drawn on accelerated canvas, GrTexture is allocated and kept by |last_frame_|. Although it works now, it's not-documented and unexpected behavior of SkBitmap and SkImageGenerator. It looks like relying on skia implementation detail. This issue makes SkCanvasVideoRenderer manage software SkBitmap and accelerated SkBitmap explicitly. This CL makes software SkBitmap without SkImageGenerator, which is same to the code before crrev.com/531353002. It's because SkImageGenerator is introduced to accelerate YUV to RGB conversion on accelerated SkCanvas, not software SkCanvas. In addition, this CL speeds up performance when both software and accelerated SkCanvas call Paint() interleavingly. Previously, |last_frame_| uploads YUV texture and converses to RGB texture every time on accelerated SkCanvas, because software SkCanvas clears the texture cache. TEST=https://codereview.chromium.org/656683007/ BUG=424591, 91208 Committed: https://crrev.com/868f4332418328e507ed5b58c9c38ca498e926e2 Cr-Commit-Position: refs/heads/master@{#301947}

Patch Set 1 #

Total comments: 7

Patch Set 2 : Address nits, and use timer #

Total comments: 4

Patch Set 3 : Clean-up Timer code #

Total comments: 3

Patch Set 4 : address nits #

Unified diffs Side-by-side diffs Delta from patch set Stats (+108 lines, -30 lines) Patch
M media/filters/skcanvas_video_renderer.h View 1 2 2 chunks +15 lines, -2 lines 0 comments Download
M media/filters/skcanvas_video_renderer.cc View 1 2 3 10 chunks +91 lines, -28 lines 0 comments Download
M media/filters/skcanvas_video_renderer_unittest.cc View 1 2 3 2 chunks +2 lines, -0 lines 0 comments Download

Messages

Total messages: 18 (4 generated)
dshwang
scherkus@, could you review? I extract this change from https://codereview.chromium.org/445013002/ to review both easily. Test ...
6 years, 2 months ago (2014-10-17 15:10:01 UTC) #2
dshwang
https://codereview.chromium.org/662033002/diff/1/media/filters/skcanvas_video_renderer.cc File media/filters/skcanvas_video_renderer.cc (right): https://codereview.chromium.org/662033002/diff/1/media/filters/skcanvas_video_renderer.cc#newcode38 media/filters/skcanvas_video_renderer.cc:38: const int kTemporaryResourceDeletionDelay = 3; // Seconds; In crrev.com/445013002 ...
6 years, 2 months ago (2014-10-17 15:23:50 UTC) #3
dshwang
Hi scherkus, rileya Do you have a chance to review it? Thank you.
6 years, 2 months ago (2014-10-22 14:28:12 UTC) #4
scherkus (not reviewing)
mostly some nits and suggestions for clarifying the code as mentioned in my other CL, ...
6 years, 2 months ago (2014-10-22 23:17:36 UTC) #5
dshwang
On 2014/10/22 23:17:36, scherkus wrote: > mostly some nits and suggestions for clarifying the code ...
6 years, 2 months ago (2014-10-24 13:27:53 UTC) #6
dshwang
Hi scherkus, do you have a chance to review it again? Thank you!
6 years, 1 month ago (2014-10-28 13:11:02 UTC) #8
scherkus (not reviewing)
https://codereview.chromium.org/662033002/diff/40001/media/filters/skcanvas_video_renderer.cc File media/filters/skcanvas_video_renderer.cc (right): https://codereview.chromium.org/662033002/diff/40001/media/filters/skcanvas_video_renderer.cc#newcode310 media/filters/skcanvas_video_renderer.cc:310: if (frame_deleting_timer_.IsRunning()) Timer's destructor will take care of stopping ...
6 years, 1 month ago (2014-10-28 23:24:19 UTC) #9
dshwang
On 2014/10/28 23:24:19, scherkus wrote: Thank you for teaching me Timer a lot. > https://codereview.chromium.org/662033002/diff/40001/media/filters/skcanvas_video_renderer.cc ...
6 years, 1 month ago (2014-10-29 11:06:49 UTC) #10
scherkus (not reviewing)
lgtm https://codereview.chromium.org/662033002/diff/60001/media/filters/skcanvas_video_renderer.cc File media/filters/skcanvas_video_renderer.cc (right): https://codereview.chromium.org/662033002/diff/60001/media/filters/skcanvas_video_renderer.cc#newcode453 media/filters/skcanvas_video_renderer.cc:453: last_frame_timestamp_ = base::TimeDelta(); use media::kNoTimestamp() https://codereview.chromium.org/662033002/diff/60001/media/filters/skcanvas_video_renderer.cc#newcode459 media/filters/skcanvas_video_renderer.cc:459: accelerated_last_frame_timestamp_ ...
6 years, 1 month ago (2014-10-29 17:24:10 UTC) #11
scherkus (not reviewing)
that should have been "lgtm after addressing these last few nits" :)
6 years, 1 month ago (2014-10-29 17:24:26 UTC) #12
dshwang
On 2014/10/29 17:24:10, scherkus wrote: > lgtm Thank you for review! Patch becomes pretty better. ...
6 years, 1 month ago (2014-10-29 20:42:13 UTC) #14
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/662033002/100001
6 years, 1 month ago (2014-10-29 20:43:46 UTC) #16
commit-bot: I haz the power
Committed patchset #4 (id:100001)
6 years, 1 month ago (2014-10-29 22:01:22 UTC) #17
commit-bot: I haz the power
6 years, 1 month ago (2014-10-29 22:01:55 UTC) #18
Message was sent while issue was closed.
Patchset 4 (id:??) landed as
https://crrev.com/868f4332418328e507ed5b58c9c38ca498e926e2
Cr-Commit-Position: refs/heads/master@{#301947}

Powered by Google App Engine
This is Rietveld 408576698