Title: [260574] trunk/Source/WebKit
Revision
260574
Author
[email protected]
Date
2020-04-23 09:27:03 -0700 (Thu, 23 Apr 2020)

Log Message

[iOS] Port MediaPlayback process assertion to RunningBoard
https://bugs.webkit.org/show_bug.cgi?id=210212
<rdar://problem/61476951>

Reviewed by Geoff Garen.

Port MediaPlayback process assertion to RunningBoard instead of the legacy BKSProcessAssertion.
We can now #ifdef out the legacy BKSProcessAssertion on recent iOS builds.

* UIProcess/ProcessAssertion.h:
* UIProcess/ios/ProcessAssertionIOS.mm:
(WebKit::runningBoardNameForAssertionType):
(WebKit::ProcessAssertion::ProcessAssertion):
(WebKit::ProcessAssertion::~ProcessAssertion):

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (260573 => 260574)


--- trunk/Source/WebKit/ChangeLog	2020-04-23 16:12:04 UTC (rev 260573)
+++ trunk/Source/WebKit/ChangeLog	2020-04-23 16:27:03 UTC (rev 260574)
@@ -1,3 +1,20 @@
+2020-04-23  Chris Dumez  <[email protected]>
+
+        [iOS] Port MediaPlayback process assertion to RunningBoard
+        https://bugs.webkit.org/show_bug.cgi?id=210212
+        <rdar://problem/61476951>
+
+        Reviewed by Geoff Garen.
+
+        Port MediaPlayback process assertion to RunningBoard instead of the legacy BKSProcessAssertion.
+        We can now #ifdef out the legacy BKSProcessAssertion on recent iOS builds.
+
+        * UIProcess/ProcessAssertion.h:
+        * UIProcess/ios/ProcessAssertionIOS.mm:
+        (WebKit::runningBoardNameForAssertionType):
+        (WebKit::ProcessAssertion::ProcessAssertion):
+        (WebKit::ProcessAssertion::~ProcessAssertion):
+
 2020-04-23  John Frankish  <[email protected]>
 
         [GTK] Crash in cairo_surface_mark_dirty_rectangle() in accelerated compositing mode under X11

Modified: trunk/Source/WebKit/UIProcess/ProcessAssertion.h (260573 => 260574)


--- trunk/Source/WebKit/UIProcess/ProcessAssertion.h	2020-04-23 16:12:04 UTC (rev 260573)
+++ trunk/Source/WebKit/UIProcess/ProcessAssertion.h	2020-04-23 16:27:03 UTC (rev 260574)
@@ -39,7 +39,9 @@
 
 OBJC_CLASS RBSAssertion;
 OBJC_CLASS WKRBSAssertionDelegate;
+#if !HAVE(RUNNINGBOARD_VISIBILITY_ASSERTIONS)
 OBJC_CLASS BKSProcessAssertion;
+#endif
 #endif // PLATFORM(IOS_FAMILY)
 
 namespace WebKit {
@@ -85,7 +87,9 @@
 #if PLATFORM(IOS_FAMILY)
     RetainPtr<RBSAssertion> m_rbsAssertion;
     RetainPtr<WKRBSAssertionDelegate> m_delegate;
+#if !HAVE(RUNNINGBOARD_VISIBILITY_ASSERTIONS)
     RetainPtr<BKSProcessAssertion> m_bksAssertion; // Legacy.
+#endif
     Validity m_validity { Validity::Unset };
 #endif
     Client* m_client { nullptr };

Modified: trunk/Source/WebKit/UIProcess/ios/ProcessAssertionIOS.mm (260573 => 260574)


--- trunk/Source/WebKit/UIProcess/ios/ProcessAssertionIOS.mm	2020-04-23 16:12:04 UTC (rev 260573)
+++ trunk/Source/WebKit/UIProcess/ios/ProcessAssertionIOS.mm	2020-04-23 16:27:03 UTC (rev 260574)
@@ -28,7 +28,6 @@
 
 #if PLATFORM(IOS_FAMILY)
 
-#import "AssertionServicesSPI.h"
 #import "Logging.h"
 #import "RunningBoardServicesSPI.h"
 #import "WebProcessPool.h"
@@ -38,6 +37,10 @@
 #import <wtf/Vector.h>
 #import <wtf/WeakHashSet.h>
 
+#if !HAVE(RUNNINGBOARD_VISIBILITY_ASSERTIONS)
+#import "AssertionServicesSPI.h"
+#endif
+
 using WebKit::ProcessAndUIAssertion;
 
 // This gives some time to our child processes to process the ProcessWillSuspendImminently IPC but makes sure we release
@@ -313,7 +316,7 @@
     case ProcessAssertionType::DependentProcessLink:
         return @"DependentProcessLink";
     case ProcessAssertionType::MediaPlayback:
-        return nil; // FIXME: Name to be defined in <rdar://problem/61263147>.
+        return @"MediaPlayback";
     }
 #else
     if (assertionType == ProcessAssertionType::DependentProcessLink)
