Web Content process gets stuck suspended after navigating away from a system preview
authortimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 19 Jul 2019 23:10:00 +0000 (23:10 +0000)
committertimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 19 Jul 2019 23:10:00 +0000 (23:10 +0000)
https://bugs.webkit.org/show_bug.cgi?id=199965
<rdar://problem/53109004>

Reviewed by Dean Jackson.

* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _isBackground]):
* UIProcess/ios/WKSystemPreviewView.h:
* UIProcess/ios/WKSystemPreviewView.mm:
(-[WKSystemPreviewView web_initWithFrame:webView:mimeType:]):
(-[WKSystemPreviewView web_isBackground]):
Apply the fix from r193481 to WKSystemPreviewView as well, having it
become a WKApplicationStateTrackingView and plumbing that through
to our is-background machinery.

We really, really should instead have WKWebView itself be the application
state tracking view, but that is a bigger change (and has some implications
for full-screen video and whatnot).

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

Source/WebKit/ChangeLog
Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm
Source/WebKit/UIProcess/ios/WKSystemPreviewView.h
Source/WebKit/UIProcess/ios/WKSystemPreviewView.mm

index 2e483b0..ca865e3 100644 (file)
@@ -1,3 +1,25 @@
+2019-07-19  Tim Horton  <timothy_horton@apple.com>
+
+        Web Content process gets stuck suspended after navigating away from a system preview
+        https://bugs.webkit.org/show_bug.cgi?id=199965
+        <rdar://problem/53109004>
+
+        Reviewed by Dean Jackson.
+
+        * UIProcess/API/Cocoa/WKWebView.mm:
+        (-[WKWebView _isBackground]):
+        * UIProcess/ios/WKSystemPreviewView.h:
+        * UIProcess/ios/WKSystemPreviewView.mm:
+        (-[WKSystemPreviewView web_initWithFrame:webView:mimeType:]):
+        (-[WKSystemPreviewView web_isBackground]):
+        Apply the fix from r193481 to WKSystemPreviewView as well, having it
+        become a WKApplicationStateTrackingView and plumbing that through
+        to our is-background machinery.
+
+        We really, really should instead have WKWebView itself be the application
+        state tracking view, but that is a bigger change (and has some implications
+        for full-screen video and whatnot).
+
 2019-07-19  Dean Jackson  <dino@apple.com>
 
         Provide correct names for UIContextMenuInteraction API replacements
index df278ae..3cc86a9 100644 (file)
@@ -1466,7 +1466,7 @@ static _WKSelectionAttributes selectionAttributes(const WebKit::EditorState& edi
 
 - (BOOL)_isBackground
 {
-    if ([self _isDisplayingPDF])
+    if (![self usesStandardContentView] && [_customContentView respondsToSelector:@selector(web_isBackground)])
         return [_customContentView web_isBackground];
     return [_contentView isBackground];
 }
index 6902528..3344f18 100644 (file)
 
 #if USE(SYSTEM_PREVIEW)
 
+#import "WKApplicationStateTrackingView.h"
 #import "WKWebViewContentProvider.h"
 #import <QuickLook/QuickLook.h>
 #import <UIKit/UIKit.h>
 #import <pal/spi/ios/QuickLookSPI.h>
 
-@interface WKSystemPreviewView : UIView <WKWebViewContentProvider, QLPreviewItemDataProvider>
+@interface WKSystemPreviewView : WKApplicationStateTrackingView <WKWebViewContentProvider, QLPreviewItemDataProvider>
 
 @end
 
index 14f04b9..f9aad83 100644 (file)
@@ -69,7 +69,7 @@ static NSString *getUTIForSystemPreviewMIMEType(const String& mimeType)
 
 - (instancetype)web_initWithFrame:(CGRect)frame webView:(WKWebView *)webView mimeType:(NSString *)mimeType
 {
-    if (!(self = [super initWithFrame:frame]))
+    if (!(self = [super initWithFrame:frame webView:webView]))
         return nil;
 
     UIColor *backgroundColor = [UIColor colorWithRed:(38. / 255) green:(38. / 255) blue:(38. / 255) alpha:1];
@@ -170,6 +170,11 @@ static NSString *getUTIForSystemPreviewMIMEType(const String& mimeType)
 {
 }
 
+- (BOOL)web_isBackground
+{
+    return self.isBackground;
+}
+
 #pragma mark Find-in-Page
 
 - (void)web_countStringMatches:(NSString *)string options:(_WKFindOptions)options maxCount:(NSUInteger)maxCount