Title: [260453] trunk/Source/WebKit
Revision
260453
Author
cdu...@apple.com
Date
2020-04-21 14:22:25 -0700 (Tue, 21 Apr 2020)

Log Message

[iOS] Provide better names for ProcessThrottler process assertions
https://bugs.webkit.org/show_bug.cgi?id=210808

Reviewed by Geoffrey Garen.

Provide better names for ProcessThrottler process assertions, to facilitate debugging.

* UIProcess/GPU/GPUProcessProxy.h:
* UIProcess/Network/NetworkProcessProxy.h:
* UIProcess/ProcessAssertion.cpp:
(WebKit::ProcessAssertion::ProcessAssertion):
* UIProcess/ProcessAssertion.h:
* UIProcess/ProcessThrottler.cpp:
(WebKit::ProcessThrottler::assertionName const):
(WebKit::ProcessThrottler::setAssertionType):
* UIProcess/ProcessThrottler.h:
* UIProcess/ProcessThrottlerClient.h:
* UIProcess/WebProcessProxy.h:
* UIProcess/ios/ProcessAssertionIOS.mm:
(WebKit::ProcessAssertion::ProcessAssertion):
(WebKit::ProcessAndUIAssertion::ProcessAndUIAssertion):

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (260452 => 260453)


--- trunk/Source/WebKit/ChangeLog	2020-04-21 20:52:54 UTC (rev 260452)
+++ trunk/Source/WebKit/ChangeLog	2020-04-21 21:22:25 UTC (rev 260453)
@@ -1,3 +1,27 @@
+2020-04-21  Chris Dumez  <cdu...@apple.com>
+
+        [iOS] Provide better names for ProcessThrottler process assertions
+        https://bugs.webkit.org/show_bug.cgi?id=210808
+
+        Reviewed by Geoffrey Garen.
+
+        Provide better names for ProcessThrottler process assertions, to facilitate debugging.
+
+        * UIProcess/GPU/GPUProcessProxy.h:
+        * UIProcess/Network/NetworkProcessProxy.h:
+        * UIProcess/ProcessAssertion.cpp:
+        (WebKit::ProcessAssertion::ProcessAssertion):
+        * UIProcess/ProcessAssertion.h:
+        * UIProcess/ProcessThrottler.cpp:
+        (WebKit::ProcessThrottler::assertionName const):
+        (WebKit::ProcessThrottler::setAssertionType):
+        * UIProcess/ProcessThrottler.h:
+        * UIProcess/ProcessThrottlerClient.h:
+        * UIProcess/WebProcessProxy.h:
+        * UIProcess/ios/ProcessAssertionIOS.mm:
+        (WebKit::ProcessAssertion::ProcessAssertion):
+        (WebKit::ProcessAndUIAssertion::ProcessAndUIAssertion):
+
 2020-04-21  Daniel Bates  <daba...@apple.com>
 
         [iOS] -_didFinishTextInteractionInTextInputContext should only zoom to reveal focused element if it changed

Modified: trunk/Source/WebKit/UIProcess/GPU/GPUProcessProxy.h (260452 => 260453)


--- trunk/Source/WebKit/UIProcess/GPU/GPUProcessProxy.h	2020-04-21 20:52:54 UTC (rev 260452)
+++ trunk/Source/WebKit/UIProcess/GPU/GPUProcessProxy.h	2020-04-21 21:22:25 UTC (rev 260453)
@@ -62,6 +62,7 @@
 
     // ProcessThrottlerClient
     void sendProcessDidResume() final { }
+    ASCIILiteral clientName() const final { return "GPUProcess"_s; }
 
 #if ENABLE(MEDIA_STREAM)
     void setUseMockCaptureDevices(bool);

Modified: trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.h (260452 => 260453)


--- trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.h	2020-04-21 20:52:54 UTC (rev 260452)
+++ trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.h	2020-04-21 21:22:25 UTC (rev 260453)
@@ -207,6 +207,7 @@
 
     // ProcessThrottlerClient
     void sendProcessDidResume() final;
