Closed
Bug 849647
Opened 12 years ago
Closed 12 years ago
It's better to remove message order optimization on Windows if it's possible
Categories
(Core :: Widget: Win32, defect)
Tracking
()
RESOLVED
FIXED
mozilla23
People
(Reporter: masayuki, Assigned: masayuki)
References
(Depends on 1 open bug)
Details
Attachments
(1 file, 2 obsolete files)
14.83 KB,
patch
|
jimm
:
review+
|
Details | Diff | Splinter Review |
https://bugzilla.mozilla.org/show_bug.cgi?id=840409#c39
I think that we should remove the message order optimization on Windows if it's possible. The reason is, some other applications such as Japanese IME ATOK may expect the message order which is described in MSDN (http://msdn.microsoft.com/en-us/library/windows/desktop/ms644943%28v=vs.85%29.aspx). The order is,
1 Sent messages
2 Posted messages
3 Input (hardware) messages and system internal events
4 Sent messages (again)
5 WM_PAINT messages
6 WM_TIMER messages
See bug 466487, this bug is now back in TSF mode. And also it seems that CUAS (does something for TSF unaware applications automatically) is also confused by the reordered message. CUAS probably hooks some messages and they perform something in TSF. For example, swapping the order of WM_FOCUS and WM_KEYDOWN might cause confusing TSF.
Currently, we give the highest priority to #3 since bug 22979 comment 20 without any explanation.
And roc tried to remove it at bug 36849, but it's backed out at bug 36849 comment 69 due to performance issue during incremental layout.
However, MetroWidget doesn't do such message order optimization. And performance of Windows PC is very very improved since 2000. Additionally, Gecko is redesigned for better performance and architecture.
So, I *guess* that now, we can remove the message optimization for getting back standard behavior of Windows application.
# If a lot of strange message blocks user input, we can blacklist them and compare the time stamps of the message and the first input message.
If you know something additional information about this, let's share it.
Assignee | ||
Comment 1•12 years ago
|
||
If you can remove it, that'll be great, but it's risky.
Assignee | ||
Comment 3•12 years ago
|
||
Yeah, the risk is highest I have ever experienced. However, the return is very big if we'll succeed.
First shot of the patch:
https://hg.mozilla.org/try/rev/d7b6509c938d
Assignee | ||
Comment 4•12 years ago
|
||
Here is the test build:
https://tbpl.mozilla.org/?tree=Try&usebuildbot=1&rev=25202386afcd
How do I test "incremental layout" which is the cause of backing out the patch of bug 36849?
And what regressions are possible?
I don't see difference between patched build and m-c except the ATOK behavior.
Assignee | ||
Comment 5•12 years ago
|
||
I think the key issue that caused the backout in bug 36849 was that PLEvents (which are now XPCOM events) were being prioritized over native paint events. So don't do that :-).
Assignee | ||
Comment 7•12 years ago
|
||
Thank you roc for the information. However, I don't know the PLEvents and the XPCOM events. PLEvents were defined as WM_USER+n or WM_APP+n? And XPCOM events are still so?
My current idea of the patch is, basically, we don't touch the event order. So, any messages must be given higher priority than WM_PAINT. However, for ensuring the responsiveness, if non-system message is too newer than the oldest system message, then, the patch gives priority to the system messages while non-system message isn't so newer than the oldest system message.
Assignee | ||
Comment 8•12 years ago
|
||
My idea for landing the patch is, we'll land the patch on m-c as far as possible. And after next merge, the patch is going to be backed out from Aurora for testing longer on Nightly. So, I think that the patch should be tested over 6 weeks on Nightly.
Comment 9•12 years ago
|
||
(In reply to Robert O'Callahan (:roc) (Mozilla Corporation) from comment #6)
> I think the key issue that caused the backout in bug 36849 was that PLEvents
> (which are now XPCOM events) were being prioritized over native paint
> events. So don't do that :-).
They will be I think, via nsAppShell's post message handler which calls NativeEventCallback() -
http://mxr.mozilla.org/mozilla-central/source/widget/windows/nsAppShell.cpp#84
http://mxr.mozilla.org/mozilla-central/source/widget/xpwidgets/nsBaseAppShell.cpp#63
Windows prioritizes posted messages, note the comments here -
http://mxr.mozilla.org/mozilla-central/source/widget/windows/nsAppShell.cpp#170
Maybe this fix for modal dialogs will help solve the problem.
Comment 10•12 years ago
|
||
Here's a blurb on msdn about paints, they fall to the very bottom.
http://msdn.microsoft.com/en-us/library/windows/desktop/ms644927%28v=vs.85%29.aspx
Since we don't pluck paints out and give them higher priority I'm not sure if this changes anything. Our posted message already have a higher priority than paints.
Assignee | ||
Comment 11•12 years ago
|
||
Let's venture this.
I believe that we should land this patch on weekend because check-in is fewer than weekdays, then, we can check the regression easier.
And we should back this out from Aurora after next merge for testing enough long time on Nightly.
I don't modify the comment of
http://mxr.mozilla.org/mozilla-central/source/widget/windows/nsAppShell.cpp#170
because I don't understand the comment enough. If you think we should update it too, I'd like you to suggest good comment.
I'm requesting the review to only jimm. I have no plan to request it to other developers. However, you are welcome to comment anything about this.
Assignee: nobody → masayuki
Attachment #723557 -
Attachment is obsolete: true
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true
Assignee | ||
Updated•12 years ago
|
Attachment #726087 -
Flags: review?
Assignee | ||
Comment 12•12 years ago
|
||
Jimm:
Could you review the patch? Bugzilla shows "You must enter a valid bug number!" error if I input reviewer's email address.
Flags: needinfo?(jmathies)
Comment 13•12 years ago
|
||
Comment on attachment 726087 [details] [diff] [review]
Patch
Review of attachment 726087 [details] [diff] [review]:
-----------------------------------------------------------------
::: widget/windows/nsAppShell.cpp
@@ +205,5 @@
> + // Give priority to enough old system message in the queue rather than
> + // newer posted user/app message. This ensures responsiveness even
> + // while somebody fills our thread's message queue with a lot of
> + // user/app messages.
> + if (msg.message >= WM_USER) {
Are we really concerned about this? I've never seen any bugs filed about it.
Attachment #726087 -
Flags: review? → review?(jmathies)
Flags: needinfo?(jmathies)
Comment 14•12 years ago
|
||
(In reply to Masayuki Nakano (:masayuki) (Mozilla Japan) from comment #11)
> I don't modify the comment of
> http://mxr.mozilla.org/mozilla-central/source/widget/windows/nsAppShell.
> cpp#170
> because I don't understand the comment enough. If you think we should update
> it too, I'd like you to suggest good comment.
I'd suggest testing your patch against the heavy js overhead testcase in the following bug:
https://bugzilla.mozilla.org/show_bug.cgi?id=575515
Assignee | ||
Comment 15•12 years ago
|
||
(In reply to Jim Mathies [:jimm] from comment #13)
> Comment on attachment 726087 [details] [diff] [review]
> Patch
>
> Review of attachment 726087 [details] [diff] [review]:
> -----------------------------------------------------------------
>
> ::: widget/windows/nsAppShell.cpp
> @@ +205,5 @@
> > + // Give priority to enough old system message in the queue rather than
> > + // newer posted user/app message. This ensures responsiveness even
> > + // while somebody fills our thread's message queue with a lot of
> > + // user/app messages.
> > + if (msg.message >= WM_USER) {
>
> Are we really concerned about this? I've never seen any bugs filed about it.
There is bug 378830. However, currently, Flash Player is always run in another process on Vista or later.
http://mxr.mozilla.org/mozilla-central/source/dom/plugins/base/nsNPAPIPlugin.cpp#278
Additionally, Flash Player makes another process for protected mode on Vista or later.
So, currently, Flash Player must not need to post the message into the our message queue.
However, I guess that it could be a problem on XP if the users disables OOPP. I'll try to check this later.
If there is no problem, indeed, removing the hack is also great.
(In reply to Jim Mathies [:jimm] from comment #14)
> (In reply to Masayuki Nakano (:masayuki) (Mozilla Japan) from comment #11)
> > I don't modify the comment of
> > http://mxr.mozilla.org/mozilla-central/source/widget/windows/nsAppShell.
> > cpp#170
> > because I don't understand the comment enough. If you think we should update
> > it too, I'd like you to suggest good comment.
>
>
> I'd suggest testing your patch against the heavy js overhead testcase in the
> following bug:
>
> https://bugzilla.mozilla.org/show_bug.cgi?id=575515
Thanks, I'll check it.
FYI: the bugzilla's problem was bug 852072, which is now fixed.
Comment 16•12 years ago
|
||
FWIW, adobe updated the behavior of flash related to their app messages, they throttle these better. I'm not sure what version this was in but it was fixed about two years ago.
Assignee | ||
Comment 17•12 years ago
|
||
Thank you, jimm. That's very good news. I'll remove the block and I'll test it again.
Assignee | ||
Comment 18•12 years ago
|
||
https://tbpl.mozilla.org/?tree=Try&usebuildbot=1&rev=71c86588e4eb
Looks like no problem even if it's too busy by running heavy script.
And I confirmed that even if OOPP is disabled on WinXP, I can type some text normally while playing high refresh rate flush contents.
Attachment #726087 -
Attachment is obsolete: true
Attachment #726087 -
Flags: review?(jmathies)
Attachment #726656 -
Flags: review?(jmathies)
Assignee | ||
Comment 19•12 years ago
|
||
And this patch gets rid of calls of PeekMessage() with PM_NOREMOVE. Therefore, this patch reduce a lot of virtual call in WidgetUtils::PeekMessage() in TSF mode. That must improve the performance of TSF mode.
Comment 20•12 years ago
|
||
Comment on attachment 726656 [details] [diff] [review]
Patch
What are you plans, landing this now or waiting until after the next merge?
Attachment #726656 -
Flags: review?(jmathies) → review+
Assignee | ||
Comment 21•12 years ago
|
||
My plans are:
1. landing this weekend for easier regression check.
2. backing out after next merge from Aurora and testing more 6 weeks on Nightly (I mean 23 is the first version of this fix included for testing this over 6 weeks on Nightly).
Assignee | ||
Comment 22•12 years ago
|
||
Comment 23•12 years ago
|
||
Status: ASSIGNED → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla22
Assignee | ||
Comment 24•12 years ago
|
||
Backed out from Aurora, see bug 857829.
Target Milestone: mozilla22 → mozilla23
Assignee | ||
Updated•12 years ago
|
Keywords: helpwanted
Comment 25•11 years ago
|
||
We're trying to find the source of a regression in bug 878449 that is present on Aurora but not Beta. Would it be OK to back this out of aurora temporarily to see if the crash goes away?
Comment 26•11 years ago
|
||
It doesn't seem like it's related by the way, but there's a limited number of bugs in widget / windows that could have an effect and this one is the closest: https://bugzilla.mozilla.org/buglist.cgi?f1=cf_status_firefox22&list_id=6858673&o1=notequals&resolution=FIXED&o2=notequals&query_format=advanced&f2=cf_status_firefox22&v1=fixed&component=Widget%3A%20Win32&v2=verified&product=Core&target_milestone=mozilla23
Assignee | ||
Comment 27•11 years ago
|
||
Hmm, even if this patch causes the crash, it means that it shows another hidden bug. I strongly recommend that we should not backout this patch since the change risk is too high.
You need to log in
before you can comment on or make changes to this bug.
Description
•