Title: [180204] trunk/Source/WebKit2
- Revision
- 180204
- Author
- timothy_hor...@apple.com
- Date
- 2015-02-16 18:30:11 -0800 (Mon, 16 Feb 2015)
Log Message
Sometimes RemoteLayerBackingStore ends up non-volatile while the process is suspended
<rdar://problem/19842957>
https://bugs.webkit.org/show_bug.cgi?id=141675
Reviewed by Simon Fraser.
Previously, it was possible to get a layer tree flush in between the
process suspension cleanup code making surfaces volatile and the process
actually being suspended (it was racy because the suspension requires
a few IPC round trips). Depending on how far through the flush we got,
we could sometimes end up either making new non-volatile backing store,
or switching some recently-made-volatile backing store back to non-volatile.
We don't want to have any non-volatile backing store while suspended.
* UIProcess/ProcessThrottler.cpp:
(WebKit::ProcessThrottler::updateAssertion):
Inform the WebProcess when it's going from suspended to runnable state.
* UIProcess/WebProcessProxy.cpp:
(WebKit::WebProcessProxy::sendProcessDidResume):
* UIProcess/WebProcessProxy.h:
Forward the message along.
* WebProcess/WebProcess.cpp:
(WebKit::WebProcess::processWillSuspend):
(WebKit::WebProcess::cancelProcessWillSuspend):
(WebKit::WebProcess::setAllLayerTreeStatesFrozen):
(WebKit::WebProcess::processDidResume):
Freeze all of this process' pages' layer trees when we start trying to suspend,
and un-freeze them when either suspension is cancelled or we resume.
* WebProcess/WebProcess.h:
* WebProcess/WebProcess.messages.in:
Modified Paths
Diff
Modified: trunk/Source/WebKit2/ChangeLog (180203 => 180204)
--- trunk/Source/WebKit2/ChangeLog 2015-02-17 02:28:52 UTC (rev 180203)
+++ trunk/Source/WebKit2/ChangeLog 2015-02-17 02:30:11 UTC (rev 180204)
@@ -1,5 +1,41 @@
2015-02-16 Tim Horton <timothy_hor...@apple.com>
+ Sometimes RemoteLayerBackingStore ends up non-volatile while the process is suspended
+ <rdar://problem/19842957>
+ https://bugs.webkit.org/show_bug.cgi?id=141675
+
+ Reviewed by Simon Fraser.
+
+ Previously, it was possible to get a layer tree flush in between the
+ process suspension cleanup code making surfaces volatile and the process
+ actually being suspended (it was racy because the suspension requires
+ a few IPC round trips). Depending on how far through the flush we got,
+ we could sometimes end up either making new non-volatile backing store,
+ or switching some recently-made-volatile backing store back to non-volatile.
+ We don't want to have any non-volatile backing store while suspended.
+
+ * UIProcess/ProcessThrottler.cpp:
+ (WebKit::ProcessThrottler::updateAssertion):
+ Inform the WebProcess when it's going from suspended to runnable state.
+
+ * UIProcess/WebProcessProxy.cpp:
+ (WebKit::WebProcessProxy::sendProcessDidResume):
+ * UIProcess/WebProcessProxy.h:
+ Forward the message along.
+
+ * WebProcess/WebProcess.cpp:
+ (WebKit::WebProcess::processWillSuspend):
+ (WebKit::WebProcess::cancelProcessWillSuspend):
+ (WebKit::WebProcess::setAllLayerTreeStatesFrozen):
+ (WebKit::WebProcess::processDidResume):
+ Freeze all of this process' pages' layer trees when we start trying to suspend,
+ and un-freeze them when either suspension is cancelled or we resume.
+
+ * WebProcess/WebProcess.h:
+ * WebProcess/WebProcess.messages.in:
+
+2015-02-16 Tim Horton <timothy_hor...@apple.com>
+
Adopt CAMachPort-as-layer-contents
https://bugs.webkit.org/show_bug.cgi?id=141687
<rdar://problem/19393233>
Modified: trunk/Source/WebKit2/UIProcess/ProcessThrottler.cpp (180203 => 180204)
--- trunk/Source/WebKit2/UIProcess/ProcessThrottler.cpp 2015-02-17 02:28:52 UTC (rev 180203)
+++ trunk/Source/WebKit2/UIProcess/ProcessThrottler.cpp 2015-02-17 02:30:11 UTC (rev 180204)
@@ -71,10 +71,15 @@
m_assertion->setState(AssertionState::Background);
return;
}
+
+ bool shouldBeRunnable = m_foregroundCounter.value() || m_backgroundCounter.value();
// If we're currently waiting for the Web process to do suspension cleanup, but no longer need to be suspended, tell the Web process to cancel the cleanup.
- if (m_suspendTimer.isActive() && (m_foregroundCounter.value() || m_backgroundCounter.value()))
+ if (m_suspendTimer.isActive() && shouldBeRunnable)
m_process->sendCancelProcessWillSuspend();
+
+ if (m_assertion && m_assertion->state() == AssertionState::Suspended && shouldBeRunnable)
+ m_process->sendProcessDidResume();
updateAssertionNow();
}
Modified: trunk/Source/WebKit2/UIProcess/WebProcessProxy.cpp (180203 => 180204)
--- trunk/Source/WebKit2/UIProcess/WebProcessProxy.cpp 2015-02-17 02:28:52 UTC (rev 180203)
+++ trunk/Source/WebKit2/UIProcess/WebProcessProxy.cpp 2015-02-17 02:30:11 UTC (rev 180204)
@@ -762,6 +762,12 @@
send(Messages::WebProcess::CancelProcessWillSuspend(), 0);
}
+void WebProcessProxy::sendProcessDidResume()
+{
+ if (canSendMessage())
+ send(Messages::WebProcess::ProcessDidResume(), 0);
+}
+
void WebProcessProxy::processReadyToSuspend()
{
m_throttler->processReadyToSuspend();
Modified: trunk/Source/WebKit2/UIProcess/WebProcessProxy.h (180203 => 180204)
--- trunk/Source/WebKit2/UIProcess/WebProcessProxy.h 2015-02-17 02:28:52 UTC (rev 180203)
+++ trunk/Source/WebKit2/UIProcess/WebProcessProxy.h 2015-02-17 02:30:11 UTC (rev 180204)
@@ -140,6 +140,7 @@
void processReadyToSuspend();
void sendCancelProcessWillSuspend();
void didCancelProcessSuspension();
+ void sendProcessDidResume();
void setIsHoldingLockedFiles(bool);
Modified: trunk/Source/WebKit2/WebProcess/WebProcess.cpp (180203 => 180204)
--- trunk/Source/WebKit2/WebProcess/WebProcess.cpp 2015-02-17 02:28:52 UTC (rev 180203)
+++ trunk/Source/WebKit2/WebProcess/WebProcess.cpp 2015-02-17 02:30:11 UTC (rev 180204)
@@ -1164,6 +1164,7 @@
void WebProcess::processWillSuspend()
{
memoryPressureHandler().releaseMemory(true);
+ setAllLayerTreeStatesFrozen(true);
if (!markAllLayersVolatileIfPossible())
m_processSuspensionCleanupTimer.startRepeating(std::chrono::milliseconds(20));
@@ -1173,6 +1174,8 @@
void WebProcess::cancelProcessWillSuspend()
{
+ 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())
@@ -1193,6 +1196,14 @@
return successfullyMarkedAllLayersVolatile;
}
+void WebProcess::setAllLayerTreeStatesFrozen(bool frozen)
+{
+ for (auto& page : m_pageMap.values()) {
+ if (auto drawingArea = page->drawingArea())
+ drawingArea->setLayerTreeStateIsFrozen(frozen);
+ }
+}
+
void WebProcess::processSuspensionCleanupTimerFired()
{
if (markAllLayersVolatileIfPossible()) {
@@ -1200,6 +1211,11 @@
parentProcessConnection()->send(Messages::WebProcessProxy::ProcessReadyToSuspend(), 0);
}
}
+
+void WebProcess::processDidResume()
+{
+ setAllLayerTreeStatesFrozen(false);
+}
void WebProcess::pageDidEnterWindow(uint64_t pageID)
{
Modified: trunk/Source/WebKit2/WebProcess/WebProcess.h (180203 => 180204)
--- trunk/Source/WebKit2/WebProcess/WebProcess.h 2015-02-17 02:28:52 UTC (rev 180203)
+++ trunk/Source/WebKit2/WebProcess/WebProcess.h 2015-02-17 02:30:11 UTC (rev 180204)
@@ -181,7 +181,9 @@
void processWillSuspend();
void cancelProcessWillSuspend();
bool markAllLayersVolatileIfPossible();
+ void setAllLayerTreeStatesFrozen(bool);
void processSuspensionCleanupTimerFired();
+ void processDidResume();
#if PLATFORM(IOS)
void resetAllGeolocationPermissions();
Modified: trunk/Source/WebKit2/WebProcess/WebProcess.messages.in (180203 => 180204)
--- trunk/Source/WebKit2/WebProcess/WebProcess.messages.in 2015-02-17 02:28:52 UTC (rev 180203)
+++ trunk/Source/WebKit2/WebProcess/WebProcess.messages.in 2015-02-17 02:30:11 UTC (rev 180204)
@@ -96,4 +96,5 @@
ProcessWillSuspend()
CancelProcessWillSuspend()
+ ProcessDidResume()
}
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes