|
|
Chromium Code Reviews|
Created:
4 years, 6 months ago by tzik Modified:
4 years, 6 months ago CC:
chromium-reviews, dshwang, ajuma+watch-canvas_chromium.org, blink-reviews-html_chromium.org, Justin Novosad, dglazkov+blink, Rik, blink-reviews, hiroshige Base URL:
https://chromium.googlesource.com/chromium/src.git@master Target Ref:
refs/pending/heads/master Project:
chromium Visibility:
Public. |
DescriptionRetain strong reference of BlobCallback in CanvasAsyncBlobCreator
CanvasAsyncBlobCreator holds a BlobCallback and runs it asynchronously.
However, it can be destroyed before the callback invocation, and the
callback doesn't retain its ownership while it's in the task queue.
This CL makes the bound task to retain the shared ownership of
BlobCallback.
BUG=621547
Committed: https://crrev.com/e7d195955d69a096ba28bcb4be85df1d64ffa2a8
Cr-Commit-Position: refs/heads/master@{#401052}
Patch Set 1 #
Total comments: 2
Patch Set 2 : s/wrapCrossThreadPersistent/wrapPersistent/ #Messages
Total messages: 20 (7 generated)
tzik@chromium.org changed reviewers: + haraken@chromium.org
PTAL
LGTM
The CQ bit was checked by tzik@chromium.org
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/2081873003/1
sigbjornf@opera.com changed reviewers: + sigbjornf@opera.com
https://codereview.chromium.org/2081873003/diff/1/third_party/WebKit/Source/c... File third_party/WebKit/Source/core/html/canvas/CanvasAsyncBlobCreator.cpp (right): https://codereview.chromium.org/2081873003/diff/1/third_party/WebKit/Source/c... third_party/WebKit/Source/core/html/canvas/CanvasAsyncBlobCreator.cpp:267: Platform::current()->mainThread()->getWebTaskRunner()->postTask(BLINK_FROM_HERE, bind(&BlobCallback::handleEvent, wrapCrossThreadPersistent(m_callback.get()), resultBlob)); I don't understand; the m_callback was created on the main thread and we're posting it to the main thread again here -- where's the cross-thread aspect?
The CQ bit was unchecked by tzik@chromium.org
https://codereview.chromium.org/2081873003/diff/1/third_party/WebKit/Source/c... File third_party/WebKit/Source/core/html/canvas/CanvasAsyncBlobCreator.cpp (right): https://codereview.chromium.org/2081873003/diff/1/third_party/WebKit/Source/c... third_party/WebKit/Source/core/html/canvas/CanvasAsyncBlobCreator.cpp:267: Platform::current()->mainThread()->getWebTaskRunner()->postTask(BLINK_FROM_HERE, bind(&BlobCallback::handleEvent, wrapCrossThreadPersistent(m_callback.get()), resultBlob)); On 2016/06/21 14:08:38, sof wrote: > I don't understand; the m_callback was created on the main thread and we're > posting it to the main thread again here -- where's the cross-thread aspect? Oops, I missed the ASSERT above and thought they are same to encodeImageOnEncoderThread(). Fixed.
On 2016/06/21 14:14:56, tzik wrote: > https://codereview.chromium.org/2081873003/diff/1/third_party/WebKit/Source/c... > File third_party/WebKit/Source/core/html/canvas/CanvasAsyncBlobCreator.cpp > (right): > > https://codereview.chromium.org/2081873003/diff/1/third_party/WebKit/Source/c... > third_party/WebKit/Source/core/html/canvas/CanvasAsyncBlobCreator.cpp:267: > Platform::current()->mainThread()->getWebTaskRunner()->postTask(BLINK_FROM_HERE, > bind(&BlobCallback::handleEvent, wrapCrossThreadPersistent(m_callback.get()), > resultBlob)); > On 2016/06/21 14:08:38, sof wrote: > > I don't understand; the m_callback was created on the main thread and we're > > posting it to the main thread again here -- where's the cross-thread aspect? > > Oops, I missed the ASSERT above and thought they are same to > encodeImageOnEncoderThread(). > Fixed. The rules are in flux here, so I may have out-of-date info, but don't we get persistent/retained for free for T* (where T is a GCed type)?
On 2016/06/21 14:21:04, sof wrote: > On 2016/06/21 14:14:56, tzik wrote: > > > https://codereview.chromium.org/2081873003/diff/1/third_party/WebKit/Source/c... > > File third_party/WebKit/Source/core/html/canvas/CanvasAsyncBlobCreator.cpp > > (right): > > > > > https://codereview.chromium.org/2081873003/diff/1/third_party/WebKit/Source/c... > > third_party/WebKit/Source/core/html/canvas/CanvasAsyncBlobCreator.cpp:267: > > > Platform::current()->mainThread()->getWebTaskRunner()->postTask(BLINK_FROM_HERE, > > bind(&BlobCallback::handleEvent, wrapCrossThreadPersistent(m_callback.get()), > > resultBlob)); > > On 2016/06/21 14:08:38, sof wrote: > > > I don't understand; the m_callback was created on the main thread and we're > > > posting it to the main thread again here -- where's the cross-thread aspect? > > > > Oops, I missed the ASSERT above and thought they are same to > > encodeImageOnEncoderThread(). > > Fixed. > > The rules are in flux here, so I may have out-of-date info, but don't we get > persistent/retained for free for T* (where T is a GCed type)? It's true for now, but will no longer true soon. I'm removing raw pointers from WTF::bind.
On 2016/06/21 14:25:42, tzik wrote: > On 2016/06/21 14:21:04, sof wrote: > > On 2016/06/21 14:14:56, tzik wrote: > > > > > > https://codereview.chromium.org/2081873003/diff/1/third_party/WebKit/Source/c... > > > File third_party/WebKit/Source/core/html/canvas/CanvasAsyncBlobCreator.cpp > > > (right): > > > > > > > > > https://codereview.chromium.org/2081873003/diff/1/third_party/WebKit/Source/c... > > > third_party/WebKit/Source/core/html/canvas/CanvasAsyncBlobCreator.cpp:267: > > > > > > Platform::current()->mainThread()->getWebTaskRunner()->postTask(BLINK_FROM_HERE, > > > bind(&BlobCallback::handleEvent, > wrapCrossThreadPersistent(m_callback.get()), > > > resultBlob)); > > > On 2016/06/21 14:08:38, sof wrote: > > > > I don't understand; the m_callback was created on the main thread and > we're > > > > posting it to the main thread again here -- where's the cross-thread > aspect? > > > > > > Oops, I missed the ASSERT above and thought they are same to > > > encodeImageOnEncoderThread(). > > > Fixed. > > > > The rules are in flux here, so I may have out-of-date info, but don't we get > > persistent/retained for free for T* (where T is a GCed type)? > > It's true for now, but will no longer true soon. I'm removing raw pointers from > WTF::bind. ok, being explicit is worth it here. But disallowing the use of Member<> in bind() seems like a well-worthy followup.
lgtm
Thanks for pointing it out. PS2 looks correct.
The CQ bit was checked by tzik@chromium.org
The patchset sent to the CQ was uploaded after l-g-t-m from haraken@chromium.org Link to the patchset: https://codereview.chromium.org/2081873003/#ps20001 (title: "s/wrapCrossThreadPersistent/wrapPersistent/")
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/2081873003/20001
Message was sent while issue was closed.
Committed patchset #2 (id:20001)
Message was sent while issue was closed.
Description was changed from ========== Retain strong reference of BlobCallback in CanvasAsyncBlobCreator CanvasAsyncBlobCreator holds a BlobCallback and runs it asynchronously. However, it can be destroyed before the callback invocation, and the callback doesn't retain its ownership while it's in the task queue. This CL makes the bound task to retain the shared ownership of BlobCallback. BUG=621547 ========== to ========== Retain strong reference of BlobCallback in CanvasAsyncBlobCreator CanvasAsyncBlobCreator holds a BlobCallback and runs it asynchronously. However, it can be destroyed before the callback invocation, and the callback doesn't retain its ownership while it's in the task queue. This CL makes the bound task to retain the shared ownership of BlobCallback. BUG=621547 Committed: https://crrev.com/e7d195955d69a096ba28bcb4be85df1d64ffa2a8 Cr-Commit-Position: refs/heads/master@{#401052} ==========
Message was sent while issue was closed.
Patchset 2 (id:??) landed as https://crrev.com/e7d195955d69a096ba28bcb4be85df1d64ffa2a8 Cr-Commit-Position: refs/heads/master@{#401052} |
