Title: [186200] trunk/Source/WebKit2
- Revision
- 186200
- Author
- [email protected]
- Date
- 2015-07-01 16:17:58 -0700 (Wed, 01 Jul 2015)
Log Message
Web page doesn't update its loading state when web process becomes suspended if there are pending network requests (XHR).
https://bugs.webkit.org/show_bug.cgi?id=146439
When web page is loading, we hold a background activity token in NavigationState and we release the token when the page done
loading. A web page can start loading subresources (like XHR) after the page is loaded, and WebPageProxy will update its
_networkRequestsInProgress state which will notify the client there is network actvity on-going. Since we don't hold
the background activity token after page is loaded, the WebContent process could become suspended without notifying the client
and the client will lose track of the loading state.
The first thought was to hold another background activity when _networkRequestsInProgress flag is set in NavigationState.
However, this could result in side-effect that a WebContent process can stay active for too long if there is a long lasting
XHR resquest.
This patch fix this by notifying the client that network activity is stopped when WebContent process is going to be suspended.
We also cache the networkRequestsInProgress state for suspended process, so that when it becomes foreground, we can tell
the client the correct state of network activity.
Patch by Yongjun Zhang <[email protected]> on 2015-07-01
Reviewed by Dan Bernstein.
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::WebPageProxy): Initialize m_hasNetworkRequestsOnSuspended.
(WebKit::WebPageProxy::processWillBecomeSuspended): If there is pending requests on suspend, cache the network activity state
and notify the client.
(WebKit::WebPageProxy::processWillBecomeForground): Restore the network activity state when the process becomes foreground.
(WebKit::WebPageProxy::resetState):
* UIProcess/WebPageProxy.h: Add a data member m_hasNetworkRequestsOnSuspended to cache the network activity state on process
suspend.
* UIProcess/WebProcessProxy.cpp:
(WebKit::WebProcessProxy::didSetAssertionState):
Modified Paths
Diff
Modified: trunk/Source/WebKit2/ChangeLog (186199 => 186200)
--- trunk/Source/WebKit2/ChangeLog 2015-07-01 23:09:48 UTC (rev 186199)
+++ trunk/Source/WebKit2/ChangeLog 2015-07-01 23:17:58 UTC (rev 186200)
@@ -1,3 +1,35 @@
+2015-07-01 Yongjun Zhang <[email protected]>
+
+ Web page doesn't update its loading state when web process becomes suspended if there are pending network requests (XHR).
+ https://bugs.webkit.org/show_bug.cgi?id=146439
+
+ When web page is loading, we hold a background activity token in NavigationState and we release the token when the page done
+ loading. A web page can start loading subresources (like XHR) after the page is loaded, and WebPageProxy will update its
+ _networkRequestsInProgress state which will notify the client there is network actvity on-going. Since we don't hold
+ the background activity token after page is loaded, the WebContent process could become suspended without notifying the client
+ and the client will lose track of the loading state.
+
+ The first thought was to hold another background activity when _networkRequestsInProgress flag is set in NavigationState.
+ However, this could result in side-effect that a WebContent process can stay active for too long if there is a long lasting
+ XHR resquest.
+
+ This patch fix this by notifying the client that network activity is stopped when WebContent process is going to be suspended.
+ We also cache the networkRequestsInProgress state for suspended process, so that when it becomes foreground, we can tell
+ the client the correct state of network activity.
+
+ Reviewed by Dan Bernstein.
+
+ * UIProcess/WebPageProxy.cpp:
+ (WebKit::WebPageProxy::WebPageProxy): Initialize m_hasNetworkRequestsOnSuspended.
+ (WebKit::WebPageProxy::processWillBecomeSuspended): If there is pending requests on suspend, cache the network activity state
+ and notify the client.
+ (WebKit::WebPageProxy::processWillBecomeForground): Restore the network activity state when the process becomes foreground.
+ (WebKit::WebPageProxy::resetState):
+ * UIProcess/WebPageProxy.h: Add a data member m_hasNetworkRequestsOnSuspended to cache the network activity state on process
+ suspend.
+ * UIProcess/WebProcessProxy.cpp:
+ (WebKit::WebProcessProxy::didSetAssertionState):
+
2015-07-01 Dean Jackson <[email protected]>
Disable the experimental WebGL2 implementation
Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp (186199 => 186200)
--- trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp 2015-07-01 23:09:48 UTC (rev 186199)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp 2015-07-01 23:17:58 UTC (rev 186200)
@@ -303,6 +303,7 @@
, m_dynamicViewportSizeUpdateWaitingForLayerTreeCommit(false)
, m_dynamicViewportSizeUpdateLayerTreeTransactionID(0)
, m_layerTreeTransactionIdAtLastTouchStart(0)
+ , m_hasNetworkRequestsOnSuspended(false)
#endif
, m_geolocationPermissionRequestManager(*this)
, m_notificationPermissionRequestManager(*this)
@@ -4834,6 +4835,27 @@
m_loaderClient->processDidCrash(*this);
}
+#if PLATFORM(IOS)
+void WebPageProxy::processWillBecomeSuspended()
+{
+ ASSERT(m_isValid);
+
+ m_hasNetworkRequestsOnSuspended = m_pageLoadState.networkRequestsInProgress();
+ if (m_hasNetworkRequestsOnSuspended)
+ setNetworkRequestsInProgress(false);
+}
+
+void WebPageProxy::processWillBecomeForeground()
+{
+ ASSERT(m_isValid);
+
+ if (m_hasNetworkRequestsOnSuspended) {
+ setNetworkRequestsInProgress(true);
+ m_hasNetworkRequestsOnSuspended = false;
+ }
+}
+#endif
+
void WebPageProxy::resetState(ResetStateReason resetStateReason)
{
m_mainFrame = nullptr;
@@ -4903,6 +4925,7 @@
m_dynamicViewportSizeUpdateWaitingForLayerTreeCommit = false;
m_dynamicViewportSizeUpdateLayerTreeTransactionID = 0;
m_layerTreeTransactionIdAtLastTouchStart = 0;
+ m_hasNetworkRequestsOnSuspended = false;
#endif
#if ENABLE(WIRELESS_PLAYBACK_TARGET) && !PLATFORM(IOS)
Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.h (186199 => 186200)
--- trunk/Source/WebKit2/UIProcess/WebPageProxy.h 2015-07-01 23:09:48 UTC (rev 186199)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.h 2015-07-01 23:17:58 UTC (rev 186200)
@@ -816,6 +816,10 @@
void interactionOccurredWhileProcessUnresponsive();
void processDidBecomeResponsive();
void processDidCrash();
+#if PLATFORM(IOS)
+ void processWillBecomeSuspended();
+ void processWillBecomeForeground();
+#endif
virtual void enterAcceleratedCompositingMode(const LayerTreeContext&);
virtual void exitAcceleratedCompositingMode();
@@ -1532,6 +1536,7 @@
uint64_t m_dynamicViewportSizeUpdateLayerTreeTransactionID;
uint64_t m_layerTreeTransactionIdAtLastTouchStart;
uint64_t m_currentDynamicViewportSizeUpdateID { 0 };
+ bool m_hasNetworkRequestsOnSuspended;
#endif
#if ENABLE(VIBRATION)
Modified: trunk/Source/WebKit2/UIProcess/WebProcessProxy.cpp (186199 => 186200)
--- trunk/Source/WebKit2/UIProcess/WebProcessProxy.cpp 2015-07-01 23:09:48 UTC (rev 186199)
+++ trunk/Source/WebKit2/UIProcess/WebProcessProxy.cpp 2015-07-01 23:17:58 UTC (rev 186200)
@@ -921,6 +921,8 @@
case AssertionState::Suspended:
m_foregroundTokenForNetworkProcess = nullptr;
m_backgroundTokenForNetworkProcess = nullptr;
+ for (auto& page : m_pageMap.values())
+ page->processWillBecomeSuspended();
break;
case AssertionState::Background:
@@ -933,6 +935,8 @@
if (processPool().usesNetworkProcess())
m_foregroundTokenForNetworkProcess = processPool().ensureNetworkProcess().throttler().foregroundActivityToken();
m_backgroundTokenForNetworkProcess = nullptr;
+ for (auto& page : m_pageMap.values())
+ page->processWillBecomeForeground();
break;
}
#else
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes