WebKit Bugzilla
Attachment 361103 Details for
Bug 194239
: Take additional process assertion while downloading
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-194239-20190204145122.patch (text/plain), 10.08 KB, created by
Brady Eidson
on 2019-02-04 14:51:23 PST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Brady Eidson
Created:
2019-02-04 14:51:23 PST
Size:
10.08 KB
patch
obsolete
>Subversion Revision: 240941 >diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog >index 12d218a0d6c0515e27bd7a112d7f11d7f4e78afe..d05cb92fcf54936f468d88c11e4ee22d2e92da93 100644 >--- a/Source/WebKit/ChangeLog >+++ b/Source/WebKit/ChangeLog >@@ -1,3 +1,35 @@ >+2019-02-04 Brady Eidson <beidson@apple.com> >+ >+ Take additional process assertion while downloading. >+ <rdar://problem/47741356> and https://bugs.webkit.org/show_bug.cgi?id=194239 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ When the first download starts, grab this new assertion. >+ When the last download ends, release it. >+ >+ * Configurations/Network-iOS.entitlements: >+ >+ * NetworkProcess/Downloads/DownloadManager.cpp: >+ (WebKit::DownloadManager::dataTaskBecameDownloadTask): >+ (WebKit::DownloadManager::downloadFinished): >+ * NetworkProcess/Downloads/DownloadManager.h: >+ >+ * Platform/spi/ios/AssertionServicesSPI.h: >+ >+ * UIProcess/ProcessAssertion.cpp: >+ (WebKit::ProcessAssertion::ProcessAssertion): >+ * UIProcess/ProcessAssertion.h: >+ (WebKit::ProcessAssertion::ProcessAssertion): >+ >+ * UIProcess/WebProcessProxy.cpp: >+ (WebKit::WebProcessProxy::didSetAssertionState): >+ >+ * UIProcess/ios/ProcessAssertionIOS.mm: >+ (WebKit::flagsForState): >+ (WebKit::reasonForState): >+ (WebKit::ProcessAssertion::ProcessAssertion): >+ > 2019-02-04 Simon Fraser <simon.fraser@apple.com> > > PageOverlayController's layers should be created lazily >diff --git a/Source/WebKit/Configurations/Network-iOS.entitlements b/Source/WebKit/Configurations/Network-iOS.entitlements >index cc96c82c5ccaab65085a190bbc7e0fe6ac4709aa..5f74903404069b5b7da8a75feaadbf02f2bed2b5 100644 >--- a/Source/WebKit/Configurations/Network-iOS.entitlements >+++ b/Source/WebKit/Configurations/Network-iOS.entitlements >@@ -16,6 +16,8 @@ > <array> > <string>com.apple.WebKit.Networking</string> > </array> >+ <key>com.apple.multitasking.systemappassertions</key> >+ <true/> > <key>com.apple.private.memorystatus</key> > <true/> > </dict> >diff --git a/Source/WebKit/NetworkProcess/Downloads/DownloadManager.cpp b/Source/WebKit/NetworkProcess/Downloads/DownloadManager.cpp >index 41cec3706deda2bcac9c748739026ad2d32a1b32..da377b89469963307205ffd01f6b2b61f7b73967 100644 >--- a/Source/WebKit/NetworkProcess/Downloads/DownloadManager.cpp >+++ b/Source/WebKit/NetworkProcess/Downloads/DownloadManager.cpp >@@ -71,6 +71,13 @@ void DownloadManager::dataTaskBecameDownloadTask(DownloadID downloadID, std::uni > ASSERT(!m_downloads.contains(downloadID)); > m_downloadsAfterDestinationDecided.remove(downloadID); > m_downloads.add(downloadID, WTFMove(download)); >+ >+#if ENABLE(TAKE_DOWNLOAD_ASSERTION) >+ if (m_downloads.size() == 1) { >+ ASSERT(!m_downloadAssertion); >+ m_downloadAssertion = std::make_unique<ProcessAssertion>(getpid(), "WebKit downloads"_s, AssertionState::Download); >+ } >+#endif > } > > void DownloadManager::continueWillSendRequest(DownloadID downloadID, WebCore::ResourceRequest&& request) >@@ -172,6 +179,13 @@ void DownloadManager::downloadFinished(Download* download) > { > ASSERT(m_downloads.contains(download->downloadID())); > m_downloads.remove(download->downloadID()); >+ >+#if ENABLE(TAKE_DOWNLOAD_ASSERTION) >+ if (m_downloads.isEmpty()) { >+ ASSERT(m_downloadAssertion); >+ m_downloadAssertion = nullptr; >+ } >+#endif > } > > void DownloadManager::didCreateDownload() >diff --git a/Source/WebKit/NetworkProcess/Downloads/DownloadManager.h b/Source/WebKit/NetworkProcess/Downloads/DownloadManager.h >index 8a0ed499687757d82015c3e8b74774ad75c5a1a9..ffe1ad045a95f246ceffc60a353549b75b926fe3 100644 >--- a/Source/WebKit/NetworkProcess/Downloads/DownloadManager.h >+++ b/Source/WebKit/NetworkProcess/Downloads/DownloadManager.h >@@ -28,6 +28,7 @@ > #include "DownloadID.h" > #include "NetworkDataTask.h" > #include "PendingDownload.h" >+#include "ProcessAssertion.h" > #include "SandboxExtension.h" > #include <WebCore/NotImplemented.h> > #include <wtf/Forward.h> >@@ -113,6 +114,10 @@ private: > HashMap<DownloadID, std::pair<RefPtr<NetworkDataTask>, ResponseCompletionHandler>> m_downloadsWaitingForDestination; > HashMap<DownloadID, RefPtr<NetworkDataTask>> m_downloadsAfterDestinationDecided; > HashMap<DownloadID, std::unique_ptr<Download>> m_downloads; >+ >+#if ENABLE(TAKE_DOWNLOAD_ASSERTION) >+ std::unique_ptr<ProcessAssertion> m_downloadAssertion; >+#endif > }; > > } // namespace WebKit >diff --git a/Source/WebKit/Platform/spi/ios/AssertionServicesSPI.h b/Source/WebKit/Platform/spi/ios/AssertionServicesSPI.h >index e2fcea0f46322d9d6fbd76fabd3495639ce762a4..fae2a1129288b33498fe65f7c052e3f123a2ec41 100644 >--- a/Source/WebKit/Platform/spi/ios/AssertionServicesSPI.h >+++ b/Source/WebKit/Platform/spi/ios/AssertionServicesSPI.h >@@ -69,6 +69,7 @@ typedef uint32_t BKSProcessAssertionFlags; > > enum { > BKSProcessAssertionReasonExtension = 13, >+ BKSProcessAssertionReasonFinishTaskUnbounded = 10004, > }; > typedef uint32_t BKSProcessAssertionReason; > >diff --git a/Source/WebKit/UIProcess/ProcessAssertion.cpp b/Source/WebKit/UIProcess/ProcessAssertion.cpp >index 54c12ddeff3ef91842055f39dfee4d3ef3241044..8592a13a6e66c94d349759a08cc8ed9fa81cb3e1 100644 >--- a/Source/WebKit/UIProcess/ProcessAssertion.cpp >+++ b/Source/WebKit/UIProcess/ProcessAssertion.cpp >@@ -35,6 +35,11 @@ ProcessAssertion::ProcessAssertion(ProcessID, AssertionState assertionState, Fun > { > } > >+ProcessAssertion::ProcessAssertion(ProcessID, const& String, AssertionState assertionState, Function<void()>&&) >+ : m_assertionState(assertionState) >+{ >+} >+ > ProcessAssertion::~ProcessAssertion() > { > } >diff --git a/Source/WebKit/UIProcess/ProcessAssertion.h b/Source/WebKit/UIProcess/ProcessAssertion.h >index b9b1e163a76d48af79c675fa3dd7f92b39bac17e..31050902d9838e92b35fa58f2ccad6150f1b89ac 100644 >--- a/Source/WebKit/UIProcess/ProcessAssertion.h >+++ b/Source/WebKit/UIProcess/ProcessAssertion.h >@@ -44,6 +44,7 @@ namespace WebKit { > enum class AssertionState { > Suspended, > Background, >+ Download, > Foreground > }; > >@@ -60,6 +61,7 @@ class ProcessAssertion > { > public: > ProcessAssertion(ProcessID, AssertionState, Function<void()>&& invalidationCallback = { }); >+ ProcessAssertion(ProcessID, const String& reason, AssertionState, Function<void()>&& invalidationCallback = { }); > virtual ~ProcessAssertion(); > > virtual void setClient(ProcessAssertionClient& client) { m_client = &client; } >diff --git a/Source/WebKit/UIProcess/WebProcessProxy.cpp b/Source/WebKit/UIProcess/WebProcessProxy.cpp >index 86d56b46d370d59b190bf71fddd017ed54d546b5..b2da3bb8765e166f972e596de1e37ef6bed39f72 100644 >--- a/Source/WebKit/UIProcess/WebProcessProxy.cpp >+++ b/Source/WebKit/UIProcess/WebProcessProxy.cpp >@@ -1077,6 +1077,9 @@ void WebProcessProxy::didSetAssertionState(AssertionState state) > for (auto& page : m_pageMap.values()) > page->processWillBecomeForeground(); > break; >+ >+ case AssertionState::Download: >+ ASSERT_NOT_REACHED(); > } > > ASSERT(!m_backgroundToken || !m_foregroundToken); >diff --git a/Source/WebKit/UIProcess/ios/ProcessAssertionIOS.mm b/Source/WebKit/UIProcess/ios/ProcessAssertionIOS.mm >index 70d7429c83c37a457c461ede036a84106840bfee..408995d94c5493c474c39b7e23e16a655e143b77 100644 >--- a/Source/WebKit/UIProcess/ios/ProcessAssertionIOS.mm >+++ b/Source/WebKit/UIProcess/ios/ProcessAssertionIOS.mm >@@ -153,20 +153,38 @@ static BKSProcessAssertionFlags flagsForState(AssertionState assertionState) > case AssertionState::Suspended: > return suspendedTabFlags; > case AssertionState::Background: >+ case AssertionState::Download: > return backgroundTabFlags; > case AssertionState::Foreground: > return foregroundTabFlags; > } > } > >+static BKSProcessAssertionReason reasonForState(AssertionState assertionState) >+{ >+ switch (assertionState) { >+ case AssertionState::Download: >+ return BKSProcessAssertionReasonFinishTaskUnbounded; >+ case AssertionState::Suspended: >+ case AssertionState::Background: >+ case AssertionState::Foreground: >+ return BKSProcessAssertionReasonExtension; >+ } >+} >+ > ProcessAssertion::ProcessAssertion(pid_t pid, AssertionState assertionState, Function<void()>&& invalidationCallback) >+ : ProcessAssertion(pid, "Web content visibility"_s, assertionState, WTFMove(invalidationCallback)) >+{ >+} >+ >+ProcessAssertion::ProcessAssertion(pid_t pid, const String& name, AssertionState assertionState, Function<void()>&& invalidationCallback) > : m_invalidationCallback(WTFMove(invalidationCallback)) > , m_assertionState(assertionState) > { > auto weakThis = makeWeakPtr(*this); > BKSProcessAssertionAcquisitionHandler handler = ^(BOOL acquired) { > if (!acquired) { >- RELEASE_LOG_ERROR(ProcessSuspension, " %p - ProcessAssertion() Unable to acquire assertion for process with PID %d", this, pid); >+ RELEASE_LOG_ERROR(ProcessSuspension, " %p - ProcessAssertion() PID %d Unable to acquire assertion for process with PID %d", this, getpid(), pid); > ASSERT_NOT_REACHED(); > dispatch_async(dispatch_get_main_queue(), ^{ > if (weakThis) >@@ -174,8 +192,9 @@ ProcessAssertion::ProcessAssertion(pid_t pid, AssertionState assertionState, Fun > }); > } > }; >- RELEASE_LOG(ProcessSuspension, "%p - ProcessAssertion() Acquiring assertion for process with PID %d", this, pid); >- m_assertion = adoptNS([[BKSProcessAssertion alloc] initWithPID:pid flags:flagsForState(assertionState) reason:BKSProcessAssertionReasonExtension name:@"Web content visibility" withHandler:handler]); >+ RELEASE_LOG(ProcessSuspension, "%p - ProcessAssertion() PID %d acquiring assertion for process with PID %d", this, getpid(), pid); >+ >+ m_assertion = adoptNS([[BKSProcessAssertion alloc] initWithPID:pid flags:flagsForState(assertionState) reason:reasonForState(assertionState) name:(NSString *)name withHandler:handler]); > m_assertion.get().invalidationHandler = ^() { > dispatch_async(dispatch_get_main_queue(), ^{ > RELEASE_LOG(ProcessSuspension, "%p - ProcessAssertion() Process assertion for process with PID %d was invalidated", this, pid);
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 194239
:
361103
|
361105
|
361108
|
361113