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

Issue 2329323002: Avoid blocking while mapping an X11 window (Closed)

Created:
4 years, 3 months ago by dackerman
Modified:
3 years, 9 months ago
CC:
chromium-reviews, tfarina
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Avoid blocking while mapping an X11 window For most window managers, calling XMapWindow causes a corresponding MapNotify event to fire, indicating it is ready for drawing. Since this usually happens immediately, but asynchronously, chromium previously blocked the UI thread until it got this event, to avoid calling any further X11 commands on the window until it was ready. Unfortunately, not all window managers fire MapNotify in all cases. For example, the i3 window manager will not fire MapNotify for a newly created window while you're in fullscreen mode (i.e. youtube video). This means chromium blocks indefinitely until the user manually exits out of fullscreen mode. The fix here is to avoid blocking, since we cannot make the assumption that we'll get a MapNotify event quickly. By simply not blocking on window map, we create two issues. The first issue occurs when dragging tabs outside a window to create a new one. The newly created window would fail to size itself properly according to the space given to it by the window manager. This was because the delayed_resize_task_ would get cancelled by SetBounds during the time the thread would have otherwise been blocked. This issue was fixed by only cancelling the task when the bounds changed in that function, since that's the only time it will call OnHostResized itself. The second issue occurs during TooltipControllerTests, where a tooltip is shown/hidden, and then immediately calls IsVisible() on the widget (which eventually calls it on the underlying native window). Since the mapping is now async, IsVisible() was false until MapNotify was called. The fix for this was to keep track of an additional variable for when we are waiting for a MapNotify event, and using that to make IsVisible() true during this time (after calling MapWindow, and before getting MapNotify). BUG=505669

Patch Set 1 #

Total comments: 8

Patch Set 2 : Remove UnmapNotify blocking, simplify visibility #

Total comments: 2

Patch Set 3 : Added David Ackerman to AUTHORS #

Patch Set 4 : Fix GlobalCommandsApiTest.GlobalCommand #

Patch Set 5 : Fix GlobalCommandsApiTest.GlobalCommand #

Patch Set 6 : Fix GlobalCommandsApiTest.GlobalCommand #

Patch Set 7 : UpdateMinAndMaxSize in MapWindow #

Unified diffs Side-by-side diffs Delta from patch set Stats (+45 lines, -39 lines) Patch
M AUTHORS View 1 2 1 chunk +1 line, -0 lines 0 comments Download
M chrome/browser/extensions/extension_commands_global_registry_apitest.cc View 1 2 3 4 5 3 chunks +32 lines, -10 lines 0 comments Download
M ui/events/platform/x11/x11_event_source.h View 1 1 chunk +0 lines, -2 lines 0 comments Download
M ui/events/platform/x11/x11_event_source.cc View 1 1 chunk +0 lines, -4 lines 0 comments Download
M ui/views/widget/desktop_aura/desktop_window_tree_host_x11.h View 1 1 chunk +3 lines, -5 lines 0 comments Download
M ui/views/widget/desktop_aura/desktop_window_tree_host_x11.cc View 1 2 3 4 5 6 7 chunks +9 lines, -18 lines 0 comments Download

Messages

