Diff
Modified: trunk/Source/WebCore/ChangeLog (198928 => 198929)
--- trunk/Source/WebCore/ChangeLog 2016-03-31 23:07:39 UTC (rev 198928)
+++ trunk/Source/WebCore/ChangeLog 2016-03-31 23:33:56 UTC (rev 198929)
@@ -1,3 +1,15 @@
+2016-03-31 Chris Dumez <[email protected]>
+
+ [iOS] Both WebPage's volatility timer and WebProcess's processSuspensionCleanupTimer are trying to make surfaces volatile with very short interval
+ https://bugs.webkit.org/show_bug.cgi?id=156065
+ <rdar://problem/25452004>
+
+ Reviewed by Simon Fraser.
+
+ Export a symbol so it can be used from WebKit2.
+
+ * page/Page.h:
+
2016-03-31 Daniel Bates <[email protected]>
REGRESSION (r195605): ASSERTION FAILED: !NoEventDispatchAssertion::isEventDispatchForbidden()
Modified: trunk/Source/WebCore/page/Page.h (198928 => 198929)
--- trunk/Source/WebCore/page/Page.h 2016-03-31 23:07:39 UTC (rev 198928)
+++ trunk/Source/WebCore/page/Page.h 2016-03-31 23:33:56 UTC (rev 198929)
@@ -509,7 +509,7 @@
bool isControlledByAutomation() const { return m_controlledByAutomation; }
void setControlledByAutomation(bool controlled) { m_controlledByAutomation = controlled; }
- bool isAlwaysOnLoggingAllowed() const;
+ WEBCORE_EXPORT bool isAlwaysOnLoggingAllowed() const;
String captionUserPreferencesStyleSheet();
void setCaptionUserPreferencesStyleSheet(const String&);
Modified: trunk/Source/WebKit2/ChangeLog (198928 => 198929)
--- trunk/Source/WebKit2/ChangeLog 2016-03-31 23:07:39 UTC (rev 198928)
+++ trunk/Source/WebKit2/ChangeLog 2016-03-31 23:33:56 UTC (rev 198929)
@@ -1,3 +1,48 @@
+2016-03-31 Chris Dumez <[email protected]>
+
+ [iOS] Both WebPage's volatility timer and WebProcess's processSuspensionCleanupTimer are trying to make surfaces volatile with very short interval
+ https://bugs.webkit.org/show_bug.cgi?id=156065
+ <rdar://problem/25452004>
+
+ Reviewed by Simon Fraser.
+
+ Upon process suspension, both the WebPage's volatility timer and
+ WebProcess' processSuspensionCleanupTimer are trying to make surfaces
+ volatile with a very short interval. This is overly aggressive given
+ that this operation normally succeeds very quickly or does not (due
+ to underlying bugs).
+
+ This patch does the following:
+ - Drop the WebProcess' processSuspensionCleanupTimer and have the
+ WebProcess drive the WebPages' volatility timer instead.
+ - Update the WebPages' volatility timer to do exponential back off.
+
+ * WebProcess/WebPage/WebPage.cpp:
+ (WebKit::WebPage::layerVolatilityTimerFired):
+ (WebKit::WebPage::markLayersVolatileImmediatelyIfPossible):
+ (WebKit::WebPage::markLayersVolatile):
+ (WebKit::WebPage::cancelMarkLayersVolatile):
+ (WebKit::WebPage::isAlwaysOnLoggingAllowed):
+ (WebKit::WebPage::setLayerTreeStateIsFrozen): Deleted.
+ * WebProcess/WebPage/WebPage.h:
+ (WebKit::WebPage::markLayersVolatile):
+ * WebProcess/WebPage/ios/WebPageIOS.mm:
+ (WebKit::WebPage::applicationDidEnterBackground):
+ (WebKit::WebPage::applicationWillEnterForeground):
+ (WebKit::WebPage::applicationDidBecomeActive): Deleted.
+ (WebKit::adjustVelocityDataForBoundedScale): Deleted.
+ * WebProcess/WebProcess.cpp:
+ (WebKit::WebProcess::actualPrepareToSuspend):
+ (WebKit::WebProcess::processWillSuspendImminently):
+ (WebKit::WebProcess::prepareToSuspend):
+ (WebKit::WebProcess::cancelPrepareToSuspend):
+ (WebKit::WebProcess::markAllLayersVolatile):
+ (WebKit::WebProcess::cancelMarkAllLayersVolatile):
+ (WebKit::WebProcess::setAllLayerTreeStatesFrozen):
+ (WebKit::WebProcess::processDidResume):
+ (WebKit::WebProcess::WebProcess): Deleted.
+ * WebProcess/WebProcess.h:
+
2016-03-31 Brian Burg <[email protected]>
Web Automation: the interaction queue in WebAutomationSession::performKeyInteractions doesn't work
Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp (198928 => 198929)
--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp 2016-03-31 23:07:39 UTC (rev 198928)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp 2016-03-31 23:33:56 UTC (rev 198929)
@@ -243,7 +243,12 @@
namespace WebKit {
static const double pageScrollHysteresisSeconds = 0.3;
+static const std::chrono::milliseconds initialLayerVolatilityTimerInterval { 20 };
+static const std::chrono::seconds maximumLayerVolatilityTimerInterval { 10 };
+#define WEBPAGE_LOG_ALWAYS(...) LOG_ALWAYS(isAlwaysOnLoggingAllowed(), __VA_ARGS__)
+#define WEBPAGE_LOG_ALWAYS_ERROR(...) LOG_ALWAYS_ERROR(isAlwaysOnLoggingAllowed(), __VA_ARGS__)
+
class SendStopResponsivenessTimer {
public:
SendStopResponsivenessTimer(WebPage* page)
@@ -351,8 +356,8 @@
, m_availableScreenSize(parameters.availableScreenSize)
, m_deviceOrientation(0)
, m_inDynamicSizeUpdate(false)
- , m_volatilityTimer(*this, &WebPage::volatilityTimerFired)
#endif
+ , m_layerVolatilityTimer(*this, &WebPage::layerVolatilityTimerFired)
, m_backgroundColor(Color::white)
, m_maximumRenderingSuppressionToken(0)
, m_scrollPinningBehavior(DoNotPin)
@@ -2026,15 +2031,55 @@
drawingArea->setLayerTreeStateIsFrozen(frozen);
}
+void WebPage::layerVolatilityTimerFired()
+{
+ if (markLayersVolatileImmediatelyIfPossible()) {
+ m_layerVolatilityTimer.stop();
+ return;
+ }
+
+ auto newInterval = std::min(2 * m_layerVolatilityTimer.repeatIntervalMS(), std::chrono::duration_cast<std::chrono::milliseconds>(maximumLayerVolatilityTimerInterval));
+ WEBPAGE_LOG_ALWAYS_ERROR("%p - WebPage - Failed to mark all layers as volatile, will retry in %lld ms", this, newInterval.count());
+ m_layerVolatilityTimer.startRepeating(newInterval);
+}
+
bool WebPage::markLayersVolatileImmediatelyIfPossible()
{
- auto* drawingArea = this->drawingArea();
- if (!drawingArea)
- return true;
+ bool success = !drawingArea() || drawingArea()->markLayersVolatileImmediatelyIfPossible();
+ if (success) {
+ WEBPAGE_LOG_ALWAYS("%p - WebPage - Successfully marked layers as volatile", this);
+ auto completionHandlers = WTFMove(m_markLayersAsVolatileCompletionHandlers);
+ for (auto& completionHandler : completionHandlers)
+ completionHandler();
+ }
- return drawingArea->markLayersVolatileImmediatelyIfPossible();
+ return success;
}
+void WebPage::markLayersVolatile(std::function<void()> completionHandler)
+{
+ WEBPAGE_LOG_ALWAYS("%p - WebPage::markLayersVolatile()", this);
+
+ if (m_layerVolatilityTimer.isActive())
+ m_layerVolatilityTimer.stop();
+
+ if (completionHandler)
+ m_markLayersAsVolatileCompletionHandlers.append(WTFMove(completionHandler));
+
+ if (markLayersVolatileImmediatelyIfPossible())
+ return;
+
+ WEBPAGE_LOG_ALWAYS("%p - Failed to mark all layers as volatile, will retry in %lld ms", this, initialLayerVolatilityTimerInterval.count());
+ m_layerVolatilityTimer.startRepeating(initialLayerVolatilityTimerInterval);
+}
+
+void WebPage::cancelMarkLayersVolatile()
+{
+ WEBPAGE_LOG_ALWAYS("%p - WebPage::cancelMarkLayersVolatile()", this);
+ m_layerVolatilityTimer.stop();
+ m_markLayersAsVolatileCompletionHandlers.clear();
+}
+
class CurrentEvent {
public:
explicit CurrentEvent(const WebEvent& event)
@@ -3337,6 +3382,11 @@
m_undoStepMap.remove(stepID);
}
+bool WebPage::isAlwaysOnLoggingAllowed() const
+{
+ return corePage() && corePage()->isAlwaysOnLoggingAllowed();
+}
+
void WebPage::unapplyEditCommand(uint64_t stepID)
{
WebUndoStep* step = webUndoStep(stepID);
Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h (198928 => 198929)
--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h 2016-03-31 23:07:39 UTC (rev 198928)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h 2016-03-31 23:33:56 UTC (rev 198929)
@@ -287,6 +287,7 @@
void removeWebEditCommand(uint64_t);
bool isInRedo() const { return m_isInRedo; }
+ bool isAlwaysOnLoggingAllowed() const;
void setActivePopupMenu(WebPopupMenu*);
void setHiddenPageTimerThrottlingIncreaseLimit(std::chrono::milliseconds limit)
@@ -579,7 +580,8 @@
#endif
void setLayerTreeStateIsFrozen(bool);
- bool markLayersVolatileImmediatelyIfPossible();
+ void markLayersVolatile(std::function<void()> completionHandler = {});
+ void cancelMarkLayersVolatile();
NotificationPermissionRequestManager* notificationPermissionRequestManager();
@@ -974,7 +976,6 @@
void resetTextAutosizingBeforeLayoutIfNeeded(const WebCore::FloatSize& oldSize, const WebCore::FloatSize& newSize);
WebCore::VisiblePosition visiblePositionInFocusedNodeForPoint(const WebCore::Frame&, const WebCore::IntPoint&, bool isInteractingWithAssistedNode);
PassRefPtr<WebCore::Range> rangeForGranularityAtPoint(const WebCore::Frame&, const WebCore::IntPoint&, uint32_t granularity, bool isInteractingWithAssistedNode);
- void volatilityTimerFired();
#endif
#if !PLATFORM(COCOA)
static const char* interpretKeyEvent(const WebCore::KeyboardEvent*);
@@ -985,6 +986,9 @@
bool executeKeypressCommandsInternal(const Vector<WebCore::KeypressCommand>&, WebCore::KeyboardEvent*);
#endif
+ bool markLayersVolatileImmediatelyIfPossible();
+ void layerVolatilityTimerFired();
+
String sourceForFrame(WebFrame*);
void loadDataImpl(uint64_t navigationID, PassRefPtr<WebCore::SharedBuffer>, const String& MIMEType, const String& encodingName, const WebCore::URL& baseURL, const WebCore::URL& failingURL, const UserData&);
@@ -1412,9 +1416,11 @@
RefPtr<WebCore::Node> m_pendingSyntheticClickNode;
WebCore::FloatPoint m_pendingSyntheticClickLocation;
WebCore::FloatRect m_previousExposedContentRect;
- WebCore::Timer m_volatilityTimer;
#endif
+ WebCore::Timer m_layerVolatilityTimer;
+ Vector<std::function<void()>> m_markLayersAsVolatileCompletionHandlers;
+
HashSet<String, ASCIICaseInsensitiveHash> m_mimeTypesWithCustomContentProviders;
WebCore::Color m_backgroundColor;
Modified: trunk/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm (198928 => 198929)
--- trunk/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm 2016-03-31 23:07:39 UTC (rev 198928)
+++ trunk/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm 2016-03-31 23:33:56 UTC (rev 198929)
@@ -2866,28 +2866,17 @@
[[NSNotificationCenter defaultCenter] postNotificationName:WebUIApplicationWillResignActiveNotification object:nil];
}
-void WebPage::volatilityTimerFired()
-{
- if (!markLayersVolatileImmediatelyIfPossible())
- return;
-
- m_volatilityTimer.stop();
-}
-
void WebPage::applicationDidEnterBackground(bool isSuspendedUnderLock)
{
[[NSNotificationCenter defaultCenter] postNotificationName:WebUIApplicationDidEnterBackgroundNotification object:nil userInfo:@{@"isSuspendedUnderLock": [NSNumber numberWithBool:isSuspendedUnderLock]}];
setLayerTreeStateIsFrozen(true);
- if (markLayersVolatileImmediatelyIfPossible())
- return;
-
- m_volatilityTimer.startRepeating(std::chrono::milliseconds(200));
+ markLayersVolatile();
}
void WebPage::applicationWillEnterForeground(bool isSuspendedUnderLock)
{
- m_volatilityTimer.stop();
+ cancelMarkLayersVolatile();
setLayerTreeStateIsFrozen(false);
[[NSNotificationCenter defaultCenter] postNotificationName:WebUIApplicationWillEnterForegroundNotification object:nil userInfo:@{@"isSuspendedUnderLock": @(isSuspendedUnderLock)}];
Modified: trunk/Source/WebKit2/WebProcess/WebProcess.cpp (198928 => 198929)
--- trunk/Source/WebKit2/WebProcess/WebProcess.cpp 2016-03-31 23:07:39 UTC (rev 198928)
+++ trunk/Source/WebKit2/WebProcess/WebProcess.cpp 2016-03-31 23:33:56 UTC (rev 198929)
@@ -140,6 +140,8 @@
// This should be greater than tileRevalidationTimeout in TileController.
static const double nonVisibleProcessCleanupDelay = 10;
+#define WEBPROCESS_LOG_ALWAYS(...) LOG_ALWAYS(true, __VA_ARGS__)
+
namespace WebKit {
WebProcess& WebProcess::singleton()
@@ -153,7 +155,6 @@
#if PLATFORM(IOS)
, m_viewUpdateDispatcher(ViewUpdateDispatcher::create())
#endif
- , m_processSuspensionCleanupTimer(*this, &WebProcess::processSuspensionCleanupTimerFired)
, m_inDidClose(false)
, m_hasSetCacheModel(false)
, m_cacheModel(CacheModelDocumentViewer)
@@ -1209,13 +1210,14 @@
setAllLayerTreeStatesFrozen(true);
- if (markAllLayersVolatileIfPossible()) {
- if (shouldAcknowledgeWhenReadyToSuspend == ShouldAcknowledgeWhenReadyToSuspend::Yes)
+ markAllLayersVolatile([this, shouldAcknowledgeWhenReadyToSuspend] {
+ WEBPROCESS_LOG_ALWAYS("%p - WebProcess::markAllLayersVolatile() Successfuly marked all layers as volatile", this);
+
+ if (shouldAcknowledgeWhenReadyToSuspend == ShouldAcknowledgeWhenReadyToSuspend::Yes) {
+ WEBPROCESS_LOG_ALWAYS("%p - WebProcess::actualPrepareToSuspend() Sending ProcessReadyToSuspend IPC message", this);
parentProcessConnection()->send(Messages::WebProcessProxy::ProcessReadyToSuspend(), 0);
- return;
- }
- m_shouldAcknowledgeWhenReadyToSuspend = shouldAcknowledgeWhenReadyToSuspend;
- m_processSuspensionCleanupTimer.startRepeating(std::chrono::milliseconds(20));
+ }
+ });
}
void WebProcess::processWillSuspendImminently(bool& handled)
@@ -1228,6 +1230,7 @@
return;
}
+ WEBPROCESS_LOG_ALWAYS("%p - WebProcess::processWillSuspendImminently()", this);
DatabaseTracker::tracker().closeAllDatabases();
actualPrepareToSuspend(ShouldAcknowledgeWhenReadyToSuspend::No);
handled = true;
@@ -1235,29 +1238,51 @@
void WebProcess::prepareToSuspend()
{
+ WEBPROCESS_LOG_ALWAYS("%p - WebProcess::prepareToSuspend()", this);
actualPrepareToSuspend(ShouldAcknowledgeWhenReadyToSuspend::Yes);
}
void WebProcess::cancelPrepareToSuspend()
{
+ WEBPROCESS_LOG_ALWAYS("%p - WebProcess::cancelPrepareToSuspend()", this);
setAllLayerTreeStatesFrozen(false);
// If we've already finished cleaning up and sent ProcessReadyToSuspend, we
// shouldn't send DidCancelProcessSuspension; the UI process strictly expects one or the other.
- if (!m_processSuspensionCleanupTimer.isActive())
+ if (!m_pagesMarkingLayersAsVolatile)
return;
- m_processSuspensionCleanupTimer.stop();
+ cancelMarkAllLayersVolatile();
+
+ WEBPROCESS_LOG_ALWAYS("%p - WebProcess::cancelPrepareToSuspend() Sending DidCancelProcessSuspension IPC message", this);
parentProcessConnection()->send(Messages::WebProcessProxy::DidCancelProcessSuspension(), 0);
}
-bool WebProcess::markAllLayersVolatileIfPossible()
+void WebProcess::markAllLayersVolatile(std::function<void()> completionHandler)
{
- bool successfullyMarkedAllLayersVolatile = true;
+ WEBPROCESS_LOG_ALWAYS("%p - WebProcess::markAllLayersVolatile()", this);
+ m_pagesMarkingLayersAsVolatile = m_pageMap.size();
+ if (!m_pagesMarkingLayersAsVolatile) {
+ completionHandler();
+ return;
+ }
+ for (auto& page : m_pageMap.values()) {
+ page->markLayersVolatile([this, completionHandler] {
+ ASSERT(m_pagesMarkingLayersAsVolatile);
+ if (!--m_pagesMarkingLayersAsVolatile)
+ completionHandler();
+ });
+ }
+}
+
+void WebProcess::cancelMarkAllLayersVolatile()
+{
+ if (!m_pagesMarkingLayersAsVolatile)
+ return;
+
for (auto& page : m_pageMap.values())
- successfullyMarkedAllLayersVolatile &= page->markLayersVolatileImmediatelyIfPossible();
-
- return successfullyMarkedAllLayersVolatile;
+ page->cancelMarkLayersVolatile();
+ m_pagesMarkingLayersAsVolatile = 0;
}
void WebProcess::setAllLayerTreeStatesFrozen(bool frozen)
@@ -1265,19 +1290,12 @@
for (auto& page : m_pageMap.values())
page->setLayerTreeStateIsFrozen(frozen);
}
-
-void WebProcess::processSuspensionCleanupTimerFired()
-{
- if (!markAllLayersVolatileIfPossible())
- return;
- m_processSuspensionCleanupTimer.stop();
- if (m_shouldAcknowledgeWhenReadyToSuspend == ShouldAcknowledgeWhenReadyToSuspend::Yes)
- parentProcessConnection()->send(Messages::WebProcessProxy::ProcessReadyToSuspend(), 0);
-}
void WebProcess::processDidResume()
{
- m_processSuspensionCleanupTimer.stop();
+ WEBPROCESS_LOG_ALWAYS("%p - WebProcess::processDidResume()", this);
+
+ cancelMarkAllLayersVolatile();
setAllLayerTreeStatesFrozen(false);
}
Modified: trunk/Source/WebKit2/WebProcess/WebProcess.h (198928 => 198929)
--- trunk/Source/WebKit2/WebProcess/WebProcess.h 2016-03-31 23:07:39 UTC (rev 198928)
+++ trunk/Source/WebKit2/WebProcess/WebProcess.h 2016-03-31 23:33:56 UTC (rev 198929)
@@ -186,9 +186,6 @@
void processWillSuspendImminently(bool& handled);
void prepareToSuspend();
void cancelPrepareToSuspend();
- bool markAllLayersVolatileIfPossible();
- void setAllLayerTreeStatesFrozen(bool);
- void processSuspensionCleanupTimerFired();
void processDidResume();
#if PLATFORM(IOS)
@@ -224,6 +221,11 @@
void registerWithStateDumper();
#endif
+ void markAllLayersVolatile(std::function<void()> completionHandler);
+ void cancelMarkAllLayersVolatile();
+ void setAllLayerTreeStatesFrozen(bool);
+ void processSuspensionCleanupTimerFired();
+
void clearCachedCredentials();
void platformTerminate();
@@ -327,7 +329,6 @@
#if PLATFORM(IOS)
RefPtr<ViewUpdateDispatcher> m_viewUpdateDispatcher;
#endif
- WebCore::Timer m_processSuspensionCleanupTimer;
bool m_inDidClose;
@@ -386,7 +387,7 @@
Ref<WebCore::ResourceLoadStatisticsStore> m_resourceLoadStatisticsStorage;
- ShouldAcknowledgeWhenReadyToSuspend m_shouldAcknowledgeWhenReadyToSuspend;
+ unsigned m_pagesMarkingLayersAsVolatile { 0 };
bool m_suppressMemoryPressureHandler { false };
};