Open Bug 868292 Opened 11 years ago Updated 2 years ago

nsIDOMWindowUtils.sendKeyEvent is much slower in content process than that in chrome process

Categories

(Core :: DOM: Core & HTML, defect, P5)

x86_64
Linux
defect

Tracking

()

People

(Reporter: xyuan, Unassigned)

Details

(Keywords: perf, Whiteboard: [c= p= u= s=])

This is a followup of Bug 860546(https://bugzilla.mozilla.org/show_bug.cgi?id=860546).

When nsIDOMWindowUtils.sendKeyEvent is used to synthesize key events, it runs much slower in content processes than that in chrome process. 

A simple test on b2g-desktop of Ubuntu 12.04 64bit shows that it takes 1 second to run nsIDOMWindowUtils.sendKeyEvent 3000 times in the system app and 25 seconds to run in the contacts and email app.
Which IPC method do we call? Is it sync or async?
Sync and async calls get the same results. 

Async method tested in chrome process is MozKeyboard.sendKey in the file b2g/components/MozKeyboard.js:

https://mxr.mozilla.org/mozilla-central/source/b2g/components/MozKeyboard.js#84

76   sendKey: function mozKeyboardSendKey(keyCode, charCode) {
77     charCode = (charCode == undefined) ? keyCode : charCode;
78 
79     let mainThread = tm.mainThread;
80     let utils = this._utils;
81 
82     function send(type) {
83       mainThread.dispatch(function() {
84 	utils.sendKeyEvent(type, keyCode, charCode, null);
85       }, mainThread.DISPATCH_NORMAL);
86     }
87 
88     send("keydown");
89     send("keypress");
90     send("keyup");
91   },

Move sendKey to content process in the file b2g/chrome/content/forms.js with the following patch will be much slower:

https://bug860546.bugzilla.mozilla.org/attachment.cgi?id=738997
Keywords: perf
Whiteboard: [c= p= u= s=]
(In reply to Yuan Xulei [:yxl] from comment #2)
> Sync and async calls get the same results. 
> 
> Async method tested in chrome process is MozKeyboard.sendKey in the file
> b2g/components/MozKeyboard.js:
> 
> https://mxr.mozilla.org/mozilla-central/source/b2g/components/MozKeyboard.
> js#84
> 

Looks like this file has moved. Yuan does your comment above still apply here? https://mxr.mozilla.org/mozilla-central/source/dom/inputmethod/MozKeyboard.js#87
Component: General → DOM
Flags: needinfo?(xyuan)
Priority: -- → P2
Product: Firefox OS → Core
(In reply to Mike Lee [:mlee] from comment #3)
> (In reply to Yuan Xulei [:yxl] from comment #2)
> > Sync and async calls get the same results. 
> > 
> > Async method tested in chrome process is MozKeyboard.sendKey in the file
> > b2g/components/MozKeyboard.js:
> > 
> > https://mxr.mozilla.org/mozilla-central/source/b2g/components/MozKeyboard.
> > js#84
> > 
> 
> Looks like this file has moved. Yuan does your comment above still apply
> here?
> https://mxr.mozilla.org/mozilla-central/source/dom/inputmethod/MozKeyboard.
> js#87
Yes, still here.
Flags: needinfo?(xyuan)
https://bugzilla.mozilla.org/show_bug.cgi?id=1472046

Move all DOM bugs that haven’t been updated in more than 3 years and has no one currently assigned to P5.

If you have questions, please contact :mdaly.
Priority: P2 → P5
Component: DOM → DOM: Core & HTML
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.