Closed Bug 83024 Opened 19 years ago Closed 4 years ago

nsClipboard::FindSelectionNotifyEvent takes 4% of new window time (XSync)

Categories

(Core :: XUL, defect, P3)

x86
Linux
defect

Tracking

()

RESOLVED WORKSFORME
mozilla1.5alpha

People

(Reporter: dbaron, Unassigned)

References

Details

(Keywords: perf)

nsClipboard::SendClipPing took 4% of new window time in a profile I took of
repeatedly opening new windows -- all of this time is in the call to XSync.  Is
this call to XSync really necessary?  Could it be XFlush instead?
Should've mentioned I'm profiling the GTK port.
CC self and adding keywords.
Keywords: mozilla1.0, perf
->pink
Assignee: trudelle → pinkerton
dr was talking about this today.
Assignee: pinkerton → dr
Blocks: 83395
I opened bug 83395 to track abuses of X. Not sure when I'll be able to tackle
the issue as a whole, but targeting this as 0.9.3 for now...
Status: NEW → ASSIGNED
Priority: -- → P3
Target Milestone: --- → mozilla0.9.3
dbaron: Are we calling SendClipPing an unusually large amount of times, or are
we calling it once and spending forever in a single XSync call?
We were calling it once.  (What does this code do?  I don't even understand what
it does so it's hard for me to know why it needs to be an XSync rather than XFlush.)
What does this code do? Beats me, I've never looked at it. I'll have a look when
I get the chance.
This is pav-code.  He's knows it best.  I don't know if I've ever looked at it.
Target Milestone: mozilla0.9.3 → mozilla1.0
May God have mercy on us all. The 212 bug spam-o-rama is Now!
QA Contact: aegis → jrgm
[spam] dr@netscape.com's bugs subject to redistribution by chofmann. R!
Assignee: dr → chofmann
Status: ASSIGNED → NEW
Priority: P3 → --
Target Milestone: mozilla1.0 → ---
dp, can you have a look and see where this one should land?
Assignee: chofmann → dp
I think this code has since changed a bit so that the time is spent in PR_Sleep
instead of XSync, but I think the problem is still there...
Changing summary: FindSelectionNotifyEvent() seems to go into a tightloop with a
timeout to get the selection. The big question is why would it do this on new
window.
Status: NEW → ASSIGNED
Priority: -- → P3
Summary: nsClipboard::SendClipPing takes 4% of new window time (XSync) → nsClipboard::FindSelectionNotifyEvent takes 4% of new window time (XSync)
Target Milestone: --- → mozilla0.9.8
I see FindSelectionNotifyEvent() event happening for mailcompose window but not
for browser windows. I guess the key is it happens whenever a text field gets
focus and the reason being to highlight paste if there was something to paste.

(gdb) bt 8
#0  nsClipboard::FindSelectionNotifyEvent (this=0x8c09eb0)
    at nsClipboard.cpp:1317
#1  0x40c4422f in nsClipboard::GetTargets (this=0x8c09eb0, aSelectionAtom=203)
    at nsClipboard.cpp:1209
#2  0x40c42f10 in nsClipboard::HasDataMatchingFlavors (this=0x8c09eb0, 
    aFlavorList=0x424f4ba8, aWhichClipboard=1, outResult=0xbfff1624)
    at nsClipboard.cpp:759
#3  0x428c63a0 in nsPlaintextEditor::CanPaste (this=0x422d7940, 
    aSelectionType=1, aCanPaste=0xbfff198c) at nsPlaintextDataTransfer.cpp:624
#4  0x428f3f87 in nsPasteCommand::IsCommandEnabled (this=0x8852180, 
    aCommandName=@0x42405958, aCommandRefCon=0x422d7940, 
    outCmdEnabled=0xbfff198c) at nsEditorCommands.cpp:228
#5  0x4166e7c0 in nsControllerCommandManager::IsCommandEnabled (
    this=0x8851e60, aCommandName=@0x42405958, aCommandRefCon=0x422d7940, 
    aResult=0xbfff198c) at nsControllerCommandManager.cpp:131
#6  0x428f8fd4 in nsEditorController::IsCommandEnabled (this=0x42426d68, 
    aCommand=@0x42405958, aResult=0xbfff198c) at nsEditorController.cpp:196
#7  0x4021c7c5 in XPTC_InvokeByIndex (that=0x42426d68, methodIndex=3, 
    paramCount=2, params=0xbfff197c) at xptcinvoke_unixish_x86.cpp:153
(More stack frames follow...)
(gdb) bt 
#0  nsClipboard::FindSelectionNotifyEvent (this=0x8c09eb0)
    at nsClipboard.cpp:1317
#1  0x40c4422f in nsClipboard::GetTargets (this=0x8c09eb0, aSelectionAtom=203)
    at nsClipboard.cpp:1209
#2  0x40c42f10 in nsClipboard::HasDataMatchingFlavors (this=0x8c09eb0, 
    aFlavorList=0x424f4ba8, aWhichClipboard=1, outResult=0xbfff1624)
    at nsClipboard.cpp:759
#3  0x428c63a0 in nsPlaintextEditor::CanPaste (this=0x422d7940, 
    aSelectionType=1, aCanPaste=0xbfff198c) at nsPlaintextDataTransfer.cpp:624
#4  0x428f3f87 in nsPasteCommand::IsCommandEnabled (this=0x8852180, 
    aCommandName=@0x42405958, aCommandRefCon=0x422d7940, 
    outCmdEnabled=0xbfff198c) at nsEditorCommands.cpp:228
#5  0x4166e7c0 in nsControllerCommandManager::IsCommandEnabled (
    this=0x8851e60, aCommandName=@0x42405958, aCommandRefCon=0x422d7940, 
    aResult=0xbfff198c) at nsControllerCommandManager.cpp:131
#6  0x428f8fd4 in nsEditorController::IsCommandEnabled (this=0x42426d68, 
    aCommand=@0x42405958, aResult=0xbfff198c) at nsEditorController.cpp:196
#7  0x4021c7c5 in XPTC_InvokeByIndex (that=0x42426d68, methodIndex=3, 
    paramCount=2, params=0xbfff197c) at xptcinvoke_unixish_x86.cpp:153
#8  0x40d928a6 in ?? ()
   from /export2/dp/trunk/mozilla/dist/bin/components/libxpconnect.so
#9  0x40d9b287 in ?? ()
   from /export2/dp/trunk/mozilla/dist/bin/components/libxpconnect.so
#10 0x4009f85b in ?? () from /export2/dp/trunk/mozilla/dist/bin/./libmozjs.so
#11 0x400aed42 in ?? () from /export2/dp/trunk/mozilla/dist/bin/./libmozjs.so
#12 0x4009f8d8 in ?? () from /export2/dp/trunk/mozilla/dist/bin/./libmozjs.so
#13 0x4009fc4f in ?? () from /export2/dp/trunk/mozilla/dist/bin/./libmozjs.so
#14 0x4006e66d in ?? () from /export2/dp/trunk/mozilla/dist/bin/./libmozjs.so
#15 0x41b5130d in ?? ()
   from /export2/dp/trunk/mozilla/dist/bin/components/libjsdom.so
#16 0x41b947d5 in ?? ()
   from /export2/dp/trunk/mozilla/dist/bin/components/libjsdom.so
#17 0x41506bd7 in nsEventListenerManager::HandleEventSubType (this=0x895ede8, 
    aListenerStruct=0x8b4d708, aDOMEvent=0x42257408, aCurrentTarget=0x8c42c18, 
    aSubType=32, aPhaseFlags=7) at nsEventListenerManager.cpp:1210
#18 0x4150a515 in nsEventListenerManager::HandleEvent (this=0x895ede8, 
    aPresContext=0x422f3f30, aEvent=0xbfff3824, aDOMEvent=0xbfff3698, 
    aCurrentTarget=0x8c42c18, aFlags=7, aEventStatus=0xbfff3750)
    at nsEventListenerManager.cpp:2200
#19 0x4165f18c in nsXULElement::HandleDOMEvent (this=0x8c42c10, 
    aPresContext=0x422f3f30, aEvent=0xbfff3824, aDOMEvent=0xbfff3698, 
    aFlags=1, aEventStatus=0xbfff3750) at nsXULElement.cpp:3426
#20 0x4167161f in nsXULCommandDispatcher::UpdateCommands (this=0x424875a8, 
    aEventName=@0xbfff3a0c) at nsXULCommandDispatcher.cpp:380
