From 9cc2d03bddf3d11804fa5ac06662220f1e21b3ce Mon Sep 17 00:00:00 2001 From: Mattias Falk Date: Fri, 25 May 2012 09:40:31 +0200 Subject: Pause WebView timer when Browser is paused If the Browser is paused while loading a page it shall finish loading the page before the WebView timer is paused. The WebView timer shall be paused in onProgressChanged when the progress has reached 100 not from onPageFinished since onPageFinished is called when the main frame is loaded and at that time subframe and other resources might haven't been finished loaded i.e. the page is still in load, which the result in WebView timers are not paused. With this patch the Browser won't consume system resources if it's minimized while doing a page load. Change-Id: Id971dbcedfbedb5b0e56cba4076cd724d590ac85 --- src/com/android/browser/Controller.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'src/com/android/browser/Controller.java') diff --git a/src/com/android/browser/Controller.java b/src/com/android/browser/Controller.java index ebfd56f..ec7ff48 100644 --- a/src/com/android/browser/Controller.java +++ b/src/com/android/browser/Controller.java @@ -860,11 +860,6 @@ public class Controller public void onPageFinished(Tab tab) { mCrashRecoveryHandler.backupState(); mUi.onTabDataChanged(tab); - // pause the WebView timer and release the wake lock if it is finished - // while BrowserActivity is in pause state. - if (mActivityPaused && pauseWebViewTimers(tab)) { - releaseWakeLock(); - } // Performance probe if (false) { @@ -889,6 +884,10 @@ public class Controller // onPageFinished has executed) if (tab.inPageLoad()) { updateInLoadMenuItems(mCachedMenu, tab); + } else if (mActivityPaused && pauseWebViewTimers(tab)) { + // pause the WebView timer and release the wake lock if it is + // finished while BrowserActivity is in pause state. + releaseWakeLock(); } if (!tab.isPrivateBrowsingEnabled() && !TextUtils.isEmpty(tab.getUrl()) -- cgit v1.1