+    ASCIILiteral clientName() const final { return "NetworkProcess"_s; }
     
     void sendProcessWillSuspendImminentlyForTesting();
 

Modified: trunk/Source/WebKit/UIProcess/ProcessAssertion.cpp (260452 => 260453)


--- trunk/Source/WebKit/UIProcess/ProcessAssertion.cpp	2020-04-21 20:52:54 UTC (rev 260452)
+++ trunk/Source/WebKit/UIProcess/ProcessAssertion.cpp	2020-04-21 21:22:25 UTC (rev 260453)
@@ -32,7 +32,7 @@
 
 namespace WebKit {
 
-ProcessAssertion::ProcessAssertion(ProcessID pid, ASCIILiteral, ProcessAssertionType assertionType)
+ProcessAssertion::ProcessAssertion(ProcessID pid, const String&, ProcessAssertionType assertionType)
     : m_assertionType(assertionType)
     , m_pid(pid)
 {

Modified: trunk/Source/WebKit/UIProcess/ProcessAssertion.h (260452 => 260453)


--- trunk/Source/WebKit/UIProcess/ProcessAssertion.h	2020-04-21 20:52:54 UTC (rev 260452)
+++ trunk/Source/WebKit/UIProcess/ProcessAssertion.h	2020-04-21 21:22:25 UTC (rev 260453)
@@ -62,7 +62,7 @@
         virtual void uiAssertionWillExpireImminently() = 0;
     };
 
-    ProcessAssertion(ProcessID, ASCIILiteral reason, ProcessAssertionType);
+    ProcessAssertion(ProcessID, const String& reason, ProcessAssertionType);
     virtual ~ProcessAssertion();
 
     void setClient(Client& client) { m_client = &client; }
@@ -95,7 +95,7 @@
 
 class ProcessAndUIAssertion final : public ProcessAssertion {
 public:
-    ProcessAndUIAssertion(ProcessID, ASCIILiteral reason, ProcessAssertionType);
+    ProcessAndUIAssertion(ProcessID, const String& reason, ProcessAssertionType);
     ~ProcessAndUIAssertion();
 
     void uiAssertionWillExpireImminently();

Modified: trunk/Source/WebKit/UIProcess/ProcessThrottler.cpp (260452 => 260453)


--- trunk/Source/WebKit/UIProcess/ProcessThrottler.cpp	2020-04-21 20:52:54 UTC (rev 260452)
+++ trunk/Source/WebKit/UIProcess/ProcessThrottler.cpp	2020-04-21 21:22:25 UTC (rev 260453)
@@ -100,6 +100,28 @@
     setAssertionType(expectedAssertionType());
 }
 
+String ProcessThrottler::assertionName(ProcessAssertionType type) const
+{
+    ASCIILiteral typeString = [type] {
+        switch (type) {
+        case ProcessAssertionType::Foreground:
+            return "Foreground"_s;
+        case ProcessAssertionType::Background:
+            return "Background"_s;
+        case ProcessAssertionType::Suspended:
+            return "Suspended"_s;
+        case ProcessAssertionType::UnboundedNetworking:
+        case ProcessAssertionType::MediaPlayback:
+        case ProcessAssertionType::DependentProcessLink:
+            ASSERT_NOT_REACHED(); // These other assertion types are not used by the ProcessThrottler.
+            break;
+        }
+        return "Unknown"_s;
+    }();
+
+    return makeString(m_process.clientName(), " ", typeString, " Assertion");
+}
+
 void ProcessThrottler::setAssertionType(ProcessAssertionType newType)
 {
     if (m_assertion && m_assertion->type() == newType)
@@ -107,9 +129,9 @@
 
     PROCESSTHROTTLER_RELEASE_LOG("setAssertionType: Updating process assertion type to %u (foregroundActivities: %u, backgroundActivities: %u)", newType, m_foregroundActivities.size(), m_backgroundActivities.size());
     if (m_shouldTakeUIBackgroundAssertion)
-        m_assertion = makeUnique<ProcessAndUIAssertion>(m_processIdentifier, "Web content visibility"_s, newType);
+        m_assertion = makeUnique<ProcessAndUIAssertion>(m_processIdentifier, assertionName(newType), newType);
     else
-        m_assertion = makeUnique<ProcessAssertion>(m_processIdentifier, "Web content visibility"_s, newType);
+        m_assertion = makeUnique<ProcessAssertion>(m_processIdentifier, assertionName(newType), newType);
     m_process.didSetAssertionType(newType);
 }
     

Modified: trunk/Source/WebKit/UIProcess/ProcessThrottler.h (260452 => 260453)


--- trunk/Source/WebKit/UIProcess/ProcessThrottler.h	2020-04-21 20:52:54 UTC (rev 260452)
+++ trunk/Source/WebKit/UIProcess/ProcessThrottler.h	2020-04-21 21:22:25 UTC (rev 260453)
@@ -120,6 +120,7 @@
     void removeActivity(ForegroundActivity&);
     void removeActivity(BackgroundActivity&);
     void invalidateAllActivities();
+    String assertionName(ProcessAssertionType) const;
 
     // ProcessAssertionClient
     void uiAssertionWillExpireImminently() override;

Modified: trunk/Source/WebKit/UIProcess/ProcessThrottlerClient.h (260452 => 260453)


--- trunk/Source/WebKit/UIProcess/ProcessThrottlerClient.h	2020-04-21 20:52:54 UTC (rev 260452)
+++ trunk/Source/WebKit/UIProcess/ProcessThrottlerClient.h	2020-04-21 21:22:25 UTC (rev 260453)
@@ -39,6 +39,7 @@
     virtual void sendPrepareToSuspend(IsSuspensionImminent, CompletionHandler<void()>&&) = 0;
     virtual void sendProcessDidResume() = 0;
     virtual void didSetAssertionType(ProcessAssertionType) { };
+    virtual ASCIILiteral clientName() const = 0;
 };
 
 } // namespace WebKit

