[iOS] ViewServices started by StoreKitUIService may get suspended unexpectedly
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 24 Aug 2017 15:59:24 +0000 (15:59 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 24 Aug 2017 15:59:24 +0000 (15:59 +0000)
https://bugs.webkit.org/show_bug.cgi?id=175922
<rdar://problem/34028921>

Reviewed by Tim Horton.

ViewServices started by StoreKitUIService may get suspended unexpectedly. This is
because StoreKitUIService is itself a ViewService and is therefore in the background.
To address the issue, treat StoreKitUIService as initially foreground in
ApplicationStateTracker so that its ViewServices do not get suspended. We don't
have good way to deal with ViewServices started by other ViewServices unfortunately.

* Platform/spi/ios/UIKitSPI.h:
* UIProcess/ApplicationStateTracker.mm:
(WebKit::ApplicationStateTracker::ApplicationStateTracker):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@221138 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebKit/ChangeLog
Source/WebKit/Platform/spi/ios/UIKitSPI.h
Source/WebKit/UIProcess/ApplicationStateTracker.mm

index 47b6a17..e232300 100644 (file)
@@ -1,3 +1,21 @@
+2017-08-24  Chris Dumez  <cdumez@apple.com>
+
+        [iOS] ViewServices started by StoreKitUIService may get suspended unexpectedly
+        https://bugs.webkit.org/show_bug.cgi?id=175922
+        <rdar://problem/34028921>
+
+        Reviewed by Tim Horton.
+
+        ViewServices started by StoreKitUIService may get suspended unexpectedly. This is
+        because StoreKitUIService is itself a ViewService and is therefore in the background.
+        To address the issue, treat StoreKitUIService as initially foreground in
+        ApplicationStateTracker so that its ViewServices do not get suspended. We don't
+        have good way to deal with ViewServices started by other ViewServices unfortunately.
+
+        * Platform/spi/ios/UIKitSPI.h:
+        * UIProcess/ApplicationStateTracker.mm:
+        (WebKit::ApplicationStateTracker::ApplicationStateTracker):
+
 2017-08-23  Youenn Fablet  <youenn@apple.com>
 
         [Cache API] Unify WebCore and WebKit error handling
index 921217b..24dfce2 100644 (file)
@@ -397,6 +397,7 @@ typedef enum {
 
 @interface UIViewController (ViewService)
 - (pid_t)_hostProcessIdentifier;
+@property (readonly) NSString *_hostApplicationBundleIdentifier;
 @end
 
 @protocol UIViewControllerContextTransitioningEx <UIViewControllerContextTransitioning>
index 286697d..6b2939a 100644 (file)
@@ -146,6 +146,12 @@ ApplicationStateTracker::ApplicationStateTracker(UIView *view, SEL didEnterBackg
         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
+        // or its ViewServices will get suspended.
+        if ([serviceViewController._hostApplicationBundleIdentifier isEqualToString:@"com.apple.ios.StoreKitUIService"])
+            m_isInBackground = false;
+
         m_didEnterBackgroundObserver = [notificationCenter addObserverForName:@"_UIViewServiceHostDidEnterBackgroundNotification" object:serviceViewController queue:nil usingBlock:[this](NSNotification *) {
             applicationDidEnterBackground();
         }];