@@ -322,6 +325,8 @@
 #endif
 }
 
+#if !HAVE(RUNNINGBOARD_VISIBILITY_ASSERTIONS)
+
 const BKSProcessAssertionFlags suspendedTabFlags = (BKSProcessAssertionAllowIdleSleep);
 const BKSProcessAssertionFlags backgroundTabFlags = (BKSProcessAssertionPreventTaskSuspend);
 const BKSProcessAssertionFlags foregroundTabFlags = (BKSProcessAssertionPreventTaskSuspend | BKSProcessAssertionWantsForegroundResourcePriority | BKSProcessAssertionPreventTaskThrottleDown);
@@ -360,6 +365,8 @@
     }
 }
 
+#endif // !HAVE(RUNNINGBOARD_VISIBILITY_ASSERTIONS)
+
 ProcessAssertion::ProcessAssertion(pid_t pid, const String& reason, ProcessAssertionType assertionType)
     : m_assertionType(assertionType)
     , m_pid(pid)
@@ -366,33 +373,9 @@
 {
     auto weakThis = makeWeakPtr(*this);
     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.utf8().data());
-            return;
-        }
 
-        RBSTarget *target = [RBSTarget targetWithPid:pid];
-        RBSDomainAttribute *domainAttribute = [RBSDomainAttribute attributeWithDomain:@"com.apple.webkit" name:runningBoardAssertionName];
-        m_rbsAssertion = adoptNS([[RBSAssertion alloc] initWithExplanation:reason target:target attributes:@[domainAttribute]]);
-
-        m_delegate = adoptNS([[WKRBSAssertionDelegate alloc] init]);
-        [m_rbsAssertion addObserver:m_delegate.get()];
-        m_delegate.get().invalidationCallback = ^{
-            RELEASE_LOG(ProcessSuspension, "%p - ProcessAssertion() RBS %{public}@ assertion for process with PID %d was invalidated", this, runningBoardAssertionName, pid);
-            processAssertionWasInvalidated();
-        };
-
-        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.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.utf8().data(), pid);
-    } else {
+#if !HAVE(RUNNINGBOARD_VISIBILITY_ASSERTIONS)
+    if (!runningBoardAssertionName) {
         // Legacy code path.
         BKSProcessAssertionAcquisitionHandler handler = ^(BOOL acquired) {
             if (!acquired) {
@@ -414,7 +397,36 @@
                     processAssertionWasInvalidated();
             });
         };
+        return;
     }
+#endif // !HAVE(RUNNINGBOARD_VISIBILITY_ASSERTIONS)
+
+    ASSERT(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.utf8().data());
+        return;
+    }
+
+    RBSTarget *target = [RBSTarget targetWithPid:pid];
+    RBSDomainAttribute *domainAttribute = [RBSDomainAttribute attributeWithDomain:@"com.apple.webkit" name:runningBoardAssertionName];
+    m_rbsAssertion = adoptNS([[RBSAssertion alloc] initWithExplanation:reason target:target attributes:@[domainAttribute]]);
+
+    m_delegate = adoptNS([[WKRBSAssertionDelegate alloc] init]);
+    [m_rbsAssertion addObserver:m_delegate.get()];
+    m_delegate.get().invalidationCallback = ^{
+        RELEASE_LOG(ProcessSuspension, "%p - ProcessAssertion() RBS %{public}@ assertion for process with PID %d was invalidated", this, runningBoardAssertionName, pid);
+        processAssertionWasInvalidated();
+    };
+
+    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.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.utf8().data(), pid);
 }
 
 ProcessAssertion::~ProcessAssertion()
@@ -427,10 +439,14 @@
 
         [m_rbsAssertion removeObserver:m_delegate.get()];
         [m_rbsAssertion invalidate];
-    } else {
+    }
+
+#if !HAVE(RUNNINGBOARD_VISIBILITY_ASSERTIONS)
+    if (m_bksAssertion) {
         m_bksAssertion.get().invalidationHandler = nil;
         [m_bksAssertion invalidate];
     }
+#endif
 }
 
 void ProcessAssertion::processAssertionWasInvalidated()
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to