Title: [244113] trunk/Source/WebKit
- Revision
- 244113
- Author
- beid...@apple.com
- Date
- 2019-04-10 09:32:30 -0700 (Wed, 10 Apr 2019)
Log Message
Background tabs are not fully reactivated after a link is opened from an external application.
<rdar://problem/49533278> and https://bugs.webkit.org/show_bug.cgi?id=196705
Reviewed by Chris Dumez.
If an app unparents a WKWebView right after activation but before the "applicationWillEnterForeground" notification
is dispatched, then that WKWebView is in a broken state with a frozen layer tree.
The WKApplicationStateTrackingView logic needs to be a little more resilient.
* UIProcess/ios/WKApplicationStateTrackingView.mm:
(-[WKApplicationStateTrackingView willMoveToWindow:]): When clearing the window, remember the current background state.
(-[WKApplicationStateTrackingView didMoveToWindow]): If our last observed background state doesn't match the current
background state then fake the relevant notification.
(-[WKApplicationStateTrackingView _applicationDidEnterBackground]): Remember that we've observed a backgrounding.
(-[WKApplicationStateTrackingView _applicationWillEnterForeground]): Remember that we've observed a foregrounding.
Modified Paths
Diff
Modified: trunk/Source/WebKit/ChangeLog (244112 => 244113)
--- trunk/Source/WebKit/ChangeLog 2019-04-10 16:30:58 UTC (rev 244112)
+++ trunk/Source/WebKit/ChangeLog 2019-04-10 16:32:30 UTC (rev 244113)
@@ -1,3 +1,22 @@
+2019-04-10 Brady Eidson <beid...@apple.com>
+
+ Background tabs are not fully reactivated after a link is opened from an external application.
+ <rdar://problem/49533278> and https://bugs.webkit.org/show_bug.cgi?id=196705
+
+ Reviewed by Chris Dumez.
+
+ If an app unparents a WKWebView right after activation but before the "applicationWillEnterForeground" notification
+ is dispatched, then that WKWebView is in a broken state with a frozen layer tree.
+
+ The WKApplicationStateTrackingView logic needs to be a little more resilient.
+
+ * UIProcess/ios/WKApplicationStateTrackingView.mm:
+ (-[WKApplicationStateTrackingView willMoveToWindow:]): When clearing the window, remember the current background state.
+ (-[WKApplicationStateTrackingView didMoveToWindow]): If our last observed background state doesn't match the current
+ background state then fake the relevant notification.
+ (-[WKApplicationStateTrackingView _applicationDidEnterBackground]): Remember that we've observed a backgrounding.
+ (-[WKApplicationStateTrackingView _applicationWillEnterForeground]): Remember that we've observed a foregrounding.
+
2019-04-10 Diego Pino Garcia <dp...@igalia.com>
Unreviewed, build fix for r244097
Modified: trunk/Source/WebKit/UIProcess/ios/WKApplicationStateTrackingView.mm (244112 => 244113)
--- trunk/Source/WebKit/UIProcess/ios/WKApplicationStateTrackingView.mm 2019-04-10 16:30:58 UTC (rev 244112)
+++ trunk/Source/WebKit/UIProcess/ios/WKApplicationStateTrackingView.mm 2019-04-10 16:32:30 UTC (rev 244113)
@@ -37,6 +37,7 @@
@implementation WKApplicationStateTrackingView {
WeakObjCPtr<WKWebView> _webViewToTrack;
std::unique_ptr<WebKit::ApplicationStateTracker> _applicationStateTracker;
+ BOOL _lastObservedStateWasBackground;
}
- (instancetype)initWithFrame:(CGRect)frame webView:(WKWebView *)webView
@@ -53,6 +54,8 @@
if (!self._contentView.window || newWindow)
return;
+ _lastObservedStateWasBackground = [self isBackground];
+
ASSERT(_applicationStateTracker);
_applicationStateTracker = nullptr;
}
@@ -64,6 +67,11 @@
ASSERT(!_applicationStateTracker);
_applicationStateTracker = std::make_unique<WebKit::ApplicationStateTracker>(self, @selector(_applicationDidEnterBackground), @selector(_applicationDidFinishSnapshottingAfterEnteringBackground), @selector(_applicationWillEnterForeground));
+
+ if (_lastObservedStateWasBackground && ![self isBackground])
+ [self _applicationWillEnterForeground];
+ else if (!_lastObservedStateWasBackground && [self isBackground])
+ [self _applicationDidEnterBackground];
}
- (void)_applicationDidEnterBackground
@@ -72,6 +80,7 @@
if (!page)
return;
+ _lastObservedStateWasBackground = YES;
page->applicationDidEnterBackground();
page->activityStateDidChange(WebCore::ActivityState::allFlags() - WebCore::ActivityState::IsInWindow);
}
@@ -88,6 +97,7 @@
if (!page)
return;
+ _lastObservedStateWasBackground = NO;
page->applicationWillEnterForeground();
page->activityStateDidChange(WebCore::ActivityState::allFlags() - WebCore::ActivityState::IsInWindow, true, WebKit::WebPageProxy::ActivityStateChangeDispatchMode::Immediate);
}
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes