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

RESOLVED INACTIVE

Status

()

Core
DOM
P2
normal
RESOLVED INACTIVE
5 years ago
3 days ago

People

(Reporter: yxl, Unassigned)

Tracking

({perf})

Firefox Tracking Flags

(Not tracked)

Details

(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

Updated

5 years ago
Keywords: perf
Whiteboard: [c= p= u= s=]

Comment 3

5 years ago
(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)

Comment 5

3 days ago
Per policy at https://wiki.mozilla.org/Bug_Triage/Projects/Bug_Handling/Bug_Husbandry#Inactive_Bugs. If this bug is not an enhancement request or a bug not present in a supported release of Firefox, then it may be reopened.
Status: NEW → RESOLVED
Last Resolved: 3 days ago
Resolution: --- → INACTIVE
You need to log in before you can comment on or make changes to this bug.