Closed
Bug 1159660
Opened 10 years ago
Closed 10 years ago
[System][WindowManager] check activeElement before focus or blur a mozbrowser iframe
Categories
(Firefox OS Graveyard :: Gaia::System::Window Mgmt, defect)
Tracking
(Not tracked)
RESOLVED
FIXED
People
(Reporter: johnhu, Assigned: johnhu)
References
Details
Attachments
(1 file)
As we known, call focus() on a mozbrowser iframe consumes a lot of performance. We should prevent that. Because changing it, we should also check if call blur() on a mozbrowser iframe costs a lot.
Assignee | ||
Updated•10 years ago
|
Blocks: system-focus
Assignee | ||
Updated•10 years ago
|
Assignee: nobody → im
Assignee | ||
Comment 1•10 years ago
|
||
I had done two different test cases:
1. Calculate elapsed time while we call focus() and blur() synchronized and calculate the average time used by focus() and blur()[1].
The average time of 100 times call focus() and blur() synchronized is 8.7488ms
2. Calculate elapsed time between focus() => focus event and blur() => blur event[2].
The average time of 100 times from focus() to focus event is 3.2067 ms.
The average time of 100 times from blur() to blur event is 0.6719 ms.
[1] https://github.com/huchengtw-moz/gaia/commit/2e9e6ac77c1f6918cf3bbdd2648e7bd8e24f1410
[2] https://github.com/huchengtw-moz/gaia/commit/aab51de6904956824ec984c7415fbfd021b68abd
Assignee | ||
Comment 2•10 years ago
|
||
If I commented out [1] which means we try to call focus() multiple times without call blur(), it seems that gecko had already checked if a mozbrowser iframe is activeElement. The average time of it is 0.186 ms.
[1] https://github.com/huchengtw-moz/gaia/commit/2e9e6ac77c1f6918cf3bbdd2648e7bd8e24f1410#diff-8e3ee5eaa7effd00d972282afc13f1c8R14
Assignee | ||
Comment 3•10 years ago
|
||
The implementation of HTMLElement.focus() of Gecko is at [1]. It uses focus manager's setFocus() and which calls SetFocusInner() to focus it. Theoretically, comment 2 is wrong. But I had tried to add event listener of focus and blur at the test case of comment 2. It doesn't fire extra focus or blur events.
[1] https://dxr.mozilla.org/mozilla-central/source/dom/html/nsGenericHTMLElement.cpp#2583-2589
Assignee | ||
Comment 4•10 years ago
|
||
More information about comment 3:
According to the code [1][2], gecko doesn't check if an element is activeElement. So, I feel comment 2 is wrong.
[1] https://dxr.mozilla.org/mozilla-central/source/dom/html/nsGenericHTMLElement.cpp#2583-2589
[2] https://dxr.mozilla.org/mozilla-central/source/dom/base/nsFocusManager.cpp#1161
Comment 5•10 years ago
|
||
Assignee | ||
Comment 6•10 years ago
|
||
Comment on attachment 8600836 [details] [review]
[gaia] huchengtw-moz:bug-1159660-check-before-focus > mozilla-b2g:master
Currently, I don't know how to measure it. The patch is ready. But I will discuss this with others about why comment 2 and comment 3/4 is conflict.
Assignee | ||
Comment 7•10 years ago
|
||
Comment on attachment 8600836 [details] [review]
[gaia] huchengtw-moz:bug-1159660-check-before-focus > mozilla-b2g:master
As per comment 1, we still need to check activeElement before changing focus. Please review this patch.
Attachment #8600836 -
Flags: review?(alive)
Comment 8•10 years ago
|
||
Comment on attachment 8600836 [details] [review]
[gaia] huchengtw-moz:bug-1159660-check-before-focus > mozilla-b2g:master
only nit: put a comment to explain why do this
Attachment #8600836 -
Flags: review?(alive) → review+
Assignee | ||
Comment 9•10 years ago
|
||
merged to master:
https://github.com/mozilla-b2g/gaia/commit/eb3f82f3b947f1ed52fa4e9246bed0f0b3e49785
tree herder is all green:
https://treeherder.mozilla.org/#/jobs?repo=gaia&revision=0ab56c16152011b5d4ef8d3f75730a92dd2feb34
Status: NEW → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
Assignee | ||
Comment 10•10 years ago
|
||
Thanks for the finding from Sean Lin. He found that gecko will check if an element is focused before focus it[1]. But we still need this patch.
[1] https://dxr.mozilla.org/mozilla-central/source/dom/base/nsFocusManager.cpp#1187-1191
You need to log in
before you can comment on or make changes to this bug.
Description
•