Modified: trunk/Source/WebKit/UIProcess/WebProcessProxy.h (260452 => 260453)


--- trunk/Source/WebKit/UIProcess/WebProcessProxy.h	2020-04-21 20:52:54 UTC (rev 260452)
+++ trunk/Source/WebKit/UIProcess/WebProcessProxy.h	2020-04-21 21:22:25 UTC (rev 260453)
@@ -318,6 +318,7 @@
     void sendPrepareToSuspend(IsSuspensionImminent, CompletionHandler<void()>&&) final;
     void sendProcessDidResume() final;
     void didSetAssertionType(ProcessAssertionType) final;
+    ASCIILiteral clientName() const final { return "WebProcess"_s; }
 
 #if PLATFORM(COCOA)
     enum SandboxExtensionType : uint32_t {

Modified: trunk/Source/WebKit/UIProcess/ios/ProcessAssertionIOS.mm (260452 => 260453)


--- trunk/Source/WebKit/UIProcess/ios/ProcessAssertionIOS.mm	2020-04-21 20:52:54 UTC (rev 260452)
+++ trunk/Source/WebKit/UIProcess/ios/ProcessAssertionIOS.mm	2020-04-21 21:22:25 UTC (rev 260453)
@@ -357,22 +357,21 @@
     }
 }
 
