Title: [259146] trunk/Source/WebKit
- Revision
- 259146
- Author
- [email protected]
- Date
- 2020-03-27 16:44:46 -0700 (Fri, 27 Mar 2020)
Log Message
[iOS] Delay process suspension for a while after loading an app link
https://bugs.webkit.org/show_bug.cgi?id=209686
<rdar://problem/60888891>
Reviewed by Darin Adler.
Delay process suspension for a while after loading an app link. This will allow the page's script to pass
information more reliably to the native app handling the navigation.
This patch adds a [WKWebView _willOpenAppLink] SPI that the client needs to call before opening the
app link.
* UIProcess/API/Cocoa/WKWebViewPrivate.h:
* UIProcess/API/ios/WKWebViewIOS.mm:
(-[WKWebView _willOpenAppLink]):
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::close):
* UIProcess/WebPageProxy.h:
* UIProcess/ios/WebPageProxyIOS.mm:
(WebKit::WebPageProxy::willOpenAppLink):
Modified Paths
Diff
Modified: trunk/Source/WebKit/ChangeLog (259145 => 259146)
--- trunk/Source/WebKit/ChangeLog 2020-03-27 23:25:33 UTC (rev 259145)
+++ trunk/Source/WebKit/ChangeLog 2020-03-27 23:44:46 UTC (rev 259146)
@@ -1,3 +1,26 @@
+2020-03-27 Chris Dumez <[email protected]>
+
+ [iOS] Delay process suspension for a while after loading an app link
+ https://bugs.webkit.org/show_bug.cgi?id=209686
+ <rdar://problem/60888891>
+
+ Reviewed by Darin Adler.
+
+ Delay process suspension for a while after loading an app link. This will allow the page's script to pass
+ information more reliably to the native app handling the navigation.
+
+ This patch adds a [WKWebView _willOpenAppLink] SPI that the client needs to call before opening the
+ app link.
+
+ * UIProcess/API/Cocoa/WKWebViewPrivate.h:
+ * UIProcess/API/ios/WKWebViewIOS.mm:
+ (-[WKWebView _willOpenAppLink]):
+ * UIProcess/WebPageProxy.cpp:
+ (WebKit::WebPageProxy::close):
+ * UIProcess/WebPageProxy.h:
+ * UIProcess/ios/WebPageProxyIOS.mm:
+ (WebKit::WebPageProxy::willOpenAppLink):
+
2020-03-27 David Kilzer <[email protected]>
NetworkConnectionToWebProcess::registerBlobURLOptionallyFileBacked should validate its parameters
Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h (259145 => 259146)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h 2020-03-27 23:25:33 UTC (rev 259145)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h 2020-03-27 23:44:46 UTC (rev 259146)
@@ -448,6 +448,8 @@
- (void)_grantAccessToAssetServices WK_API_AVAILABLE(ios(WK_IOS_TBA));
- (void)_revokeAccessToAssetServices WK_API_AVAILABLE(ios(WK_IOS_TBA));
+- (void)_willOpenAppLink WK_API_AVAILABLE(ios(WK_IOS_TBA));
+
@end
@interface WKWebView () <UIResponderStandardEditActions>
Modified: trunk/Source/WebKit/UIProcess/API/ios/WKWebViewIOS.mm (259145 => 259146)
--- trunk/Source/WebKit/UIProcess/API/ios/WKWebViewIOS.mm 2020-03-27 23:25:33 UTC (rev 259145)
+++ trunk/Source/WebKit/UIProcess/API/ios/WKWebViewIOS.mm 2020-03-27 23:44:46 UTC (rev 259146)
@@ -3100,6 +3100,12 @@
#endif
}
+- (void)_willOpenAppLink
+{
+ if (_page)
+ _page->willOpenAppLink();
+}
+
@end // WKWebView (WKPrivateIOS)
#if ENABLE(FULLSCREEN_API)
Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.cpp (259145 => 259146)
--- trunk/Source/WebKit/UIProcess/WebPageProxy.cpp 2020-03-27 23:25:33 UTC (rev 259145)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.cpp 2020-03-27 23:44:46 UTC (rev 259146)
@@ -1138,6 +1138,7 @@
m_isVisibleActivity = nullptr;
m_isAudibleActivity = nullptr;
m_isCapturingActivity = nullptr;
+ m_openingAppLinkActivity = nullptr;
m_alwaysRunsAtForegroundPriorityActivity = nullptr;
m_audibleActivityTimer.stop();
#endif
@@ -7571,6 +7572,7 @@
m_isVisibleActivity = nullptr;
m_isAudibleActivity = nullptr;
m_isCapturingActivity = nullptr;
+ m_openingAppLinkActivity = nullptr;
m_alwaysRunsAtForegroundPriorityActivity = nullptr;
#endif
Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.h (259145 => 259146)
--- trunk/Source/WebKit/UIProcess/WebPageProxy.h 2020-03-27 23:25:33 UTC (rev 259145)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.h 2020-03-27 23:44:46 UTC (rev 259146)
@@ -523,6 +523,8 @@
#if PLATFORM(IOS_FAMILY)
bool allowsMediaDocumentInlinePlayback() const;
void setAllowsMediaDocumentInlinePlayback(bool);
+
+ void willOpenAppLink();
#endif
#if USE(SYSTEM_PREVIEW)
@@ -2400,6 +2402,7 @@
std::unique_ptr<ProcessThrottler::ForegroundActivity> m_isCapturingActivity;
std::unique_ptr<ProcessThrottler::ForegroundActivity> m_alwaysRunsAtForegroundPriorityActivity;
RunLoop::Timer<WebPageProxy> m_audibleActivityTimer;
+ std::unique_ptr<ProcessThrottler::BackgroundActivity> m_openingAppLinkActivity;
#endif
bool m_initialCapitalizationEnabled { false };
Optional<double> m_cpuLimit;
Modified: trunk/Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm (259145 => 259146)
--- trunk/Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm 2020-03-27 23:25:33 UTC (rev 259145)
+++ trunk/Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm 2020-03-27 23:44:46 UTC (rev 259146)
@@ -1539,7 +1539,22 @@
send(Messages::WebPage::SetShouldRevealCurrentSelectionAfterInsertion(shouldRevealCurrentSelectionAfterInsertion));
}
+void WebPageProxy::willOpenAppLink()
+{
+ if (m_openingAppLinkActivity && m_openingAppLinkActivity->isValid())
+ return;
+ // We take a background activity for 25 seconds when switching to another app via an app link in case the WebPage
+ // needs to run script to pass information to the native app.
+ // We chose 25 seconds because the system only gives us 30 seconds and we don't want to get too close to that limit
+ // to avoid assertion invalidation (or even termination).
+ m_openingAppLinkActivity = process().throttler().backgroundActivity("Opening AppLink"_s).moveToUniquePtr();
+ dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 25 * NSEC_PER_SEC), dispatch_get_main_queue(), [weakThis = makeWeakPtr(*this)] {
+ if (weakThis)
+ weakThis->m_openingAppLinkActivity = nullptr;
+ });
+}
+
#if PLATFORM(IOS)
void WebPageProxy::grantAccessToAssetServices()
{
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes