Changeset 231676 in webkit
- Timestamp:
- May 10, 2018 4:35:32 PM (6 years ago)
- Location:
- trunk/Source/WebKit
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/ChangeLog
r231664 r231676 1 2018-05-10 Chris Dumez <cdumez@apple.com> 2 3 [iOS] Release page load process assertion if the screen is locked 4 https://bugs.webkit.org/show_bug.cgi?id=185333 5 6 Reviewed by Geoff Garen. 7 8 We normally take a background process assertion during page loads to allow them to complete 9 even if the tab / app is backgrounded. We should however avoid doing so when the backgrounding 10 is caused by the screen locking. Keeping the process assertion in this case would prevent the 11 whole device from sleeping longer than it should, thus negatively impacting power. 12 13 * UIProcess/Cocoa/NavigationState.h: 14 * UIProcess/Cocoa/NavigationState.mm: 15 (WebKit::NavigationState::NavigationState): 16 (WebKit::NavigationState::releaseNetworkActivityToken): 17 (WebKit::NavigationState::didChangeIsLoading): 18 * UIProcess/ios/WebPageProxyIOS.mm: 19 (WebKit::WebPageProxy::applicationDidEnterBackground): 20 1 21 2018-05-10 Megan Gardner <megan_gardner@apple.com> 2 22 -
trunk/Source/WebKit/UIProcess/Cocoa/NavigationState.h
r231498 r231676 83 83 void didFirstPaint(); 84 84 85 #if PLATFORM(IOS) 86 enum class NetworkActivityTokenReleaseReason { LoadCompleted, ScreenLocked }; 87 void releaseNetworkActivityToken(NetworkActivityTokenReleaseReason); 88 #endif 89 85 90 private: 86 91 class NavigationClient final : public API::NavigationClient { … … 173 178 174 179 #if PLATFORM(IOS) 175 void releaseNetworkActivityToken ();180 void releaseNetworkActivityTokenAfterLoadCompletion() { releaseNetworkActivityToken(NetworkActivityTokenReleaseReason::LoadCompleted); } 176 181 #endif 177 182 -
trunk/Source/WebKit/UIProcess/Cocoa/NavigationState.mm
r231663 r231676 98 98 , m_historyDelegateMethods() 99 99 #if PLATFORM(IOS) 100 , m_releaseActivityTimer(RunLoop::current(), this, &NavigationState::releaseNetworkActivityToken )100 , m_releaseActivityTimer(RunLoop::current(), this, &NavigationState::releaseNetworkActivityTokenAfterLoadCompletion) 101 101 #endif 102 102 { … … 1146 1146 1147 1147 #if PLATFORM(IOS) 1148 void NavigationState::releaseNetworkActivityToken() 1149 { 1150 RELEASE_LOG_IF(m_webView->_page->isAlwaysOnLoggingAllowed(), ProcessSuspension, "%p UIProcess is releasing a background assertion because a page load completed", this); 1151 ASSERT(m_activityToken); 1148 void NavigationState::releaseNetworkActivityToken(NetworkActivityTokenReleaseReason reason) 1149 { 1150 if (!m_activityToken) 1151 return; 1152 1153 switch (reason) { 1154 case NetworkActivityTokenReleaseReason::LoadCompleted: 1155 RELEASE_LOG_IF(m_webView->_page->isAlwaysOnLoggingAllowed(), ProcessSuspension, "%p NavigationState is releasing background process assertion because a page load completed", this); 1156 break; 1157 case NetworkActivityTokenReleaseReason::ScreenLocked: 1158 RELEASE_LOG_IF(m_webView->_page->isAlwaysOnLoggingAllowed(), ProcessSuspension, "%p NavigationState is releasing background process assertion because the screen was locked", this); 1159 break; 1160 } 1152 1161 m_activityToken = nullptr; 1162 m_releaseActivityTimer.stop(); 1153 1163 } 1154 1164 #endif … … 1158 1168 #if PLATFORM(IOS) 1159 1169 if (m_webView->_page->pageLoadState().isLoading()) { 1170 // We do not take a network activity token if a load starts after the screen has been locked. 1171 if ([UIApp isSuspendedUnderLock]) 1172 return; 1173 1160 1174 if (m_releaseActivityTimer.isActive()) { 1161 RELEASE_LOG_IF(m_webView->_page->isAlwaysOnLoggingAllowed(), ProcessSuspension, "%p - A new page load started while the UIProcess was still holding a page load background assertion", this);1175 RELEASE_LOG_IF(m_webView->_page->isAlwaysOnLoggingAllowed(), ProcessSuspension, "%p - NavigationState keeps its process network assertion because a new page load started", this); 1162 1176 m_releaseActivityTimer.stop(); 1163 } else {1164 RELEASE_LOG_IF(m_webView->_page->isAlwaysOnLoggingAllowed(), ProcessSuspension, "%p - UIProcess is taking a background assertion because a page load started", this);1165 ASSERT(!m_activityToken);1177 } 1178 if (!m_activityToken) { 1179 RELEASE_LOG_IF(m_webView->_page->isAlwaysOnLoggingAllowed(), ProcessSuspension, "%p - NavigationState is taking a process network assertion because a page load started", this); 1166 1180 m_activityToken = m_webView->_page->process().throttler().backgroundActivityToken(); 1167 1181 } 1168 1182 } else if (m_activityToken) { 1169 1183 if (m_webView._isBackground) 1170 releaseNetworkActivityToken ();1184 releaseNetworkActivityTokenAfterLoadCompletion(); 1171 1185 else { 1172 1186 // The application is visible so we delay releasing the background activity for 3 seconds to give it a chance to start another navigation 1173 1187 // before suspending the WebContent process <rdar://problem/27910964>. 1174 RELEASE_LOG_IF(m_webView->_page->isAlwaysOnLoggingAllowed(), ProcessSuspension, "%p - Page load completed and UIProcess will be releasing background assertion soon unless a new load starts", this);1188 RELEASE_LOG_IF(m_webView->_page->isAlwaysOnLoggingAllowed(), ProcessSuspension, "%p - NavigationState will release its process network assertion soon because the page load completed", this); 1175 1189 m_releaseActivityTimer.startOneShot(3_s); 1176 1190 } -
trunk/Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm
r231498 r231676 35 35 #import "Logging.h" 36 36 #import "NativeWebKeyboardEvent.h" 37 #import "NavigationState.h" 37 38 #import "PageClient.h" 38 39 #import "PrintInfo.h" … … 678 679 { 679 680 bool isSuspendedUnderLock = [UIApp isSuspendedUnderLock]; 681 682 // We normally delay process suspension when the app is backgrounded until the current page load completes. However, 683 // we do not want to do so when the screen is locked for power reasons. 684 if (isSuspendedUnderLock) 685 NavigationState::fromWebPage(*this).releaseNetworkActivityToken(NavigationState::NetworkActivityTokenReleaseReason::ScreenLocked); 680 686 m_process->send(Messages::WebPage::ApplicationDidEnterBackground(isSuspendedUnderLock), m_pageID); 681 687 }
Note: See TracChangeset
for help on using the changeset viewer.