[Stingray] Lost focus after pinning TV channel occasionally

RESOLVED FIXED

Status

Firefox OS
Gaia::TV
RESOLVED FIXED
3 years ago
3 years ago

People

(Reporter: dwi2, Assigned: johnhu)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(2 attachments, 2 obsolete attachments)

(Reporter)

Description

3 years ago
STR:
1. After boot-up, enter TV app
2. pin channel with lower-left pin button

Expected result:
Back to smart-home app and the focus is on the latest pinned TV channel

Actual result:
There are around 1/3 chances that the focus is still on TV app.
Assignee: nobody → im
I found a STR which almost gives us 100% reproduce ratio:

1. open tv deck
2. pin
3. press up/down while animation running
I had put log at browser_mixin.js before blur and focus. The log shows it focuses to smart-home correct and no following logs. This means gaia doesn't call tv deck's focus(). But document.activeElement gives us tv deck at this time.
I had tried another test case. I set an interval with 100ms. It showed that the focus had set to smart-home and after few ms, it goes back to tv deck.
Sean,

This is the one I told you. Please help us to check it from gecko's point of view.
Flags: needinfo?(selin)
Created attachment 8602008 [details] [diff] [review]
remove-focus.patch

It's so strange. If I remove the focus function call in TV deck, this issue is disappeared.

It seems the local focus in TV deck may affect the local focus in system app.
Created attachment 8602015 [details] [diff] [review]
more specific test patch

We only need to remove this line to workaround it.
Attachment #8602008 - Attachment is obsolete: true
Comment on attachment 8602015 [details] [diff] [review]
more specific test patch

False alarm.

This issue is so hard to reproduce. Once I applied this patch, the issue is still there.

Another STR to reproduce it is:
1. open TV deck
2. press enter continuously.
Attachment #8602015 - Attachment is obsolete: true
Created attachment 8602036 [details] [diff] [review]
app-deck-test-patch.patch

We could reproduce the same issue with this patch. This is confirmed with Sung.
STR of comment 8:

1. open app deck
2. press enter continuously

Once affected, you may find the focus moved to left top corner of app deck.
Deassign myself until Sean Lin gives us more information.
Assignee: im → nobody
Take this back since we had offline discussion about this.
Assignee: nobody → im
Created attachment 8602496 [details] [review]
[gaia] huchengtw-moz:bug-1161940-move-focus-to-known-element-while-animating > mozilla-b2g:master
Comment on attachment 8602496 [details] [review]
[gaia] huchengtw-moz:bug-1161940-move-focus-to-known-element-while-animating > mozilla-b2g:master

Rex,

I had changed the code to move focus to an element instead of body to prevent other apps request focus from smart-home app. Please review this patch. Thanks.
Attachment #8602496 - Flags: review?(rexboy)
The root cause is as follows (based on the STR in comment 9):

1. When the focus is set to smart-home, it only focuses the frame without explicitly setting focus to any element inside it. (The focused window is smart-home but focused content is null in this case.) 

2. So a follow-up attempt to set focus to a smart button in app-deck could "steal" the focus. (The focused window becomes app-deck and the focused content becomes the smart button.)

On the other hand, John's patch forces the focus on an element inside smart-home in step 1. Since the current focused content is non-null, the attempt in step 2 would trigger the security constraint [1] to prevent the focus move, since smart-home and app-deck cannot access each other's content due to same-origin policy.

[1] https://dxr.mozilla.org/mozilla-central/source/dom/base/nsFocusManager.cpp#1280-1298
Flags: needinfo?(selin)
Comment on attachment 8602496 [details] [review]
[gaia] huchengtw-moz:bug-1161940-move-focus-to-known-element-while-animating > mozilla-b2g:master

Basically it's OK but I'm not sure if it's the case on opening delete dialog. See my comments. Please discuss with me before landing.
Comment on attachment 8602496 [details] [review]
[gaia] huchengtw-moz:bug-1161940-move-focus-to-known-element-while-animating > mozilla-b2g:master

r=me but please move the function to a new util.js.
Thank you!
Attachment #8602496 - Flags: review?(rexboy) → review+
Whiteboard: checkin-needed
Keywords: checkin-needed
Whiteboard: checkin-needed

Updated

3 years ago
Keywords: checkin-needed

Updated

3 years ago
Status: NEW → RESOLVED
Last Resolved: 3 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.