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

Issue 2182213004: Use ChildThreadImpl::thread_safe_sender in font proxy if available (Closed)

Created:
4 years, 4 months ago by Ilya Kulshin
Modified:
4 years, 4 months ago
CC:
chromium-reviews, darin-cc_chromium.org, mlamouri+watch-content_chromium.org
Base URL:
https://chromium.googlesource.com/chromium/src.git@master
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Use ChildThreadImpl::thread_safe_sender in font proxy if available This changes the logic that the font proxy uses to get the IPC sender. It will now try to get a sender in the initialization code, and use that one if available. This allows it to get the sender while it is still running on the main thread in the plugin, so that it can use it for IPCs later when called from a different thread. This is a threading violation, but it will allow the proxy to work when called by Flash from a background thread. BUG=631254 Committed: https://crrev.com/ddaf9994ab75ff143da0c2f5c44499e49db1815f Cr-Commit-Position: refs/heads/master@{#408551}

Patch Set 1 #

Patch Set 2 : Fix unittests #

Patch Set 3 : Rebase #

Patch Set 4 : Fix unittests #

Total comments: 2

Patch Set 5 : Refactor to make cherrypick easier by reducing conflicts #

Patch Set 6 : Set thread_safe_sender in font proxy init, if available. #

Total comments: 5
Unified diffs Side-by-side diffs Delta from patch set Stats (+11 lines, -1 line) Patch
M content/child/dwrite_font_proxy/dwrite_font_proxy_init_win.cc View 1 2 3 4 5 2 chunks +11 lines, -1 line 5 comments Download

Messages

Total messages: 48 (26 generated)
Ilya Kulshin
ptal.
4 years, 4 months ago (2016-07-27 22:21:57 UTC) #9
Ilya Kulshin
ping. Can I get a review so this can make it into tomorrow's canary?
4 years, 4 months ago (2016-07-28 00:19:17 UTC) #16
Will Harris
I'm sorry I do not know the impact of this change, jam@ reviewed the original ...
4 years, 4 months ago (2016-07-28 00:20:13 UTC) #17
Ken Rockot(use gerrit already)
While I could understand if we want to just land this revert as-is since it's ...
4 years, 4 months ago (2016-07-28 15:28:31 UTC) #19
forshaw
On 2016/07/28 15:28:31, Ken Rockot wrote: > While I could understand if we want to ...
4 years, 4 months ago (2016-07-28 15:58:47 UTC) #20
jam
https://codereview.chromium.org/2182213004/diff/60001/content/child/dwrite_font_proxy/dwrite_font_proxy_win.cc File content/child/dwrite_font_proxy/dwrite_font_proxy_win.cc (left): https://codereview.chromium.org/2182213004/diff/60001/content/child/dwrite_font_proxy/dwrite_font_proxy_win.cc#oldcode351 content/child/dwrite_font_proxy/dwrite_font_proxy_win.cc:351: return sender_override_ ? sender_override_ : ChildThread::Get(); you can fix ...
4 years, 4 months ago (2016-07-28 16:34:31 UTC) #21
Ilya Kulshin
https://codereview.chromium.org/2182213004/diff/60001/content/child/dwrite_font_proxy/dwrite_font_proxy_win.cc File content/child/dwrite_font_proxy/dwrite_font_proxy_win.cc (left): https://codereview.chromium.org/2182213004/diff/60001/content/child/dwrite_font_proxy/dwrite_font_proxy_win.cc#oldcode351 content/child/dwrite_font_proxy/dwrite_font_proxy_win.cc:351: return sender_override_ ? sender_override_ : ChildThread::Get(); On 2016/07/28 16:34:31, ...
4 years, 4 months ago (2016-07-28 19:01:13 UTC) #23
Ken Rockot(use gerrit already)
On 2016/07/28 at 19:01:13, kulshin wrote: > https://codereview.chromium.org/2182213004/diff/60001/content/child/dwrite_font_proxy/dwrite_font_proxy_win.cc > File content/child/dwrite_font_proxy/dwrite_font_proxy_win.cc (left): > > https://codereview.chromium.org/2182213004/diff/60001/content/child/dwrite_font_proxy/dwrite_font_proxy_win.cc#oldcode351 ...
4 years, 4 months ago (2016-07-28 19:11:41 UTC) #24
Ilya Kulshin
On 2016/07/28 19:11:41, Ken Rockot wrote: > On 2016/07/28 at 19:01:13, kulshin wrote: > > ...
4 years, 4 months ago (2016-07-28 19:50:19 UTC) #26
Ilya Kulshin
ptal. I refactored the change to use ChildThreadImpl::thread_safe_sender, which also allowed me to remove most ...
4 years, 4 months ago (2016-07-28 19:51:02 UTC) #27
jam
https://codereview.chromium.org/2182213004/diff/120001/content/child/dwrite_font_proxy/dwrite_font_proxy_init_win.cc File content/child/dwrite_font_proxy/dwrite_font_proxy_init_win.cc (right): https://codereview.chromium.org/2182213004/diff/120001/content/child/dwrite_font_proxy/dwrite_font_proxy_init_win.cc#newcode81 content/child/dwrite_font_proxy/dwrite_font_proxy_init_win.cc:81: // Hack for crbug.com/631254: set the sender if we ...
4 years, 4 months ago (2016-07-28 22:04:43 UTC) #32
Ilya Kulshin
https://codereview.chromium.org/2182213004/diff/120001/content/child/dwrite_font_proxy/dwrite_font_proxy_init_win.cc File content/child/dwrite_font_proxy/dwrite_font_proxy_init_win.cc (right): https://codereview.chromium.org/2182213004/diff/120001/content/child/dwrite_font_proxy/dwrite_font_proxy_init_win.cc#newcode81 content/child/dwrite_font_proxy/dwrite_font_proxy_init_win.cc:81: // Hack for crbug.com/631254: set the sender if we ...
4 years, 4 months ago (2016-07-28 22:10:41 UTC) #33
ananta
lgtm
4 years, 4 months ago (2016-07-29 01:40:38 UTC) #35
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2182213004/120001
4 years, 4 months ago (2016-07-29 01:44:27 UTC) #38
commit-bot: I haz the power
Committed patchset #6 (id:120001)
4 years, 4 months ago (2016-07-29 01:47:44 UTC) #40
commit-bot: I haz the power
Patchset 6 (id:??) landed as https://crrev.com/ddaf9994ab75ff143da0c2f5c44499e49db1815f Cr-Commit-Position: refs/heads/master@{#408551}
4 years, 4 months ago (2016-07-29 01:49:32 UTC) #42
jam
https://codereview.chromium.org/2182213004/diff/120001/content/child/dwrite_font_proxy/dwrite_font_proxy_init_win.cc File content/child/dwrite_font_proxy/dwrite_font_proxy_init_win.cc (right): https://codereview.chromium.org/2182213004/diff/120001/content/child/dwrite_font_proxy/dwrite_font_proxy_init_win.cc#newcode81 content/child/dwrite_font_proxy/dwrite_font_proxy_init_win.cc:81: // Hack for crbug.com/631254: set the sender if we ...
4 years, 4 months ago (2016-07-29 22:34:58 UTC) #43
Ilya Kulshin
On 2016/07/29 22:34:58, jam wrote: > https://codereview.chromium.org/2182213004/diff/120001/content/child/dwrite_font_proxy/dwrite_font_proxy_init_win.cc > File content/child/dwrite_font_proxy/dwrite_font_proxy_init_win.cc (right): > > https://codereview.chromium.org/2182213004/diff/120001/content/child/dwrite_font_proxy/dwrite_font_proxy_init_win.cc#newcode81 > ...
4 years, 4 months ago (2016-07-29 22:38:29 UTC) #44
jam
On 2016/07/29 22:38:29, Ilya Kulshin wrote: > On 2016/07/29 22:34:58, jam wrote: > > > ...
4 years, 4 months ago (2016-07-29 23:14:08 UTC) #45
Ilya Kulshin
On 2016/07/29 23:14:08, jam wrote: > On 2016/07/29 22:38:29, Ilya Kulshin wrote: > > On ...
4 years, 4 months ago (2016-07-30 00:25:20 UTC) #46
jam
On 2016/07/30 00:25:20, Ilya Kulshin wrote: > On 2016/07/29 23:14:08, jam wrote: > > On ...
4 years, 4 months ago (2016-08-01 22:23:28 UTC) #47
Ilya Kulshin
4 years, 4 months ago (2016-08-01 22:30:18 UTC) #48
Message was sent while issue was closed.
On 2016/08/01 22:23:28, jam wrote:
> On 2016/07/30 00:25:20, Ilya Kulshin wrote:
> > On 2016/07/29 23:14:08, jam wrote:
> > > On 2016/07/29 22:38:29, Ilya Kulshin wrote:
> > > > On 2016/07/29 22:34:58, jam wrote:
> > > > >
> > > >
> > >
> >
>
https://codereview.chromium.org/2182213004/diff/120001/content/child/dwrite_f...
> > > > > File content/child/dwrite_font_proxy/dwrite_font_proxy_init_win.cc
> > (right):
> > > > > 
> > > > >
> > > >
> > >
> >
>
https://codereview.chromium.org/2182213004/diff/120001/content/child/dwrite_f...
> > > > > content/child/dwrite_font_proxy/dwrite_font_proxy_init_win.cc:81: //
> Hack
> > > for
> > > > > crbug.com/631254: set the sender if we can get one, so that when
> > > > > On 2016/07/28 22:10:41, Ilya Kulshin wrote:
> > > > > > On 2016/07/28 22:04:43, jam wrote:
> > > > > > > nit: saying hack makes it sound like this should be fixed
properly.
> > > using
> > > > > > > thread-safe sender is a standard pattern.
> > > > > > > 
> > > > > > > I would just get rid of this comment since it's documenting what
the
> > > code
> > > > is
> > > > > > > doing.
> > > > > > 
> > > > > > This should be fixed properly. One possible fix we are talking about
> is
> > to
> > > > > > detect when the pepper font api is being called from the wrong
thread,
> > and
> > > > > > marshal the call to the appropriate thread.
> > > > > 
> > > > > I don't understand this comment. That's what the SafeSender is doing
> > > > internally?
> > > > 
> > > > The SafeSender will make sure the IPC runs from the right thread,
correct?
> 
> > > 
> > > Correct>
> > > 
> > > > The
> > > > problem is that there's a bunch of non-IPC code that runs before it even
> > gets
> > > to
> > > > the point where it knows it needs to send an IPC, and that code also is
> not
> > > > being called from the right thread.
> > > 
> > > I don't know what code you're talking about. But generally the pattern is
on
> > > startup we save a pointer to safe sender and then call it later on
different
> > > threads. Can't that be done here as well?
> > > 
> > Consider the callstack in
> > https://bugs.chromium.org/p/chromium/issues/detail?id=631254#c3. This is
> > happening during process runtime, and happens to be not on the main thread.
At
> > the top of the stack is DWriteFontCollectionProxy, which actually calls the
> IPC
> > code. Before that there is Skia code, and before that there is blink code.
> > Although the code was crashing because the font proxy was unable to obtain a
> > sender, the blink code is also triggering DCHECKs because it is being called
> on
> > the wrong thread. The blink code is the code that I want to marshal to a
> > different thread (and therefore also the Skia and font proxy code that blink
> > will call). That marshaling will need to happen in
> > content::BrowserFontResource_Trusted::Describe as well as any other similar
> > functions that are called by the plugin code.
> > 
> > As far as saving a pointer to the safe sender and then calling it later on
> > different threads, that is exactly what this patch implements. It is still
not
> > sufficient, because by the time it gets to the point where it needs the
> sender,
> > we are already running code on the wrong thread.
> 
> Why can't some of the blink or pepper code in that callstack have some context
> that (indirectly or directly) holds onto the safe sender pointer? i.e.
> InitializeDWriteFontProxy is called before blink code is running.

Blink uses the DirectWrite API to talk to the font proxy, and that doesn't have
any way to pass context, other than being object-oriented. I'm also not sure I
understand your question, since the lack of context isn't an issue - the IPC
sender is saved as a member of the object, so there's no difficulty in
retrieving the saved value once inside the font proxy code.

Powered by Google App Engine
This is Rietveld 408576698