Total messages: 64 (50 generated)
dackerman
I ran the views_unittests locally with my setup - regular master has 9 failed tests. ...
4 years, 3 months ago (2016-09-11 21:47:16 UTC) #4
Elliot Glaysher
Started a dry CQ run for you. Also added Dana and Tom since they might ...
4 years, 3 months ago (2016-09-12 22:23:21 UTC) #8
Tom (Use chromium acct)
Thank you David for putting in this CL I'm a bit worried about the race ...
4 years, 3 months ago (2016-09-12 22:45:07 UTC) #12
dackerman
On 2016/09/12 22:45:07, Tom Anderson wrote: > Thank you David for putting in this CL ...
4 years, 3 months ago (2016-09-18 23:17:41 UTC) #13
dackerman
oops, I didn't realize I had to click "Publish+Mail Comments" :-/ https://codereview.chromium.org/2329323002/diff/1/ui/views/widget/desktop_aura/desktop_window_tree_host_x11.cc File ui/views/widget/desktop_aura/desktop_window_tree_host_x11.cc (left): ...
4 years, 3 months ago (2016-09-23 14:12:37 UTC) #14
Tom (Use chromium acct)
https://codereview.chromium.org/2329323002/diff/1/ui/views/widget/desktop_aura/desktop_window_tree_host_x11.cc File ui/views/widget/desktop_aura/desktop_window_tree_host_x11.cc (left): https://codereview.chromium.org/2329323002/diff/1/ui/views/widget/desktop_aura/desktop_window_tree_host_x11.cc#oldcode1901 ui/views/widget/desktop_aura/desktop_window_tree_host_x11.cc:1901: // Block until our window is unmapped. This avoids ...
4 years, 3 months ago (2016-09-23 18:35:49 UTC) #15
dackerman
I removed the BlockUntilWindowUnmapped and simplified the visibility check as requested (it definitely looks much ...
4 years, 2 months ago (2016-09-25 19:45:36 UTC) #21
Tom (Use chromium acct)
lgtm, but I have no OWNERS power here. You'll need erg@ or sadrul@ to review ...
4 years, 2 months ago (2016-09-26 17:26:04 UTC) #22
Elliot Glaysher
lgtm owners stamp
4 years, 2 months ago (2016-09-26 20:43:23 UTC) #23
sadrul
lgtm!
4 years, 2 months ago (2016-09-27 01:05:39 UTC) #28
dackerman
On 2016/09/27 01:05:39, sadrul wrote: > lgtm! Great to see the lgtms, but in the ...
4 years, 2 months ago (2016-09-29 13:38:05 UTC) #29
Tom (Use chromium acct)
On 2016/09/29 13:38:05, dackerman wrote: > On 2016/09/27 01:05:39, sadrul wrote: > > lgtm! > ...
4 years, 2 months ago (2016-09-29 17:09:43 UTC) #30
dackerman
On 2016/09/29 17:09:43, Tom Anderson wrote: > On 2016/09/29 13:38:05, dackerman wrote: > > On ...
4 years, 2 months ago (2016-10-02 23:20:00 UTC) #45
Tom (Use chromium acct)
4 years, 2 months ago (2016-10-03 18:23:19 UTC) #56
On 2016/10/02 23:20:00, dackerman wrote:
> On 2016/09/29 17:09:43, Tom Anderson wrote:
> > On 2016/09/29 13:38:05, dackerman wrote:
> > > On 2016/09/27 01:05:39, sadrul wrote:
> > > > lgtm!
> > > 
> > > Great to see the lgtms, but in the trybot results I see a couple red boxes
-
> > it
> > > looks like the following is failing:
> > > ManagePasswordsBubbleViewTest.AutoSigninNoFocus
> > > GlobalCommandsApiTest.GlobalCommand
> > > WidgetTest.MinimumSizeConstraints
> > > 
> > > Are these actual failures that are caused by my CL, or potential existing
> > > issues? 
> > 
> > Most likely we just need to rerun the tests
> > 
> > > If the former, I'll look into them (although I think
> > > WidgetTest.MinimumSizeConstraints at least fails on master for even my
local
> > > setup). If the latter, how do I merge this? Is there documentation on it?
> > 
> > However one thing you do need to change for sure is add yourself to the
> AUTHORS
> > file, you can do that in the next patch set.
> > 
> > ** Presubmit Warnings **
> > mailto:David.W.Ackerman@gmail.com is not in AUTHORS file. If you are a new
> contributor,
> > please visit
> > http://www.chromium.org/developers/contributing-code and read the "Legal"
> > section
> > If you are a chromite, verify the contributor signed the CLA.
> 
> So I think the GlobalCommandsApiTest.GlobalCommand test was actually failing
> (broken after my change, not on master according to my local setup). It seemed
> that it was just firing key events too quickly (i.e. before mapping
happened)...
> I fixed it in a way that feels wrong, so please advise if you think there's a
> better way.  There's also a tab dragging test that seems to be failing here
> (TabDragging/DetachToBrowserTabDragControllerTest.DeleteTabsWhileDetached/0) -
> but on my local setup it also fails in the same way on master, and I am not
able
> to understand what is actually happening to figure out how to fix it.

Ok, I've taken a look and it appears the failure in
WidgetTest.MinimumSizeConstraints is here
https://cs.chromium.org/chromium/src/ui/views/widget/widget_unittest.cc?rcl=0...

GetNativeWidgetMinimumContentSize() calls XGetWMNormalHints here
https://cs.chromium.org/chromium/src/ui/views/test/widget_test_aura.cc?rcl=0&...

But, we set the WmNormalHints in DesktopWindowTreeHostX11::UpdateMinAndMaxSize
which is supposed to get called after receiving a MapNotify here:
https://cs.chromium.org/chromium/src/ui/views/widget/desktop_aura/desktop_win...

It looks like xfwm actually has problems with WM_NORMAL_HINTS getting changed
after a map.  I also peeked at the GTK source code and they set WM_NORMAL_HINTS
before mapping.

A blame points to this revision
https://chromium.googlesource.com/chromium/src/+/c07049637%5E%21/#F5
It looks like it was simply a mistake to add the call to UpdateMinAndMaxSize
after the map.

Please remove UpdateMinAndMaxSize() from the MapNotify and add it in
DesktopWindowTreeHostX11::MapWindow() before the XMapWindow()

Powered by Google App Engine
This is Rietveld 408576698