- Revision
- 242099
- Author
- [email protected]
- Date
- 2019-02-26 12:34:36 -0800 (Tue, 26 Feb 2019)
Log Message
[iOS] Regression(PSON) Scroll position is no longer restored when navigating back to reddit.com
https://bugs.webkit.org/show_bug.cgi?id=195054
<rdar://problem/48330549>
Reviewed by Geoff Garen.
Source/WebCore:
Add MaintainMemoryCache flag to indicate that the memory cache should not get purged.
* page/MemoryRelease.cpp:
(WebCore::releaseNoncriticalMemory):
(WebCore::releaseCriticalMemory):
(WebCore::releaseMemory):
* page/MemoryRelease.h:
Source/WebKit:
We attempt to restore the scroll position twice, on first layout and then on load completion.
Before PSON, the scroll position would fail to get restored on first layout but would succeed
on load completion because the view is tall enough by then. With PSON however, we would
fail to restore the scroll position on load completion because the view would not be tall
enough yet by this point. The reason is that the dynamic resources would not be in the memory cache
and would then get reloaded abd finish loading *after* the load event.
To address the issue, we now make sure to not purge the memory cache on process suspension on
iOS if there is currently a SuspendedPageProxy in the UIProcess for this process.
* UIProcess/SuspendedPageProxy.cpp:
(WebKit::SuspendedPageProxy::SuspendedPageProxy):
(WebKit::SuspendedPageProxy::~SuspendedPageProxy):
* UIProcess/WebProcessProxy.cpp:
(WebKit::WebProcessProxy::incrementSuspendedPageCount):
(WebKit::WebProcessProxy::decrementSuspendedPageCount):
* UIProcess/WebProcessProxy.h:
* WebProcess/WebProcess.cpp:
(WebKit::WebProcess::initializeWebProcess):
(WebKit::WebProcess::setHasSuspendedPageProxy):
* WebProcess/WebProcess.h:
* WebProcess/WebProcess.messages.in:
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (242098 => 242099)
--- trunk/Source/WebCore/ChangeLog 2019-02-26 20:24:43 UTC (rev 242098)
+++ trunk/Source/WebCore/ChangeLog 2019-02-26 20:34:36 UTC (rev 242099)
@@ -1,3 +1,19 @@
+2019-02-26 Chris Dumez <[email protected]>
+
+ [iOS] Regression(PSON) Scroll position is no longer restored when navigating back to reddit.com
+ https://bugs.webkit.org/show_bug.cgi?id=195054
+ <rdar://problem/48330549>
+
+ Reviewed by Geoff Garen.
+
+ Add MaintainMemoryCache flag to indicate that the memory cache should not get purged.
+
+ * page/MemoryRelease.cpp:
+ (WebCore::releaseNoncriticalMemory):
+ (WebCore::releaseCriticalMemory):
+ (WebCore::releaseMemory):
+ * page/MemoryRelease.h:
+
2019-02-26 Commit Queue <[email protected]>
Unreviewed, rolling out r241970.
Modified: trunk/Source/WebCore/page/MemoryRelease.cpp (242098 => 242099)
--- trunk/Source/WebCore/page/MemoryRelease.cpp 2019-02-26 20:24:43 UTC (rev 242098)
+++ trunk/Source/WebCore/page/MemoryRelease.cpp 2019-02-26 20:34:36 UTC (rev 242099)
@@ -58,7 +58,7 @@
namespace WebCore {
-static void releaseNoncriticalMemory()
+static void releaseNoncriticalMemory(MaintainMemoryCache maintainMemoryCache)
{
RenderTheme::singleton().purgeCaches();
@@ -70,12 +70,13 @@
for (auto* document : Document::allDocuments())
document->clearSelectorQueryCache();
- MemoryCache::singleton().pruneDeadResourcesToSize(0);
+ if (maintainMemoryCache == MaintainMemoryCache::No)
+ MemoryCache::singleton().pruneDeadResourcesToSize(0);
InlineStyleSheetOwner::clearCache();
}
-static void releaseCriticalMemory(Synchronous synchronous, MaintainPageCache maintainPageCache)
+static void releaseCriticalMemory(Synchronous synchronous, MaintainPageCache maintainPageCache, MaintainMemoryCache maintainMemoryCache)
{
// Right now, the only reason we call release critical memory while not under memory pressure is if the process is about to be suspended.
if (maintainPageCache == MaintainPageCache::No) {
@@ -83,7 +84,10 @@
PageCache::singleton().pruneToSizeNow(0, pruningReason);
}
- MemoryCache::singleton().pruneLiveResourcesToSize(0, /*shouldDestroyDecodedDataForAllLiveResources*/ true);
+ if (maintainMemoryCache == MaintainMemoryCache::No) {
+ auto shouldDestroyDecodedDataForAllLiveResources = true;
+ MemoryCache::singleton().pruneLiveResourcesToSize(0, shouldDestroyDecodedDataForAllLiveResources);
+ }
CSSValuePool::singleton().drain();
@@ -113,7 +117,7 @@
}
}
-void releaseMemory(Critical critical, Synchronous synchronous, MaintainPageCache maintainPageCache)
+void releaseMemory(Critical critical, Synchronous synchronous, MaintainPageCache maintainPageCache, MaintainMemoryCache maintainMemoryCache)
{
TraceScope scope(MemoryPressureHandlerStart, MemoryPressureHandlerEnd, static_cast<uint64_t>(critical), static_cast<uint64_t>(synchronous));
@@ -120,10 +124,10 @@
if (critical == Critical::Yes) {
// Return unused pages back to the OS now as this will likely give us a little memory to work with.
WTF::releaseFastMallocFreeMemory();
- releaseCriticalMemory(synchronous, maintainPageCache);
+ releaseCriticalMemory(synchronous, maintainPageCache, maintainMemoryCache);
}
- releaseNoncriticalMemory();
+ releaseNoncriticalMemory(maintainMemoryCache);
platformReleaseMemory(critical);
Modified: trunk/Source/WebCore/page/MemoryRelease.h (242098 => 242099)
--- trunk/Source/WebCore/page/MemoryRelease.h 2019-02-26 20:24:43 UTC (rev 242098)
+++ trunk/Source/WebCore/page/MemoryRelease.h 2019-02-26 20:34:36 UTC (rev 242099)
@@ -30,8 +30,9 @@
namespace WebCore {
enum class MaintainPageCache : bool { No, Yes };
+enum class MaintainMemoryCache : bool { No, Yes };
-WEBCORE_EXPORT void releaseMemory(Critical, Synchronous, MaintainPageCache = MaintainPageCache::No);
+WEBCORE_EXPORT void releaseMemory(Critical, Synchronous, MaintainPageCache = MaintainPageCache::No, MaintainMemoryCache = MaintainMemoryCache::No);
void platformReleaseMemory(Critical);
void jettisonExpensiveObjectsOnTopLevelNavigation();
WEBCORE_EXPORT void registerMemoryReleaseNotifyCallbacks();
Modified: trunk/Source/WebKit/ChangeLog (242098 => 242099)
--- trunk/Source/WebKit/ChangeLog 2019-02-26 20:24:43 UTC (rev 242098)
+++ trunk/Source/WebKit/ChangeLog 2019-02-26 20:34:36 UTC (rev 242099)
@@ -1,3 +1,34 @@
+2019-02-26 Chris Dumez <[email protected]>
+
+ [iOS] Regression(PSON) Scroll position is no longer restored when navigating back to reddit.com
+ https://bugs.webkit.org/show_bug.cgi?id=195054
+ <rdar://problem/48330549>
+
+ Reviewed by Geoff Garen.
+
+ We attempt to restore the scroll position twice, on first layout and then on load completion.
+ Before PSON, the scroll position would fail to get restored on first layout but would succeed
+ on load completion because the view is tall enough by then. With PSON however, we would
+ fail to restore the scroll position on load completion because the view would not be tall
+ enough yet by this point. The reason is that the dynamic resources would not be in the memory cache
+ and would then get reloaded abd finish loading *after* the load event.
+
+ To address the issue, we now make sure to not purge the memory cache on process suspension on
+ iOS if there is currently a SuspendedPageProxy in the UIProcess for this process.
+
+ * UIProcess/SuspendedPageProxy.cpp:
+ (WebKit::SuspendedPageProxy::SuspendedPageProxy):
+ (WebKit::SuspendedPageProxy::~SuspendedPageProxy):
+ * UIProcess/WebProcessProxy.cpp:
+ (WebKit::WebProcessProxy::incrementSuspendedPageCount):
+ (WebKit::WebProcessProxy::decrementSuspendedPageCount):
+ * UIProcess/WebProcessProxy.h:
+ * WebProcess/WebProcess.cpp:
+ (WebKit::WebProcess::initializeWebProcess):
+ (WebKit::WebProcess::setHasSuspendedPageProxy):
+ * WebProcess/WebProcess.h:
+ * WebProcess/WebProcess.messages.in:
+
2019-02-26 Ryosuke Niwa <[email protected]>
[iOS] REGRESSION(r238490?): Safari sometimes shows blank page until a cross site navigation or re-opening the tab
Modified: trunk/Source/WebKit/UIProcess/SuspendedPageProxy.cpp (242098 => 242099)
--- trunk/Source/WebKit/UIProcess/SuspendedPageProxy.cpp 2019-02-26 20:24:43 UTC (rev 242098)
+++ trunk/Source/WebKit/UIProcess/SuspendedPageProxy.cpp 2019-02-26 20:34:36 UTC (rev 242099)
@@ -89,6 +89,7 @@
#endif
{
item.setSuspendedPage(this);
+ m_process->incrementSuspendedPageCount();
m_process->addMessageReceiver(Messages::WebPageProxy::messageReceiverName(), m_page.pageID(), *this);
m_suspensionTimeoutTimer.startOneShot(suspensionTimeout);
@@ -97,6 +98,8 @@
SuspendedPageProxy::~SuspendedPageProxy()
{
+ m_process->decrementSuspendedPageCount();
+
if (m_readyToUnsuspendHandler) {
RunLoop::main().dispatch([readyToUnsuspendHandler = WTFMove(m_readyToUnsuspendHandler)]() mutable {
readyToUnsuspendHandler(nullptr);
Modified: trunk/Source/WebKit/UIProcess/WebProcessProxy.cpp (242098 => 242099)
--- trunk/Source/WebKit/UIProcess/WebProcessProxy.cpp 2019-02-26 20:24:43 UTC (rev 242098)
+++ trunk/Source/WebKit/UIProcess/WebProcessProxy.cpp 2019-02-26 20:34:36 UTC (rev 242099)
@@ -1438,6 +1438,21 @@
m_registrableDomain = WTFMove(registrableDomain);
}
+void WebProcessProxy::incrementSuspendedPageCount()
+{
+ ++m_suspendedPageCount;
+ if (m_suspendedPageCount == 1)
+ send(Messages::WebProcess::SetHasSuspendedPageProxy(true), 0);
+}
+
+void WebProcessProxy::decrementSuspendedPageCount()
+{
+ ASSERT(m_suspendedPageCount);
+ --m_suspendedPageCount;
+ if (!m_suspendedPageCount)
+ send(Messages::WebProcess::SetHasSuspendedPageProxy(false), 0);
+}
+
#if PLATFORM(WATCHOS)
void WebProcessProxy::takeBackgroundActivityTokenForFullscreenInput()
Modified: trunk/Source/WebKit/UIProcess/WebProcessProxy.h (242098 => 242099)
--- trunk/Source/WebKit/UIProcess/WebProcessProxy.h 2019-02-26 20:24:43 UTC (rev 242098)
+++ trunk/Source/WebKit/UIProcess/WebProcessProxy.h 2019-02-26 20:34:36 UTC (rev 242099)
@@ -106,6 +106,9 @@
WebConnection* webConnection() const { return m_webConnection.get(); }
+ void incrementSuspendedPageCount();
+ void decrementSuspendedPageCount();
+
WebProcessPool& processPool() const { ASSERT(m_processPool); return *m_processPool.get(); }
String registrableDomain() const { return m_registrableDomain.valueOr(String()); }
@@ -426,6 +429,7 @@
HashMap<uint64_t, Function<void()>> m_messageBatchDeliveryCompletionHandlers;
HashMap<uint64_t, CompletionHandler<void(WebCore::MessagePortChannelProvider::HasActivity)>> m_localPortActivityCompletionHandlers;
+ unsigned m_suspendedPageCount { 0 };
bool m_hasCommittedAnyProvisionalLoads { false };
bool m_isPrewarmed;
Modified: trunk/Source/WebKit/WebProcess/WebProcess.cpp (242098 => 242099)
--- trunk/Source/WebKit/WebProcess/WebProcess.cpp 2019-02-26 20:24:43 UTC (rev 242098)
+++ trunk/Source/WebKit/WebProcess/WebProcess.cpp 2019-02-26 20:34:36 UTC (rev 242099)
@@ -301,7 +301,8 @@
#endif
auto maintainPageCache = m_isSuspending && hasPageRequiringPageCacheWhileSuspended() ? WebCore::MaintainPageCache::Yes : WebCore::MaintainPageCache::No;
- WebCore::releaseMemory(critical, synchronous, maintainPageCache);
+ auto maintainMemoryCache = m_isSuspending && m_hasSuspendedPageProxy ? WebCore::MaintainMemoryCache::Yes : WebCore::MaintainMemoryCache::No;
+ WebCore::releaseMemory(critical, synchronous, maintainPageCache, maintainMemoryCache);
});
#if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MAX_ALLOWED >= 101200) || PLATFORM(GTK) || PLATFORM(WPE)
memoryPressureHandler.setShouldUsePeriodicMemoryMonitor(true);
@@ -481,6 +482,12 @@
return true;
}
+void WebProcess::setHasSuspendedPageProxy(bool hasSuspendedPageProxy)
+{
+ ASSERT(m_hasSuspendedPageProxy != hasSuspendedPageProxy);
+ m_hasSuspendedPageProxy = hasSuspendedPageProxy;
+}
+
void WebProcess::setIsInProcessCache(bool isInProcessCache)
{
#if PLATFORM(MAC)
Modified: trunk/Source/WebKit/WebProcess/WebProcess.h (242098 => 242099)
--- trunk/Source/WebKit/WebProcess/WebProcess.h 2019-02-26 20:24:43 UTC (rev 242098)
+++ trunk/Source/WebKit/WebProcess/WebProcess.h 2019-02-26 20:34:36 UTC (rev 242099)
@@ -267,6 +267,7 @@
void platformTerminate();
+ void setHasSuspendedPageProxy(bool);
void setIsInProcessCache(bool);
void markIsNoLongerPrewarmed();
@@ -478,6 +479,7 @@
#if PLATFORM(WAYLAND)
std::unique_ptr<WaylandCompositorDisplay> m_waylandCompositorDisplay;
#endif
+ bool m_hasSuspendedPageProxy { false };
bool m_isSuspending { false };
};
Modified: trunk/Source/WebKit/WebProcess/WebProcess.messages.in (242098 => 242099)
--- trunk/Source/WebKit/WebProcess/WebProcess.messages.in 2019-02-26 20:24:43 UTC (rev 242098)
+++ trunk/Source/WebKit/WebProcess/WebProcess.messages.in 2019-02-26 20:34:36 UTC (rev 242099)
@@ -119,6 +119,7 @@
CheckProcessLocalPortForActivity(struct WebCore::MessagePortIdentifier port, uint64_t callbackIdentifier)
MessagesAvailableForPort(struct WebCore::MessagePortIdentifier port)
+ SetHasSuspendedPageProxy(bool hasSuspendedPageProxy);
SetIsInProcessCache(bool isInProcessCache)
MarkIsNoLongerPrewarmed()
UpdateActivePages()