Changeset 260642 in webkit
- Timestamp:
- Apr 24, 2020 7:57:32 AM (4 years ago)
- Location:
- trunk
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/ChangeLog
r260614 r260642 1 2020-04-24 Chris Dumez <cdumez@apple.com> 2 3 [iOS] Stop using legacy BKSApplicationStateMonitor 4 https://bugs.webkit.org/show_bug.cgi?id=210945 5 6 Reviewed by Tim Horton. 7 8 Stop using legacy BKSApplicationStateMonitor and use RunningBoard API instead. 9 10 * Configurations/WebKit.xcconfig: 11 Stop linking against ApplicationServices when using iOS 14 SDK now that we are 12 fully transitioned to RunningBoard. 13 14 * Platform/spi/ios/RunningBoardServicesSPI.h: 15 * UIProcess/ApplicationStateTracker.h: 16 * UIProcess/ApplicationStateTracker.mm: 17 (WebKit::ApplicationStateTracker::ApplicationStateTracker): 18 (WebKit::isApplicationForeground): 19 (WebKit::ApplicationStateTracker::~ApplicationStateTracker): 20 (WebKit::isBackgroundState): Deleted. 21 * UIProcess/ios/PageClientImplIOS.mm: 22 (WebKit::PageClientImpl::isApplicationVisible): 23 1 24 2020-04-23 Simon Fraser <simon.fraser@apple.com> 2 25 -
trunk/Source/WebKit/Configurations/WebKit.xcconfig
r260581 r260642 49 49 WK_APPKIT_LDFLAGS_maccatalyst = -framework AppKit; 50 50 51 WK_ASSERTION_SERVICES_LDFLAGS = $(WK_ASSERTION_SERVICES_LDFLAGS_$(WK_COCOA_TOUCH)); 52 WK_ASSERTION_SERVICES_LDFLAGS_cocoatouch = -framework AssertionServices; 51 WK_ASSERTION_SERVICES_LDFLAGS = $(WK_ASSERTION_SERVICES_LDFLAGS_$(WK_PLATFORM_NAME)); 52 WK_ASSERTION_SERVICES_LDFLAGS_iphoneos = $(WK_ASSERTION_SERVICES_LDFLAGS$(WK_IOS_14)); 53 WK_ASSERTION_SERVICES_LDFLAGS_iphonesimulator = $(WK_ASSERTION_SERVICES_LDFLAGS$(WK_IOS_14)); 54 WK_ASSERTION_SERVICES_LDFLAGS_IOS_BEFORE_14 = -framework AssertionServices; 55 // FIXME: It is unnecessary to link against AssertionServices with the latest SDK for the following platforms too. 56 WK_ASSERTION_SERVICES_LDFLAGS_watchos = -framework AssertionServices; 57 WK_ASSERTION_SERVICES_LDFLAGS_watchsimulator = -framework AssertionServices; 58 WK_ASSERTION_SERVICES_LDFLAGS_appletvos = -framework AssertionServices; 59 WK_ASSERTION_SERVICES_LDFLAGS_appletvsimulator = -framework AssertionServices; 60 WK_ASSERTION_SERVICES_LDFLAGS_maccatalyst = -framework AssertionServices; 53 61 54 62 WK_RUNNINGBOARD_SERVICES_LDFLAGS = $(WK_RUNNINGBOARD_SERVICES_LDFLAGS_$(WK_COCOA_TOUCH)); -
trunk/Source/WebKit/Platform/spi/ios/RunningBoardServicesSPI.h
r259610 r260642 43 43 @end 44 44 45 @protocol RBSAssertionObserving <NSObject> 46 - (void)assertionWillInvalidate:(RBSAssertion *)assertion; 47 - (void)assertion:(RBSAssertion *)assertion didInvalidateWithError:(NSError *)error; 48 @end 45 @protocol RBSAssertionObserving; 49 46 50 47 @interface RBSAssertion : NSObject … … 56 53 @end 57 54 55 @protocol RBSAssertionObserving <NSObject> 56 - (void)assertionWillInvalidate:(RBSAssertion *)assertion; 57 - (void)assertion:(RBSAssertion *)assertion didInvalidateWithError:(NSError *)error; 58 @end 59 60 @interface RBSProcessIdentifier : NSObject 61 + (RBSProcessIdentifier *)identifierWithPid:(pid_t)pid; 62 @end 63 64 typedef NS_ENUM(uint8_t, RBSTaskState) { 65 RBSTaskStateUnknown = 0, 66 RBSTaskStateNone = 1, 67 RBSTaskStateRunningUnknown = 2, 68 RBSTaskStateRunningSuspended = 3, 69 RBSTaskStateRunningScheduled = 4, 70 }; 71 72 @interface RBSProcessState : NSObject 73 @property (nonatomic, readonly, assign) RBSTaskState taskState; 74 @property (nonatomic, readonly, copy) NSSet<NSString *> *endowmentNamespaces; 75 @end 76 77 @interface RBSProcessHandle : NSObject 78 + (RBSProcessHandle *)handleForIdentifier:(RBSProcessIdentifier *)identifier error:(NSError **)outError; 79 @property (nonatomic, readonly, strong) RBSProcessState *currentState; 80 @end 81 58 82 #endif -
trunk/Source/WebKit/UIProcess/ApplicationStateTracker.h
r258767 r260642 63 63 bool m_isInBackground; 64 64 65 RetainPtr<BKSApplicationStateMonitor> m_applicationStateMonitor;66 67 65 id m_didEnterBackgroundObserver; 68 66 id m_didFinishSnapshottingAfterEnteringBackgroundObserver; … … 81 79 82 80 ApplicationType applicationType(UIWindow *); 81 bool isApplicationForeground(pid_t); 83 82 84 83 } -
trunk/Source/WebKit/UIProcess/ApplicationStateTracker.mm
r258767 r260642 31 31 #import "AssertionServicesSPI.h" 32 32 #import "Logging.h" 33 #import "RunningBoardServicesSPI.h" 33 34 #import "SandboxUtilities.h" 34 35 #import "UIKitSPI.h" … … 62 63 63 64 return ApplicationType::Application; 64 }65 66 static bool isBackgroundState(BKSApplicationState state)67 {68 switch (state) {69 case BKSApplicationStateBackgroundRunning:70 case BKSApplicationStateBackgroundTaskSuspended:71 return true;72 73 default:74 return false;75 }76 65 } 77 66 … … 169 158 ASSERT(applicationPID); 170 159 171 auto applicationStateMonitor = adoptNS([[BKSApplicationStateMonitor alloc] init]); 172 m_isInBackground = isBackgroundState([applicationStateMonitor mostElevatedApplicationStateForPID:applicationPID]); 173 [applicationStateMonitor invalidate]; 160 m_isInBackground = !isApplicationForeground(applicationPID); 174 161 175 162 // Workaround for <rdar://problem/34028921>. If the host application is StoreKitUIService then it is also a ViewService … … 195 182 } 196 183 184 bool isApplicationForeground(pid_t pid) 185 { 186 RBSProcessIdentifier *processIdentifier = [RBSProcessIdentifier identifierWithPid:pid]; 187 if (!processIdentifier) { 188 RELEASE_LOG_ERROR(ProcessSuspension, "isApplicationForeground: Failed to construct RBSProcessIdentifier from PID %d", pid); 189 return false; 190 } 191 192 NSError *error = nil; 193 RBSProcessHandle *processHandle = [RBSProcessHandle handleForIdentifier:processIdentifier error:&error]; 194 if (!processHandle) { 195 RELEASE_LOG_ERROR(ProcessSuspension, "isApplicationForeground: Failed to get RBSProcessHandle for process with PID %d, error: %{public}@", pid, error); 196 return false; 197 } 198 199 RBSProcessState *state = processHandle.currentState; 200 if (state.taskState != RBSTaskStateRunningScheduled) { 201 RELEASE_LOG_ERROR(ProcessSuspension, "isApplicationForeground: Process with PID %d is not running", pid); 202 return false; 203 } 204 205 return [[state endowmentNamespaces] containsObject:@"com.apple.frontboard.visibility"]; 206 } 207 197 208 ApplicationStateTracker::~ApplicationStateTracker() 198 209 { 199 210 RELEASE_LOG(ViewState, "%p - ~ApplicationStateTracker", this); 200 if (m_applicationStateMonitor) {201 [m_applicationStateMonitor invalidate];202 return;203 }204 211 205 212 NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; -
trunk/Source/WebKit/UIProcess/ios/PageClientImplIOS.mm
r260134 r260642 39 39 #import "NativeWebKeyboardEvent.h" 40 40 #import "NavigationState.h" 41 #import "RunningBoardServicesSPI.h" 41 42 #import "StringUtilities.h" 42 43 #import "UIKitSPI.h" … … 169 170 ASSERT(applicationPID); 170 171 171 auto applicationStateMonitor = adoptNS([[BKSApplicationStateMonitor alloc] init]); 172 auto applicationState = [applicationStateMonitor mostElevatedApplicationStateForPID:applicationPID]; 173 [applicationStateMonitor invalidate]; 174 return applicationState != BKSApplicationStateBackgroundRunning && applicationState != BKSApplicationStateBackgroundTaskSuspended; 172 return isApplicationForeground(applicationPID); 175 173 } 176 174 -
trunk/WebKitLibraries/ChangeLog
r258520 r260642 1 2020-04-24 Chris Dumez <cdumez@apple.com> 2 3 [iOS] Stop using legacy BKSApplicationStateMonitor 4 https://bugs.webkit.org/show_bug.cgi?id=210945 5 6 Reviewed by Tim Horton. 7 8 * WebKitPrivateFrameworkStubs/iOS/13/RunningBoardServices.framework/RunningBoardServices.tbd: 9 1 10 2020-03-16 Keith Rollin <krollin@apple.com> 2 11 -
trunk/WebKitLibraries/WebKitPrivateFrameworkStubs/iOS/13/RunningBoardServices.framework/RunningBoardServices.tbd
r258180 r260642 6 6 exports: 7 7 - archs: [ x86_64, arm64, arm64e ] 8 objc-classes: [ RBSAttribute, RBSDomainAttribute, RBSTarget, RBSAssertion ]8 objc-classes: [ RBSAttribute, RBSDomainAttribute, RBSTarget, RBSAssertion, RBSProcessIdentifier, RBSProcessState, RBSProcessHandle ] 9 9 ...
Note: See TracChangeset
for help on using the changeset viewer.