#21 0x41b61e82 in ?? ()
   from /export2/dp/trunk/mozilla/dist/bin/components/libjsdom.so
#22 0x41b53c4b in ?? ()
   from /export2/dp/trunk/mozilla/dist/bin/components/libjsdom.so
#23 0x41b53a32 in ?? ()
   from /export2/dp/trunk/mozilla/dist/bin/components/libjsdom.so
#24 0x41b54881 in ?? ()
   from /export2/dp/trunk/mozilla/dist/bin/components/libjsdom.so
#25 0x41508a34 in nsEventListenerManager::HandleEvent (this=0x42454858, 
    aPresContext=0x422f3f30, aEvent=0xbfffb52c, aDOMEvent=0xbfffafe4, 
    aCurrentTarget=0x424547d8, aFlags=4, aEventStatus=0xbfffb578)
    at nsEventListenerManager.cpp:1698
#26 0x41b7c1ea in ?? ()
   from /export2/dp/trunk/mozilla/dist/bin/components/libjsdom.so
#27 0x41b57d54 in ?? ()
   from /export2/dp/trunk/mozilla/dist/bin/components/libjsdom.so
#28 0x4167fd80 in nsXULDocument::HandleDOMEvent (this=0x4242f468, 
    aPresContext=0x422f3f30, aEvent=0xbfffb52c, aDOMEvent=0xbfffafe4, 
    aFlags=4, aEventStatus=0xbfffb578) at nsXULDocument.cpp:2432
#29 0x4165f01f in nsXULElement::HandleDOMEvent (this=0x42478018, 
    aPresContext=0x422f3f30, aEvent=0xbfffb52c, aDOMEvent=0xbfffafe4, 
    aFlags=4, aEventStatus=0xbfffb578) at nsXULElement.cpp:3410
#30 0x4165efd8 in nsXULElement::HandleDOMEvent (this=0x8961040, 
    aPresContext=0x422f3f30, aEvent=0xbfffb52c, aDOMEvent=0xbfffafe4, 
    aFlags=4, aEventStatus=0xbfffb578) at nsXULElement.cpp:3406
#31 0x4165efd8 in nsXULElement::HandleDOMEvent (this=0x8b3e2a8, 
    aPresContext=0x422f3f30, aEvent=0xbfffb52c, aDOMEvent=0xbfffafe4, 
    aFlags=4, aEventStatus=0xbfffb578) at nsXULElement.cpp:3406
#32 0x4165efd8 in nsXULElement::HandleDOMEvent (this=0x8b52ee0, 
    aPresContext=0x422f3f30, aEvent=0xbfffb52c, aDOMEvent=0xbfffafe4, 
    aFlags=4, aEventStatus=0xbfffb578) at nsXULElement.cpp:3406
#33 0x4165efd8 in nsXULElement::HandleDOMEvent (this=0x895e498, 
    aPresContext=0x422f3f30, aEvent=0xbfffb52c, aDOMEvent=0xbfffafe4, 
    aFlags=4, aEventStatus=0xbfffb578) at nsXULElement.cpp:3406
#34 0x4165efd8 in nsXULElement::HandleDOMEvent (this=0x8b55438, 
    aPresContext=0x422f3f30, aEvent=0xbfffb52c, aDOMEvent=0xbfffafe4, 
    aFlags=4, aEventStatus=0xbfffb578) at nsXULElement.cpp:3406
#35 0x4165efd8 in nsXULElement::HandleDOMEvent (this=0x8b5b4a0, 
    aPresContext=0x422f3f30, aEvent=0xbfffb52c, aDOMEvent=0xbfffafe4, 
    aFlags=4, aEventStatus=0xbfffb578) at nsXULElement.cpp:3406
#36 0x4165efd8 in nsXULElement::HandleDOMEvent (this=0x8c1a3b0, 
    aPresContext=0x422f3f30, aEvent=0xbfffb52c, aDOMEvent=0xbfffafe4, 
    aFlags=4, aEventStatus=0xbfffb578) at nsXULElement.cpp:3406
#37 0x4165efd8 in nsXULElement::HandleDOMEvent (this=0x426026a0, 
    aPresContext=0x422f3f30, aEvent=0xbfffb52c, aDOMEvent=0xbfffafe4, 
    aFlags=4, aEventStatus=0xbfffb578) at nsXULElement.cpp:3406
#38 0x4165efd8 in nsXULElement::HandleDOMEvent (this=0x422d5b88, 
    aPresContext=0x422f3f30, aEvent=0xbfffb52c, aDOMEvent=0xbfffafe4, 
    aFlags=4, aEventStatus=0xbfffb578) at nsXULElement.cpp:3406
#39 0x4165efd8 in nsXULElement::HandleDOMEvent (this=0x42487460, 
    aPresContext=0x422f3f30, aEvent=0xbfffb52c, aDOMEvent=0xbfffafe4, 
    aFlags=4, aEventStatus=0xbfffb578) at nsXULElement.cpp:3406
#40 0x4165efd8 in nsXULElement::HandleDOMEvent (this=0x424b2768, 
    aPresContext=0x422f3f30, aEvent=0xbfffb52c, aDOMEvent=0xbfffafe4, 
    aFlags=4, aEventStatus=0xbfffb578) at nsXULElement.cpp:3406
#41 0x4165efd8 in nsXULElement::HandleDOMEvent (this=0x424e30d0, 
    aPresContext=0x422f3f30, aEvent=0xbfffb52c, aDOMEvent=0xbfffafe4, 
    aFlags=4, aEventStatus=0xbfffb578) at nsXULElement.cpp:3406
#42 0x4165efd8 in nsXULElement::HandleDOMEvent (this=0x42652c50, 
    aPresContext=0x422f3f30, aEvent=0xbfffb52c, aDOMEvent=0xbfffafe4, 
    aFlags=4, aEventStatus=0xbfffb578) at nsXULElement.cpp:3406
#43 0x4165efd8 in nsXULElement::HandleDOMEvent (this=0x42458270, 
    aPresContext=0x422f3f30, aEvent=0xbfffb52c, aDOMEvent=0xbfffafe4, 
    aFlags=4, aEventStatus=0xbfffb578) at nsXULElement.cpp:3406
#44 0x41749e57 in nsGenericElement::HandleDOMEvent (this=0x424008b0, 
    aPresContext=0x422f3f30, aEvent=0xbfffb52c, aDOMEvent=0xbfffafe4, 
    aFlags=1, aEventStatus=0xbfffb578) at nsGenericElement.cpp:1845
#45 0x4156c22d in nsHTMLInputElement::HandleDOMEvent (this=0x424008b0, 
    aPresContext=0x422f3f30, aEvent=0xbfffb52c, aDOMEvent=0x0, aFlags=1, 
    aEventStatus=0xbfffb578) at nsHTMLInputElement.cpp:1147
#46 0x4151ca5e in nsEventStateManager::SendFocusBlur (this=0x424004d8, 
    aPresContext=0x422f3f30, aContent=0x424008b0)
    at nsEventStateManager.cpp:3611
#47 0x41519eb9 in nsEventStateManager::SetContentState (this=0x424004d8, 
    aContent=0x424008b0, aState=2) at nsEventStateManager.cpp:3306
#48 0x4156a7e6 in nsHTMLInputElement::SetFocus (this=0x424008b0, 
    aPresContext=0x422f3f30) at nsHTMLInputElement.cpp:742
#49 0x41534fd2 in nsGenericHTMLElement::SetElementFocus (this=0x424008b0, 
    aDoFocus=1) at nsGenericHTMLElement.cpp:4331
#50 0x4156a3d0 in nsHTMLInputElement::Focus (this=0x424008b0)
    at nsHTMLInputElement.cpp:703
#51 0x4021c7c5 in XPTC_InvokeByIndex (that=0x424008dc, methodIndex=90, 
    paramCount=0, params=0xbfffbb94) at xptcinvoke_unixish_x86.cpp:153
#52 0x40d928a6 in ?? ()
   from /export2/dp/trunk/mozilla/dist/bin/components/libxpconnect.so
#53 0x40d9b287 in ?? ()
   from /export2/dp/trunk/mozilla/dist/bin/components/libxpconnect.so
#54 0x4009f85b in ?? () from /export2/dp/trunk/mozilla/dist/bin/./libmozjs.so
#55 0x400aed42 in ?? () from /export2/dp/trunk/mozilla/dist/bin/./libmozjs.so
#56 0x4009f8d8 in ?? () from /export2/dp/trunk/mozilla/dist/bin/./libmozjs.so
#57 0x4009fc4f in ?? () from /export2/dp/trunk/mozilla/dist/bin/./libmozjs.so
#58 0x4006e66d in ?? () from /export2/dp/trunk/mozilla/dist/bin/./libmozjs.so
#59 0x41b5130d in ?? ()
   from /export2/dp/trunk/mozilla/dist/bin/components/libjsdom.so
#60 0x41b947d5 in ?? ()
   from /export2/dp/trunk/mozilla/dist/bin/components/libjsdom.so
#61 0x416e8035 in nsXBLPrototypeHandler::ExecuteHandler (this=0x8825dc0, 
    aReceiver=0x424e30d8, aEvent=0x41983fc8) at nsXBLPrototypeHandler.cpp:442
#62 0x416eb921 in nsXBLFocusHandler::Focus (this=0x424c3620, aEvent=0x41983fc8)
    at nsXBLFocusHandler.cpp:103
#63 0x41508a34 in nsEventListenerManager::HandleEvent (this=0x4247e148, 
    aPresContext=0x422f3f30, aEvent=0xbfffdf44, aDOMEvent=0xbfffdc80, 
    aCurrentTarget=0x424e30d8, aFlags=7, aEventStatus=0xbfffdf90)
    at nsEventListenerManager.cpp:1698
#64 0x4165f18c in nsXULElement::HandleDOMEvent (this=0x424e30d0, 
    aPresContext=0x422f3f30, aEvent=0xbfffdf44, aDOMEvent=0xbfffdc80, 
    aFlags=1, aEventStatus=0xbfffdf90) at nsXULElement.cpp:3426
#65 0x4151ca5e in nsEventStateManager::SendFocusBlur (this=0x424004d8, 
    aPresContext=0x422f3f30, aContent=0x424e30d0)
    at nsEventStateManager.cpp:3611
#66 0x41519eb9 in nsEventStateManager::SetContentState (this=0x424004d8, 
    aContent=0x424e30d0, aState=2) at nsEventStateManager.cpp:3306
#67 0x4166449b in nsXULElement::SetFocus (this=0x424e30d0, 
    aPresContext=0x422f3f30) at nsXULElement.cpp:4534
#68 0x41663c6b in nsXULElement::Focus (this=0x424e30d0)
    at nsXULElement.cpp:4439
Looks like the fix would be to delay figuring out if paste should be highlighted
or not up until absolutely required - On popup of the menu. I think the menu in
question is the "cut, copy, paste" menu that shows up when we right click on a
text window. Over to editor folks.
Assignee: dp → akkana
Status: ASSIGNED → NEW
If we aren't doing that now, then my guess is that this would require a
reworking of the command handling system.  Simon, are you still the command
handling guru?  If not, who is?  Is it possible to delay checking for paste
until a menu containing that command is popped up?  (Of course, this assumes
there's no toolbar with the command on it, though there's an RFE against the
editor requesting a toolbar paste button.  If nothing else, this would help the
browser window's startup time.)
Assignee: akkana → sfraser
0.9.9
Target Milestone: mozilla0.9.8 → mozilla0.9.9
Over to 1.0
Status: NEW → ASSIGNED
Target Milestone: mozilla0.9.9 → mozilla1.0
Moving Netscape owned 0.9.9 and 1.0 bugs that don't have an nsbeta1, nsbeta1+,
topembed, topembed+, Mozilla0.9.9+ or Mozilla1.0+ keyword.  Please send any
questions or feedback about this to adt@netscape.com.  You can search for
"Moving bugs not scheduled for a project" to quickly delete this bugmail.
Target Milestone: mozilla1.0 → mozilla1.2
please look at bug 56219, comment #42 and the supplied patch
i cant evalute it myself
this needs a new milestone btw 
Target Milestone: mozilla1.2alpha → mozilla1.5alpha
Is this still an issue?
Assignee: sfraser_bugs → jag
Status: ASSIGNED → NEW
Assignee: jag → nobody
nsClipboard::FindSelectionNotifyEvent does not exist in current m-c.
Status: NEW → RESOLVED
Closed: 4 years ago
Resolution: --- → WORKSFORME
You need to log in before you can comment on or make changes to this bug.