window.onblur() is not fired when android activity loses input focus. |
|||||||||||||
Issue descriptionThe context for this bug is I'm implementing a feature that delivers head tracking data for VR through the WebVR API, and we only want to expose this data to the focused frame. On Android, frames don't lose focus when the application is paused, either by hiding Chrome, or switching to another app in multiwindow mode. This is because on Android we listen for focus changes using onFocusChanged, which doesn't care if the app is paused or hidden and doesn't actually have input focus (it has input focus *for the app*, regardless of whether the app has focus). I think Chrome on Android should match the behaviour of other platforms and change the focused state when the window (activity) loses input focus regardless of whether the view has focus.
,
Jan 27 2017
,
Jan 27 2017
,
Jan 27 2017
+aelias@ for general focus +twellington@ for multiwindow When Chrome is hidden, we call hide on the webcontents (Tab.java#onActivityHidden is called from onStopWithNative which is when the activity is fully hidden). I'm surprised that doesn't implicitly result in a blur. ContentViewCore already has onWindowFocusChanged, if we see that we have focus but the window loses focus, we could potentially send a blur (and refocus later as well). I don't know all the implications of that and I'll defer to Alex there.
,
Jan 27 2017
Seems OK to make that change. I tested with example http://output.jsbin.com/luquqoh that iOS Safari sends a blur event when going to homescreen. So Clank seems like the outlier. > Also more generally, have we put thought into side-channel attacks related to exposing high-accuracy accelerometer data to pages without input focus? Looks like timvolodine@ wrote the accelerometer code, he would know.
,
Jan 30 2017
,
Feb 9 2017
aelias@, are you willing to take this on (or find somebody who is)? This is definitely outside of my area of expertise.
,
Feb 9 2017
Well, I might not have time to get to this in a while -- I'd prefer if you wrote the patch, and I'd be happy to answer questions and code review. I'm sure you could quickly develop the necessary expertise with a bit of code search on how focus works (same as I'd need to do). I generally encourage subprojects that are blocked on deeper problems in Chrome to go ahead and fix it themselves -- that scales better than everybody only writing patches in their code silos.
,
Feb 10 2017
For hardware related apis like sensors we actually disable them when page is invisible. (not sure if this also applies to WebVR but would expect it should). Regarding 'side-channel' considerations I was actually working on this although it's not focus based at the moment.
,
Feb 21 2017
Lowering priority as this only affect multi-window for VR. When the app is backgrounded we already stop sending pose data, so it's not as big of an issue that the page isn't blurred.
,
Mar 24 2017
,
Mar 24 2017
,
Mar 29 2017
,
Mar 29 2017
also cc'ing kochi@ for focus
,
Apr 10 2017
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/460ffe75e23987ac6760d668963d9d2f1a83962b commit 460ffe75e23987ac6760d668963d9d2f1a83962b Author: mthiesse <mthiesse@chromium.org> Date: Mon Apr 10 21:08:46 2017 [Android] Focus/Blur contents when window focus changes This ensure that when an activity loses input focus (OnWindowFocusChanged), that the web page is blurred and not considered to be focused. BUG= 686232 Review-Url: https://codereview.chromium.org/2779033004 Cr-Commit-Position: refs/heads/master@{#463390} [modify] https://crrev.com/460ffe75e23987ac6760d668963d9d2f1a83962b/chrome/android/java/src/org/chromium/chrome/browser/ChromeActivity.java [modify] https://crrev.com/460ffe75e23987ac6760d668963d9d2f1a83962b/chrome/android/javatests/src/org/chromium/chrome/browser/ContentViewFocusTest.java [add] https://crrev.com/460ffe75e23987ac6760d668963d9d2f1a83962b/chrome/test/data/android/content_view_focus/content_view_blur_focus.html [modify] https://crrev.com/460ffe75e23987ac6760d668963d9d2f1a83962b/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java
,
Apr 11 2017
Noting for posterity that this doesn't precisely track input focus to the WebContents, so it's not exactly analogous to other platforms (due to popup views stealing input focus), but it should behave as users would expect. |
|||||||||||||
►
Sign in to add a comment |
|||||||||||||
Comment 1 by mthiesse@chromium.org
, Jan 27 2017