-ProcessAssertion::ProcessAssertion(pid_t pid, ASCIILiteral reason, ProcessAssertionType assertionType)
+ProcessAssertion::ProcessAssertion(pid_t pid, const String& reason, ProcessAssertionType assertionType)
     : m_assertionType(assertionType)
     , m_pid(pid)
 {
     auto weakThis = makeWeakPtr(*this);
-    NSString *nsReason = [NSString stringWithCString:reason.characters() encoding:NSASCIIStringEncoding];
     NSString *runningBoardAssertionName = runningBoardNameForAssertionType(assertionType);
     if (runningBoardAssertionName) {
         if (!pid) {
-            RELEASE_LOG_ERROR(ProcessSuspension, "%p - ProcessAssertion: Failed to acquire RBS %{public}@ assertion '%{public}s' for process because PID is invalid", this, runningBoardAssertionName, reason.characters());
+            RELEASE_LOG_ERROR(ProcessSuspension, "%p - ProcessAssertion: Failed to acquire RBS %{public}@ assertion '%{public}s' for process because PID is invalid", this, runningBoardAssertionName, reason.utf8().data());
             return;
         }
 
         RBSTarget *target = [RBSTarget targetWithPid:pid];
         RBSDomainAttribute *domainAttribute = [RBSDomainAttribute attributeWithDomain:@"com.apple.webkit" name:runningBoardAssertionName];
-        m_rbsAssertion = adoptNS([[RBSAssertion alloc] initWithExplanation:nsReason target:target attributes:@[domainAttribute]]);
+        m_rbsAssertion = adoptNS([[RBSAssertion alloc] initWithExplanation:reason target:target attributes:@[domainAttribute]]);
 
         m_delegate = adoptNS([[WKRBSAssertionDelegate alloc] init]);
         [m_rbsAssertion addObserver:m_delegate.get()];
@@ -383,13 +382,13 @@
 
         NSError *acquisitionError = nil;
         if (![m_rbsAssertion acquireWithError:&acquisitionError]) {
-            RELEASE_LOG_ERROR(ProcessSuspension, "%p - ProcessAssertion: Failed to acquire RBS %{public}@ assertion '%{public}s' for process with PID %d, error: %{public}@", this, runningBoardAssertionName, reason.characters(), pid, acquisitionError);
+            RELEASE_LOG_ERROR(ProcessSuspension, "%p - ProcessAssertion: Failed to acquire RBS %{public}@ assertion '%{public}s' for process with PID %d, error: %{public}@", this, runningBoardAssertionName, reason.utf8().data(), pid, acquisitionError);
             dispatch_async(dispatch_get_main_queue(), ^{
                 if (weakThis)
                     processAssertionWasInvalidated();
             });
         } else
-            RELEASE_LOG(ProcessSuspension, "%p - ProcessAssertion: Successfully took RBS %{public}@ assertion '%{public}s' for process with PID %d", this, runningBoardAssertionName, reason.characters(), pid);
+            RELEASE_LOG(ProcessSuspension, "%p - ProcessAssertion: Successfully took RBS %{public}@ assertion '%{public}s' for process with PID %d", this, runningBoardAssertionName, reason.utf8().data(), pid);
     } else {
         // Legacy code path.
         BKSProcessAssertionAcquisitionHandler handler = ^(BOOL acquired) {
@@ -401,9 +400,9 @@
                 });
             }
         };
-        RELEASE_LOG(ProcessSuspension, "%p - ProcessAssertion() PID %d acquiring BKS assertion for process with PID %d, name '%s'", this, getpid(), pid, reason.characters());
+        RELEASE_LOG(ProcessSuspension, "%p - ProcessAssertion() PID %d acquiring BKS assertion for process with PID %d, name '%s'", this, getpid(), pid, reason.utf8().data());
 
-        m_bksAssertion = adoptNS([[BKSProcessAssertion alloc] initWithPID:pid flags:flagsForAssertionType(assertionType) reason:toBKSProcessAssertionReason(assertionType) name:nsReason withHandler:handler]);
+        m_bksAssertion = adoptNS([[BKSProcessAssertion alloc] initWithPID:pid flags:flagsForAssertionType(assertionType) reason:toBKSProcessAssertionReason(assertionType) name:reason withHandler:handler]);
 
         m_bksAssertion.get().invalidationHandler = ^() {
             dispatch_async(dispatch_get_main_queue(), ^{
@@ -450,7 +449,7 @@
     m_isHoldingBackgroundTask = shouldHoldBackgroundTask;
 }
 
-ProcessAndUIAssertion::ProcessAndUIAssertion(pid_t pid, ASCIILiteral reason, ProcessAssertionType assertionType)
+ProcessAndUIAssertion::ProcessAndUIAssertion(pid_t pid, const String& reason, ProcessAssertionType assertionType)
     : ProcessAssertion(pid, reason, assertionType)
 {
     updateRunInBackgroundCount();
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to