Closed Bug 445765 Opened 16 years ago Closed 15 years ago

window.screen sometimes maps to wrong screen in multiple monitor environment

Categories

(Core :: Layout, defect)

defect
Not set
normal

Tracking

()

VERIFIED FIXED
mozilla1.9.3a1
Tracking Status
status1.9.2 --- beta1-fixed

People

(Reporter: sylvain.pasche, Assigned: tnikkel)

References

Details

Attachments

(3 files)

The screen property fetched from a root window does not map to the current screen where the window is located, but to the main window. The property is correct if read from a child window. This means it is correct for content window, but not browser window (thus causing bug 445749).

In fact nsScreen::GetDeviceContext() returns a deviceContext that has no associated nsIWidget (mWidget is null), so nsThebesDeviceContext::FindScreen() uses GetPrimaryScreen() which is not correct when the window is on the right screen.
OS: Linux → All
Hardware: PC → All
Blocks: 436304
Flags: blocking1.9.2?
No longer blocks: ctrl-tab-panel
No longer blocks: 436304
This sounds like a widget level bug to me. Reassigning.
Component: DOM: Core & HTML → Widget
QA Contact: general → general
Attached patch patchSplinter Review
In getting the device context from a docshell don't go through nsIBaseWindow::GetMainWidget because that always returns the device context for the primary screen when called on toplevel docshell.
Assignee: nobody → tnikkel
Attachment #396094 - Flags: review?(dbaron)
Blocks: 377539
Comment on attachment 396094 [details] [diff] [review]
patch

I don't feel like much of an expert on this, but I have no idea who would, so r=dbaron.
Keywords: checkin-needed
http://hg.mozilla.org/mozilla-central/rev/6b686281f9ac
Status: NEW → RESOLVED
Closed: 15 years ago
Component: Widget → Layout
Keywords: checkin-needed
QA Contact: general → layout
Resolution: --- → FIXED
Target Milestone: --- → mozilla1.9.3a1
Could this have affected Txul?

Regression: Txul increase 3.19% on Linux Firefox

Previous results: 108.947 from build 20090822192711 of revision 0c55df2e3f99 at 2009-08-22 19:27:00 on talos-rev2-linux18 run # 0

New results: 112.421 from build 20090822232404 of revision 6b686281f9ac at 2009-08-22 23:24:00 on talos-rev2-linux01 run # 0

Suspected checkin range: from revision 0c55df2e3f99 to revision 6b686281f9ac

Checkin range only includes this bug.
The graphs were pretty clear, so I backed it out:

http://hg.mozilla.org/mozilla-central/rev/85899e12310f
http://hg.mozilla.org/mozilla-central/rev/e455909e2a17

I'm pretty surprised, though.  Maybe it changed something about initialization order because something gets window.screen early in window creation?


We'll see if the backout fixes the regression, at least...
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
I'm stumped for now. I've stepped through both the new and old code running Txul, nothing is created, nothing happens that would seem to take any more time, just a bunch of ref/com ptr and queryinterface stuff. There are 3 calls to GetDeviceContextForScreenInfo on a window creation, two come through nsXULWindow::OnChromeLoaded for availHeight and availWidth, one comes from js when onload fires wanting availWidth. On Linux, the actual screen properties are stored in the nsScreenGTK on Init and only changed via event callback as far as I can tell.
Doing some timing on my debug build I found a culprit taking about 30ms (everything else was dwarfed by this). The device context we get via nsIBaseWidget::GetMainWidget doesn't have a widget, so any screen related calls to that device context default to the primary screen. But if we do have a widget (what the patch in this bug does) then we have to go through nsScreenManagerGtk::ScreenForNativeWidget which makes two system calls that can sometimes be expensive. These system calls are a waste of time on single monitor systems because we can only ever return the one monitor. So skip the system calls in the common one monitor case.

Could someone submit these two patches in this bug to the tryserver so we can determine if the Txul regression is solved?
Attachment #396313 - Flags: review?(dbaron)
OK, I just pushed it to tryserver. I'm not going to push anything else tonight so it will be the latest rocallahan@mozilla.com build as of tomorrow morning.
Oops, I did two pushes, one with just the first patch and one with both patches.
Thank you for Robert for sending it to the try server.

Because of the two pushes I'm having trouble identifying which Twinopen result has both patches incorporated. One has a bad Twinopen time of 115.37 and one has a good time of 108.61. I'm not sure how try works, I would imagine it clears all changes and go back to a clean m-c pull after every push. In that case it seems like Robert did two pushes, each with one patch?
Figured it out by looking at the files on the hg webserver for those revisions. The 108.61 is for both patches, 115.37 is for just the first patch. So the second patch does solve the Txul regression.
Comment on attachment 396313 [details] [diff] [review]
bypass expensive system calls for one monitor case

r=dbaron.

But it would be good to get a bug filed on the multi-monitor case here too; taking a 3% new window time hit for multi-monitor isn't exactly ideal.
Attachment #396313 - Flags: review?(dbaron) → review+
http://hg.mozilla.org/mozilla-central/rev/b5f5c94eba5d
http://hg.mozilla.org/mozilla-central/rev/eacf5f1da49c

Don't forget to file that bug, though.
Status: REOPENED → RESOLVED
Closed: 15 years ago15 years ago
Resolution: --- → FIXED
Thanks for landing those.

Bug 513985 filed on making nsScreenManagerGtk::ScreenForNativeWidget faster in the multi-monitor case. I would have filed it sooner (and added checkin-needed) but I wanted to think about the issue a little bit more.
Attachment #396313 - Flags: approval1.9.2?
Attachment #396094 - Flags: approval1.9.2?
Attachment #396094 - Flags: approval1.9.2? → approval1.9.2+
Attachment #396313 - Flags: approval1.9.2? → approval1.9.2+
Keywords: checkin-needed
Flags: blocking1.9.2? → wanted1.9.2+
Verified Fixed on Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2a2pre) Gecko/20090915 Namoroka/3.6a2pre (.NET CLR 3.5.30729) ID:20090915052755
Status: RESOLVED → VERIFIED
Blocks: songbird
Depends on: 547469
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: