WebKit Bugzilla
Attachment 340119 Details for
Bug 185318
: [iOS] Apps that are not visible may not get suspended if they trigger page loads while in the background
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-185318-20180510130249.patch (text/plain), 4.40 KB, created by
Chris Dumez
on 2018-05-10 13:02:49 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Chris Dumez
Created:
2018-05-10 13:02:49 PDT
Size:
4.40 KB
patch
obsolete
>Subversion Revision: 231625 >diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog >index d61d891c256b5b11c08f0de8743c7915d92e2689..0b4c6729a7a2a000a5c81a16ec05de7718ba5c0e 100644 >--- a/Source/WebKit/ChangeLog >+++ b/Source/WebKit/ChangeLog >@@ -1,3 +1,22 @@ >+2018-05-10 Chris Dumez <cdumez@apple.com> >+ >+ [iOS] Apps that are not visible may not get suspended if they trigger page loads while in the background >+ https://bugs.webkit.org/show_bug.cgi?id=185318 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Whenever there is a page load going on, we take a background process assertion to delay process >+ suspension until this load completes. However, there is also a 3 seconds grace period after >+ a load is complete to allow the app to trigger a new load shortly after. This grace period was >+ introduced to support use cases where a visible app does loads in an offscreen view. However, >+ it can be abused by apps running in the background as they could trigger new page loads while >+ in the background to delay process suspension. This patch tightens the policy so that only >+ apps that are currently visible get to use this grace period. Apps that are in the background >+ get to finish their current load and will then get suspended. >+ >+ * UIProcess/Cocoa/NavigationState.mm: >+ (WebKit::NavigationState::didChangeIsLoading): >+ > 2018-05-09 Tim Horton <timothy_horton@apple.com> > > Remove the unused HAVE_OS_ACTIVITY >diff --git a/Source/WebKit/UIProcess/Cocoa/NavigationState.mm b/Source/WebKit/UIProcess/Cocoa/NavigationState.mm >index 809e5a008d72b379fe9ae74837e8f8b85e02c793..203706afb66e833ca5967216bd2fb65ff13b2bad 100644 >--- a/Source/WebKit/UIProcess/Cocoa/NavigationState.mm >+++ b/Source/WebKit/UIProcess/Cocoa/NavigationState.mm >@@ -1157,17 +1157,23 @@ void NavigationState::didChangeIsLoading() > { > #if PLATFORM(IOS) > if (m_webView->_page->pageLoadState().isLoading()) { >- if (m_releaseActivityTimer.isActive()) >+ if (m_releaseActivityTimer.isActive()) { >+ 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); > m_releaseActivityTimer.stop(); >- else { >+ } else { > RELEASE_LOG_IF(m_webView->_page->isAlwaysOnLoggingAllowed(), ProcessSuspension, "%p - UIProcess is taking a background assertion because a page load started", this); > ASSERT(!m_activityToken); > m_activityToken = m_webView->_page->process().throttler().backgroundActivityToken(); > } >- } else { >- // Delay releasing the background activity for 3 seconds to give the application a chance to start another navigation >- // before suspending the WebContent process <rdar://problem/27910964>. >- m_releaseActivityTimer.startOneShot(3_s); >+ } else if (m_activityToken) { >+ if (m_webView._isBackground) >+ releaseNetworkActivityToken(); >+ else { >+ // The application is visible so we delay releasing the background activity for 3 seconds to give it a chance to start another navigation >+ // before suspending the WebContent process <rdar://problem/27910964>. >+ 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); >+ m_releaseActivityTimer.startOneShot(3_s); >+ } > } > #endif > >diff --git a/Tools/TestWebKitAPI/cocoa/TestWKWebView.mm b/Tools/TestWebKitAPI/cocoa/TestWKWebView.mm >index 81e376ee3c4a8b693bac6d955580fc3de684baa3..75f37d0d19f6989f84b5879158a0797fa7b6dfeb 100644 >--- a/Tools/TestWebKitAPI/cocoa/TestWKWebView.mm >+++ b/Tools/TestWebKitAPI/cocoa/TestWKWebView.mm >@@ -49,6 +49,18 @@ > #import <wtf/SoftLinking.h> > SOFT_LINK_FRAMEWORK(UIKit) > SOFT_LINK_CLASS(UIKit, UIWindow) >+ >+@implementation WKWebView (WKWebViewTestingQuicks) >+ >+// TestWebKitAPI is currently not a UIApplication so we are unable to track if it is in >+// the background or not (https://bugs.webkit.org/show_bug.cgi?id=175204). This can >+// cause our processes to get suspended on iOS. We work around this by having >+// WKWebView._isBackground always return NO in the context of API tests. >+- (BOOL)_isBackground >+{ >+ return NO; >+} >+@end > #endif > > @implementation TestMessageHandler {
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 185318
:
339584
|
339585
| 340119