Title: [261419] branches/safari-610.1.12-branch

Diff

Modified: branches/safari-610.1.12-branch/Source/WebKit/ChangeLog (261418 => 261419)


--- branches/safari-610.1.12-branch/Source/WebKit/ChangeLog	2020-05-08 21:41:59 UTC (rev 261418)
+++ branches/safari-610.1.12-branch/Source/WebKit/ChangeLog	2020-05-08 22:04:18 UTC (rev 261419)
@@ -1,5 +1,9 @@
 2020-05-08  Alan Coon  <[email protected]>
 
+        Revert r260642. rdar://problem/63037576
+
+2020-05-08  Alan Coon  <[email protected]>
+
         Revert r260787. rdar://problem/63032130
 
 2020-05-07  Alan Coon  <[email protected]>

Modified: branches/safari-610.1.12-branch/Source/WebKit/Platform/spi/ios/RunningBoardServicesSPI.h (261418 => 261419)


--- branches/safari-610.1.12-branch/Source/WebKit/Platform/spi/ios/RunningBoardServicesSPI.h	2020-05-08 21:41:59 UTC (rev 261418)
+++ branches/safari-610.1.12-branch/Source/WebKit/Platform/spi/ios/RunningBoardServicesSPI.h	2020-05-08 22:04:18 UTC (rev 261419)
@@ -42,7 +42,10 @@
 + (RBSTarget *)targetWithPid:(pid_t)pid;
 @end
 
-@protocol RBSAssertionObserving;
+@protocol RBSAssertionObserving <NSObject>
+- (void)assertionWillInvalidate:(RBSAssertion *)assertion;
+- (void)assertion:(RBSAssertion *)assertion didInvalidateWithError:(NSError *)error;
+@end
 
 @interface RBSAssertion : NSObject
 - (instancetype)initWithExplanation:(NSString *)explanation target:(RBSTarget *)target attributes:(NSArray <RBSAttribute *> *)attributes;
@@ -54,31 +57,4 @@
 @property (nonatomic, readonly, assign, getter=isValid) BOOL valid;
 @end
 
-@protocol RBSAssertionObserving <NSObject>
-- (void)assertionWillInvalidate:(RBSAssertion *)assertion;
-- (void)assertion:(RBSAssertion *)assertion didInvalidateWithError:(NSError *)error;
-@end
-
-@interface RBSProcessIdentifier : NSObject
-+ (RBSProcessIdentifier *)identifierWithPid:(pid_t)pid;
-@end
-
-typedef NS_ENUM(uint8_t, RBSTaskState) {
-    RBSTaskStateUnknown                 = 0,
-    RBSTaskStateNone                    = 1,
-    RBSTaskStateRunningUnknown          = 2,
-    RBSTaskStateRunningSuspended        = 3,
-    RBSTaskStateRunningScheduled        = 4,
-};
-
-@interface RBSProcessState : NSObject
-@property (nonatomic, readonly, assign) RBSTaskState taskState;
-@property (nonatomic, readonly, copy) NSSet<NSString *> *endowmentNamespaces;
-@end
-
-@interface RBSProcessHandle : NSObject
-+ (RBSProcessHandle *)handleForIdentifier:(RBSProcessIdentifier *)identifier error:(NSError **)outError;
-@property (nonatomic, readonly, strong) RBSProcessState *currentState;
-@end
-
 #endif

Modified: branches/safari-610.1.12-branch/Source/WebKit/UIProcess/ApplicationStateTracker.h (261418 => 261419)


--- branches/safari-610.1.12-branch/Source/WebKit/UIProcess/ApplicationStateTracker.h	2020-05-08 21:41:59 UTC (rev 261418)
+++ branches/safari-610.1.12-branch/Source/WebKit/UIProcess/ApplicationStateTracker.h	2020-05-08 22:04:18 UTC (rev 261419)
@@ -62,6 +62,8 @@
 
     bool m_isInBackground;
 
+    RetainPtr<BKSApplicationStateMonitor> m_applicationStateMonitor;
+
     id m_didEnterBackgroundObserver;
     id m_didFinishSnapshottingAfterEnteringBackgroundObserver;
     id m_willEnterForegroundObserver;
@@ -78,7 +80,6 @@
 };
 
 ApplicationType applicationType(UIWindow *);
-bool isApplicationForeground(pid_t);
 
 }
 

Modified: branches/safari-610.1.12-branch/Source/WebKit/UIProcess/ApplicationStateTracker.mm (261418 => 261419)


--- branches/safari-610.1.12-branch/Source/WebKit/UIProcess/ApplicationStateTracker.mm	2020-05-08 21:41:59 UTC (rev 261418)
+++ branches/safari-610.1.12-branch/Source/WebKit/UIProcess/ApplicationStateTracker.mm	2020-05-08 22:04:18 UTC (rev 261419)
@@ -30,7 +30,6 @@
 
 #import "AssertionServicesSPI.h"
 #import "Logging.h"
-#import "RunningBoardServicesSPI.h"
 #import "SandboxUtilities.h"
 #import "UIKitSPI.h"
 #import <wtf/ObjCRuntimeExtras.h>
@@ -64,6 +63,18 @@
     return ApplicationType::Application;
 }
 
+static bool isBackgroundState(BKSApplicationState state)
+{
+    switch (state) {
+    case BKSApplicationStateBackgroundRunning:
+    case BKSApplicationStateBackgroundTaskSuspended:
+        return true;
+
+    default:
+        return false;
+    }
+}
+
 ApplicationStateTracker::ApplicationStateTracker(UIView *view, SEL didEnterBackgroundSelector, SEL didFinishSnapshottingAfterEnteringBackgroundSelector, SEL willEnterForegroundSelector, SEL willBeginSnapshotSequenceSelector, SEL didCompleteSnapshotSequenceSelector)
     : m_view(view)
     , m_didEnterBackgroundSelector(didEnterBackgroundSelector)
@@ -157,7 +168,9 @@
         pid_t applicationPID = serviceViewController._hostProcessIdentifier;
         ASSERT(applicationPID);
 
-        m_isInBackground = !isApplicationForeground(applicationPID);
+        auto applicationStateMonitor = adoptNS([[BKSApplicationStateMonitor alloc] init]);
+        m_isInBackground = isBackgroundState([applicationStateMonitor mostElevatedApplicationStateForPID:applicationPID]);
+        [applicationStateMonitor invalidate];
 
         // Workaround for <rdar://problem/34028921>. If the host application is StoreKitUIService then it is also a ViewService
         // and is always in the background. We need to treat StoreKitUIService as foreground for the purpose of process suspension
@@ -181,33 +194,13 @@
     }
 }
 
