Diff
Modified: trunk/Source/WebKit/ChangeLog (260641 => 260642)
--- trunk/Source/WebKit/ChangeLog 2020-04-24 14:22:10 UTC (rev 260641)
+++ trunk/Source/WebKit/ChangeLog 2020-04-24 14:57:32 UTC (rev 260642)
@@ -1,3 +1,26 @@
+2020-04-24 Chris Dumez <[email protected]>
+
+ [iOS] Stop using legacy BKSApplicationStateMonitor
+ https://bugs.webkit.org/show_bug.cgi?id=210945
+
+ Reviewed by Tim Horton.
+
+ Stop using legacy BKSApplicationStateMonitor and use RunningBoard API instead.
+
+ * Configurations/WebKit.xcconfig:
+ Stop linking against ApplicationServices when using iOS 14 SDK now that we are
+ fully transitioned to RunningBoard.
+
+ * Platform/spi/ios/RunningBoardServicesSPI.h:
+ * UIProcess/ApplicationStateTracker.h:
+ * UIProcess/ApplicationStateTracker.mm:
+ (WebKit::ApplicationStateTracker::ApplicationStateTracker):
+ (WebKit::isApplicationForeground):
+ (WebKit::ApplicationStateTracker::~ApplicationStateTracker):
+ (WebKit::isBackgroundState): Deleted.
+ * UIProcess/ios/PageClientImplIOS.mm:
+ (WebKit::PageClientImpl::isApplicationVisible):
+
2020-04-23 Simon Fraser <[email protected]>
Bounce displayWasRefreshed() via EventDispatcher
Modified: trunk/Source/WebKit/Configurations/WebKit.xcconfig (260641 => 260642)
--- trunk/Source/WebKit/Configurations/WebKit.xcconfig 2020-04-24 14:22:10 UTC (rev 260641)
+++ trunk/Source/WebKit/Configurations/WebKit.xcconfig 2020-04-24 14:57:32 UTC (rev 260642)
@@ -48,8 +48,16 @@
WK_APPKIT_LDFLAGS_macosx = -framework AppKit;
WK_APPKIT_LDFLAGS_maccatalyst = -framework AppKit;
-WK_ASSERTION_SERVICES_LDFLAGS = $(WK_ASSERTION_SERVICES_LDFLAGS_$(WK_COCOA_TOUCH));
-WK_ASSERTION_SERVICES_LDFLAGS_cocoatouch = -framework AssertionServices;
+WK_ASSERTION_SERVICES_LDFLAGS = $(WK_ASSERTION_SERVICES_LDFLAGS_$(WK_PLATFORM_NAME));
+WK_ASSERTION_SERVICES_LDFLAGS_iphoneos = $(WK_ASSERTION_SERVICES_LDFLAGS$(WK_IOS_14));
+WK_ASSERTION_SERVICES_LDFLAGS_iphonesimulator = $(WK_ASSERTION_SERVICES_LDFLAGS$(WK_IOS_14));
+WK_ASSERTION_SERVICES_LDFLAGS_IOS_BEFORE_14 = -framework AssertionServices;
+// FIXME: It is unnecessary to link against AssertionServices with the latest SDK for the following platforms too.
+WK_ASSERTION_SERVICES_LDFLAGS_watchos = -framework AssertionServices;
+WK_ASSERTION_SERVICES_LDFLAGS_watchsimulator = -framework AssertionServices;
+WK_ASSERTION_SERVICES_LDFLAGS_appletvos = -framework AssertionServices;
+WK_ASSERTION_SERVICES_LDFLAGS_appletvsimulator = -framework AssertionServices;
+WK_ASSERTION_SERVICES_LDFLAGS_maccatalyst = -framework AssertionServices;
WK_RUNNINGBOARD_SERVICES_LDFLAGS = $(WK_RUNNINGBOARD_SERVICES_LDFLAGS_$(WK_COCOA_TOUCH));
WK_RUNNINGBOARD_SERVICES_LDFLAGS_cocoatouch = -framework RunningBoardServices;
Modified: trunk/Source/WebKit/Platform/spi/ios/RunningBoardServicesSPI.h (260641 => 260642)
--- trunk/Source/WebKit/Platform/spi/ios/RunningBoardServicesSPI.h 2020-04-24 14:22:10 UTC (rev 260641)
+++ trunk/Source/WebKit/Platform/spi/ios/RunningBoardServicesSPI.h 2020-04-24 14:57:32 UTC (rev 260642)
@@ -42,10 +42,7 @@
+ (RBSTarget *)targetWithPid:(pid_t)pid;
@end
-@protocol RBSAssertionObserving <NSObject>
-- (void)assertionWillInvalidate:(RBSAssertion *)assertion;
-- (void)assertion:(RBSAssertion *)assertion didInvalidateWithError:(NSError *)error;
-@end
+@protocol RBSAssertionObserving;
@interface RBSAssertion : NSObject
- (instancetype)initWithExplanation:(NSString *)explanation target:(RBSTarget *)target attributes:(NSArray <RBSAttribute *> *)attributes;
@@ -55,4 +52,31 @@
- (void)removeObserver:(id <RBSAssertionObserving>)observer;
@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: trunk/Source/WebKit/UIProcess/ApplicationStateTracker.h (260641 => 260642)
--- trunk/Source/WebKit/UIProcess/ApplicationStateTracker.h 2020-04-24 14:22:10 UTC (rev 260641)
+++ trunk/Source/WebKit/UIProcess/ApplicationStateTracker.h 2020-04-24 14:57:32 UTC (rev 260642)
@@ -62,8 +62,6 @@
bool m_isInBackground;
- RetainPtr<BKSApplicationStateMonitor> m_applicationStateMonitor;
-
id m_didEnterBackgroundObserver;
id m_didFinishSnapshottingAfterEnteringBackgroundObserver;
id m_willEnterForegroundObserver;
@@ -80,6 +78,7 @@
};
ApplicationType applicationType(UIWindow *);
+bool isApplicationForeground(pid_t);
}
Modified: trunk/Source/WebKit/UIProcess/ApplicationStateTracker.mm (260641 => 260642)
--- trunk/Source/WebKit/UIProcess/ApplicationStateTracker.mm 2020-04-24 14:22:10 UTC (rev 260641)
+++ trunk/Source/WebKit/UIProcess/ApplicationStateTracker.mm 2020-04-24 14:57:32 UTC (rev 260642)
@@ -30,6 +30,7 @@
#import "AssertionServicesSPI.h"
#import "Logging.h"
+#import "RunningBoardServicesSPI.h"
#import "SandboxUtilities.h"
#import "UIKitSPI.h"
#import <wtf/ObjCRuntimeExtras.h>
@@ -63,18 +64,6 @@
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)
@@ -168,9 +157,7 @@
pid_t applicationPID = serviceViewController._hostProcessIdentifier;
ASSERT(applicationPID);
- auto applicationStateMonitor = adoptNS([[BKSApplicationStateMonitor alloc] init]);
- m_isInBackground = isBackgroundState([applicationStateMonitor mostElevatedApplicationStateForPID:applicationPID]);
- [applicationStateMonitor invalidate];
+ m_isInBackground = !isApplicationForeground(applicationPID);
// 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
@@ -194,13 +181,33 @@
}
}
+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: trunk/Source/WebKit/UIProcess/ios/PageClientImplIOS.mm (260641 => 260642)
--- trunk/Source/WebKit/UIProcess/ios/PageClientImplIOS.mm 2020-04-24 14:22:10 UTC (rev 260641)
+++ trunk/Source/WebKit/UIProcess/ios/PageClientImplIOS.mm 2020-04-24 14:57:32 UTC (rev 260642)
@@ -38,6 +38,7 @@
#import "InteractionInformationAtPosition.h"
#import "NativeWebKeyboardEvent.h"
#import "NavigationState.h"
+#import "RunningBoardServicesSPI.h"
#import "StringUtilities.h"
#import "UIKitSPI.h"
#import "UndoOrRedo.h"
@@ -168,10 +169,7 @@
pid_t applicationPID = serviceViewController._hostProcessIdentifier;
ASSERT(applicationPID);
- auto applicationStateMonitor = adoptNS([[BKSApplicationStateMonitor alloc] init]);
- auto applicationState = [applicationStateMonitor mostElevatedApplicationStateForPID:applicationPID];
- [applicationStateMonitor invalidate];
- return applicationState != BKSApplicationStateBackgroundRunning && applicationState != BKSApplicationStateBackgroundTaskSuspended;
+ return isApplicationForeground(applicationPID);
}
bool PageClientImpl::isViewInWindow()
Modified: trunk/WebKitLibraries/ChangeLog (260641 => 260642)
--- trunk/WebKitLibraries/ChangeLog 2020-04-24 14:22:10 UTC (rev 260641)
+++ trunk/WebKitLibraries/ChangeLog 2020-04-24 14:57:32 UTC (rev 260642)
@@ -1,3 +1,12 @@
+2020-04-24 Chris Dumez <[email protected]>
+
+ [iOS] Stop using legacy BKSApplicationStateMonitor
+ https://bugs.webkit.org/show_bug.cgi?id=210945
+
+ Reviewed by Tim Horton.
+
+ * WebKitPrivateFrameworkStubs/iOS/13/RunningBoardServices.framework/RunningBoardServices.tbd:
+
2020-03-16 Keith Rollin <[email protected]>
Remove support for WebKitSystemInterface
Modified: trunk/WebKitLibraries/WebKitPrivateFrameworkStubs/iOS/13/RunningBoardServices.framework/RunningBoardServices.tbd (260641 => 260642)
--- trunk/WebKitLibraries/WebKitPrivateFrameworkStubs/iOS/13/RunningBoardServices.framework/RunningBoardServices.tbd 2020-04-24 14:22:10 UTC (rev 260641)
+++ trunk/WebKitLibraries/WebKitPrivateFrameworkStubs/iOS/13/RunningBoardServices.framework/RunningBoardServices.tbd 2020-04-24 14:57:32 UTC (rev 260642)
@@ -5,5 +5,5 @@
platform: ios
exports:
- archs: [ x86_64, arm64, arm64e ]
- objc-classes: [ RBSAttribute, RBSDomainAttribute, RBSTarget, RBSAssertion ]
+ objc-classes: [ RBSAttribute, RBSDomainAttribute, RBSTarget, RBSAssertion, RBSProcessIdentifier, RBSProcessState, RBSProcessHandle ]
...