New issue
Advanced search Search tips

Issue 681738 link

Starred by 2 users

Issue metadata

Status: Fixed
Owner:
Closed: Jan 2017
Cc:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 3
Type: Bug



Sign in to add a comment

Refactor PowerSaveBlocker to not using AnchorView

Project Member Reported by jinsuk...@chromium.org, Jan 17 2017

Issue description

Before I forget - It was mentioned (though briefly) during the code view https://crrev.com/2103243002 that PowerSaveBlocker may deserve refactoring in the way that it avoids creating an anchor view just to call View.keepScreenOn, since keeping screen on is supposed to work globally, not at the view level. 

Instead, ViewAndroidDelegate issues on/off request to WindowAndroid where we keep a view on which we call keepScreenOn. Or just maintain a refcount variable to invoke a callback to turn it on or off when refcount goes above or to zero. The actual work can go up further to activity level. May need examining against Chrome and WebView.
 

Comment 1 by boliu@chromium.org, Jan 17 2017

did I say that? :p

switching anchor views was specifically for webview, so that it's power save blocker only kicks in if the webview is attached and whatnot. webview isn't supposed to modify global state, because then webview and app can stomp each other, so we don't want to switch to using setting flags in the window
> did I say that? :p

It was sievers@' observation.

> so we don't want to switch to using setting flags in the window

Hm... then how about use its container view rather than creating/destroying an anchor view? Would become rather a minor change but at least we can save ourselves from creating/destroying views. It's just that it doesn't look like a suitable use case of anchor view for PowerSaveBlocker just to call |keepScreenOn|.

Comment 3 by boliu@chromium.org, Jan 18 2017

> Hm... then how about use its container view rather than creating/destroying an anchor view?

I'm ok with that.

I guess in theory apps could still modify that state on webview. But then we can just tell apps to stop doing that.
Status: Fixed (was: Assigned)
Summary: Refactor PowerSaveBlocker to not using AnchorView (was: Refactor PowerSaveBloker to not using AnchorView)

Comment 6 by jiad...@gmail.com, Jul 18 2017

we found an issue related to this change.
containerView will be changed when exitFullScreen is called. refered:
https://cs.chromium.org/chromium/src/android_webview/java/src/org/chromium/android_webview/AwContents.java?type=cs&q=setContainerView&sq=package:chromium&l=880

setKeepScreenOn for the previous containerView will be ignored by the android system.  

The case is 
 playing a video on youtube, click fullscreen playing. the screen will go to sleep after 1 min timeout.
Thanks for the report. Could you give me more detailed step, and if possible, a test webview app which the issue can be reproduced with? I just tested this with a simple webview-based app but can't reproduce it. Even in fullscreen mode the power save blocker still holds the on-screen lock to prevent the screen from entering sleep/dimmed mode. It is tested with the accompanying change in AwContentsClientFullScreenTest.java See the tests like testPowerSaveBlockerIsEnabledDuringFullscreenPlayback_*. 
We also found The issue mentioned by #C6  
This can be reproduced with SystemWebviewShell.apk. It Happens for every HTML5 video

SampleURL: https://mounirlamouri.github.io/sandbox/fullscreen-orientation.htm

[Steps]
1. enter fullscreen
2. pause the video if it's playing
3. play the video
4. exit fullscreen

=> the handset goes to sleep after screen timeout.

The reason is that if user play the video after switching to full screen, FullScreenView (current ContainerView) gains the wakelock.
When user leaves full screen, the FullScreenView is detached. The wakelock no longer works.

Sign in to add a comment