-bool isApplicationForeground(pid_t pid)
-{
-    RBSProcessIdentifier *processIdentifier = [RBSProcessIdentifier identifierWithPid:pid];
-    if (!processIdentifier) {
-        RELEASE_LOG_ERROR(ProcessSuspension, "isApplicationForeground: Failed to construct RBSProcessIdentifier from PID %d", pid);
-        return false;
-    }
-
-    NSError *error = nil;
-    RBSProcessHandle *processHandle = [RBSProcessHandle handleForIdentifier:processIdentifier error:&error];
-    if (!processHandle) {
-        RELEASE_LOG_ERROR(ProcessSuspension, "isApplicationForeground: Failed to get RBSProcessHandle for process with PID %d, error: %{public}@", pid, error);
-        return false;
-    }
-
-    RBSProcessState *state = processHandle.currentState;
-    if (state.taskState != RBSTaskStateRunningScheduled) {
-        RELEASE_LOG_ERROR(ProcessSuspension, "isApplicationForeground: Process with PID %d is not running", pid);
-        return false;
-    }
-
-    return [[state endowmentNamespaces] containsObject:@"com.apple.frontboard.visibility"];
-}
-
 ApplicationStateTracker::~ApplicationStateTracker()
 {
     RELEASE_LOG(ViewState, "%p - ~ApplicationStateTracker", this);
+    if (m_applicationStateMonitor) {
+        [m_applicationStateMonitor invalidate];
+        return;
+    }
 
     NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
     [notificationCenter removeObserver:m_didEnterBackgroundObserver];

Modified: branches/safari-610.1.12-branch/Source/WebKit/UIProcess/ios/PageClientImplIOS.mm (261418 => 261419)


--- branches/safari-610.1.12-branch/Source/WebKit/UIProcess/ios/PageClientImplIOS.mm	2020-05-08 21:41:59 UTC (rev 261418)
+++ branches/safari-610.1.12-branch/Source/WebKit/UIProcess/ios/PageClientImplIOS.mm	2020-05-08 22:04:18 UTC (rev 261419)
@@ -38,7 +38,6 @@
 #import "InteractionInformationAtPosition.h"
 #import "NativeWebKeyboardEvent.h"
 #import "NavigationState.h"
-#import "RunningBoardServicesSPI.h"
 #import "StringUtilities.h"
 #import "UIKitSPI.h"
 #import "UndoOrRedo.h"
@@ -169,7 +168,10 @@
     pid_t applicationPID = serviceViewController._hostProcessIdentifier;
     ASSERT(applicationPID);
 
-    return isApplicationForeground(applicationPID);
+    auto applicationStateMonitor = adoptNS([[BKSApplicationStateMonitor alloc] init]);
+    auto applicationState = [applicationStateMonitor mostElevatedApplicationStateForPID:applicationPID];
+    [applicationStateMonitor invalidate];
+    return applicationState != BKSApplicationStateBackgroundRunning && applicationState != BKSApplicationStateBackgroundTaskSuspended;
 }
 
 bool PageClientImpl::isViewInWindow()

Modified: branches/safari-610.1.12-branch/WebKitLibraries/ChangeLog (261418 => 261419)


--- branches/safari-610.1.12-branch/WebKitLibraries/ChangeLog	2020-05-08 21:41:59 UTC (rev 261418)
+++ branches/safari-610.1.12-branch/WebKitLibraries/ChangeLog	2020-05-08 22:04:18 UTC (rev 261419)
@@ -1,3 +1,7 @@
+2020-05-08  Alan Coon  <[email protected]>
+
+        Revert r260642. rdar://problem/63037576
+
 2020-04-24  Chris Dumez  <[email protected]>
 
         [iOS] Stop using legacy BKSApplicationStateMonitor

Modified: branches/safari-610.1.12-branch/WebKitLibraries/WebKitPrivateFrameworkStubs/iOS/13/RunningBoardServices.framework/RunningBoardServices.tbd (261418 => 261419)


--- branches/safari-610.1.12-branch/WebKitLibraries/WebKitPrivateFrameworkStubs/iOS/13/RunningBoardServices.framework/RunningBoardServices.tbd	2020-05-08 21:41:59 UTC (rev 261418)
+++ branches/safari-610.1.12-branch/WebKitLibraries/WebKitPrivateFrameworkStubs/iOS/13/RunningBoardServices.framework/RunningBoardServices.tbd	2020-05-08 22:04:18 UTC (rev 261419)
@@ -5,5 +5,5 @@
 platform: ios
 exports:
   - archs:           [ x86_64, arm64, arm64e ]
-    objc-classes:    [ RBSAttribute, RBSDomainAttribute, RBSTarget, RBSAssertion, RBSProcessIdentifier, RBSProcessState, RBSProcessHandle ]
+    objc-classes:    [ RBSAttribute, RBSDomainAttribute, RBSTarget, RBSAssertion ]
 ...
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to