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

Issue 1781613002: Fix data race problem in createImageBitmap(Blob) (Closed)

Created:
4 years, 9 months ago by xidachen
Modified:
4 years, 9 months ago
CC:
chromium-reviews, blink-reviews
Base URL:
https://chromium.googlesource.com/chromium/src.git@master
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Fix data race problem in createImageBitmap(Blob) In createImageBitmap(Blob), the method creates an ImageDecoder in a background thread, does the image decoding in the same thread, and pass the ImageDecoder back to the main thread for creating an ImageBitmap. This is causing the data race problem because the ImageDecoder does some non-atomic reference counts internally. This CL should fix the data race problem. In particular, we let the ImageDecoder does image decoding in the background thread, and creates a SkImage from the ImageDecoder, and pass the SkImage across threads. Because SkImage is thread-safe RefCnted, this solves the data race problem. In order to let postTask taking a SkImage, this CL changes the CrossThreadCopier so that it can take an object that is SkRefCnt. Locally I was able to repro the test case reported in the bug by using the tsan build. With this CL the data race goes away. Also, an existing layout tests that have data race condition is changed. BUG=593224 Committed: https://crrev.com/283d18607e366095c377ddf72d196a8c4e256429 Cr-Commit-Position: refs/heads/master@{#380609}

Patch Set 1 #

Total comments: 2

Patch Set 2 : pass SkImage across thread instead of ImageDecoder #

Patch Set 3 : switch back to ImageDecoder instead of DeferredImageDecoder #

Patch Set 4 : PassRefPtr<SkImage> instead of SkImage* #

Patch Set 5 : fix data rance layout test #

Unified diffs Side-by-side diffs Delta from patch set Stats (+21 lines, -9 lines) Patch
M third_party/WebKit/LayoutTests/virtual/threaded/fast/canvas-toBlob/canvas-createImageBitmap-blob-in-workers.html View 1 2 3 4 1 chunk +6 lines, -2 lines 0 comments Download
M third_party/WebKit/Source/core/imagebitmap/ImageBitmapFactories.h View 1 2 3 2 chunks +2 lines, -1 line 0 comments Download
M third_party/WebKit/Source/core/imagebitmap/ImageBitmapFactories.cpp View 1 2 3 1 chunk +7 lines, -5 lines 0 comments Download
M third_party/WebKit/Source/platform/CrossThreadCopier.h View 1 2 chunks +6 lines, -1 line 0 comments Download

Messages

Total messages: 35 (18 generated)
xidachen
PTAL. junov@: I tried to use the idea of creating the ImageDecoder on the main ...
4 years, 9 months ago (2016-03-09 16:29:48 UTC) #3
Justin Novosad
https://codereview.chromium.org/1781613002/diff/1/third_party/WebKit/Source/core/imagebitmap/ImageBitmapFactories.cpp File third_party/WebKit/Source/core/imagebitmap/ImageBitmapFactories.cpp (right): https://codereview.chromium.org/1781613002/diff/1/third_party/WebKit/Source/core/imagebitmap/ImageBitmapFactories.cpp#newcode237 third_party/WebKit/Source/core/imagebitmap/ImageBitmapFactories.cpp:237: RefPtr<SkImage> frame = decoder->createFrameAtIndex(0); Have you verified this in ...
4 years, 9 months ago (2016-03-09 16:41:03 UTC) #4
xidachen
https://codereview.chromium.org/1781613002/diff/1/third_party/WebKit/Source/core/imagebitmap/ImageBitmapFactories.cpp File third_party/WebKit/Source/core/imagebitmap/ImageBitmapFactories.cpp (right): https://codereview.chromium.org/1781613002/diff/1/third_party/WebKit/Source/core/imagebitmap/ImageBitmapFactories.cpp#newcode237 third_party/WebKit/Source/core/imagebitmap/ImageBitmapFactories.cpp:237: RefPtr<SkImage> frame = decoder->createFrameAtIndex(0); On 2016/03/09 16:41:03, Justin Novosad ...
4 years, 9 months ago (2016-03-09 17:49:26 UTC) #5
Justin Novosad
On 2016/03/09 17:49:26, xidachen wrote: > https://codereview.chromium.org/1781613002/diff/1/third_party/WebKit/Source/core/imagebitmap/ImageBitmapFactories.cpp > File third_party/WebKit/Source/core/imagebitmap/ImageBitmapFactories.cpp > (right): > > https://codereview.chromium.org/1781613002/diff/1/third_party/WebKit/Source/core/imagebitmap/ImageBitmapFactories.cpp#newcode237 ...
4 years, 9 months ago (2016-03-09 17:57:14 UTC) #6
xidachen
junov@: Right now the ImageDecoder is created an destroyed in the background thread, and a ...
4 years, 9 months ago (2016-03-09 18:54:36 UTC) #9
Justin Novosad
+reed as an FYI : This CL makes blink recognize that SkRefCnt does ref counting ...
4 years, 9 months ago (2016-03-09 19:10:54 UTC) #11
Justin Novosad
core/ lgtm
4 years, 9 months ago (2016-03-09 19:13:24 UTC) #12
reed1
+more skia refcnt experts
4 years, 9 months ago (2016-03-09 19:16:12 UTC) #14
haraken
platform/ LGTM
4 years, 9 months ago (2016-03-09 23:27:27 UTC) #15
commit-bot: I haz the power
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1781613002/50001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1781613002/50001
4 years, 9 months ago (2016-03-10 00:22:57 UTC) #17
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1781613002/50001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1781613002/50001
4 years, 9 months ago (2016-03-10 02:55:25 UTC) #20
commit-bot: I haz the power
Try jobs failed on following builders: win_chromium_rel_ng on tryserver.chromium.win (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.win/builders/win_chromium_rel_ng/builds/186947)
4 years, 9 months ago (2016-03-10 05:34:33 UTC) #22
xidachen
junov@: the latest PS fix the layout test that has data race condition. PTAL.
4 years, 9 months ago (2016-03-10 16:35:53 UTC) #24
commit-bot: I haz the power
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1781613002/70001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1781613002/70001
4 years, 9 months ago (2016-03-10 18:39:43 UTC) #27
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1781613002/70001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1781613002/70001
4 years, 9 months ago (2016-03-11 12:21:35 UTC) #31
commit-bot: I haz the power
Committed patchset #5 (id:70001)
4 years, 9 months ago (2016-03-11 12:26:19 UTC) #33
commit-bot: I haz the power
4 years, 9 months ago (2016-03-11 12:27:13 UTC) #35
Message was sent while issue was closed.
Patchset 5 (id:??) landed as
https://crrev.com/283d18607e366095c377ddf72d196a8c4e256429
Cr-Commit-Position: refs/heads/master@{#380609}

Powered by Google App Engine
This is Rietveld 408576698