Changeset 244113 in webkit


Ignore:
Timestamp:
Apr 10, 2019 9:32:30 AM (5 years ago)
Author:
beidson@apple.com
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.

Location:
trunk/Source/WebKit
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r244104 r244113  
     12019-04-10  Brady Eidson  <beidson@apple.com>
     2
     3        Background tabs are not fully reactivated after a link is opened from an external application.
     4        <rdar://problem/49533278> and https://bugs.webkit.org/show_bug.cgi?id=196705
     5
     6        Reviewed by Chris Dumez.
     7
     8        If an app unparents a WKWebView right after activation but before the "applicationWillEnterForeground" notification
     9        is dispatched, then that WKWebView is in a broken state with a frozen layer tree.
     10
     11        The WKApplicationStateTrackingView logic needs to be a little more resilient.
     12
     13        * UIProcess/ios/WKApplicationStateTrackingView.mm:
     14        (-[WKApplicationStateTrackingView willMoveToWindow:]): When clearing the window, remember the current background state.
     15        (-[WKApplicationStateTrackingView didMoveToWindow]): If our last observed background state doesn't match the current
     16          background state then fake the relevant notification.
     17        (-[WKApplicationStateTrackingView _applicationDidEnterBackground]): Remember that we've observed a backgrounding.
     18        (-[WKApplicationStateTrackingView _applicationWillEnterForeground]): Remember that we've observed a foregrounding.
     19
    1202019-04-10  Diego Pino Garcia  <dpino@igalia.com>
    221
  • trunk/Source/WebKit/UIProcess/ios/WKApplicationStateTrackingView.mm

    r237266 r244113  
    3838    WeakObjCPtr<WKWebView> _webViewToTrack;
    3939    std::unique_ptr<WebKit::ApplicationStateTracker> _applicationStateTracker;
     40    BOOL _lastObservedStateWasBackground;
    4041}
    4142
     
    5455        return;
    5556
     57    _lastObservedStateWasBackground = [self isBackground];
     58
    5659    ASSERT(_applicationStateTracker);
    5760    _applicationStateTracker = nullptr;
     
    6568    ASSERT(!_applicationStateTracker);
    6669    _applicationStateTracker = std::make_unique<WebKit::ApplicationStateTracker>(self, @selector(_applicationDidEnterBackground), @selector(_applicationDidFinishSnapshottingAfterEnteringBackground), @selector(_applicationWillEnterForeground));
     70   
     71    if (_lastObservedStateWasBackground && ![self isBackground])
     72        [self _applicationWillEnterForeground];
     73    else if (!_lastObservedStateWasBackground && [self isBackground])
     74        [self _applicationDidEnterBackground];
    6775}
    6876
     
    7381        return;
    7482
     83    _lastObservedStateWasBackground = YES;
    7584    page->applicationDidEnterBackground();
    7685    page->activityStateDidChange(WebCore::ActivityState::allFlags() - WebCore::ActivityState::IsInWindow);
     
    8998        return;
    9099
     100    _lastObservedStateWasBackground = NO;
    91101    page->applicationWillEnterForeground();
    92102    page->activityStateDidChange(WebCore::ActivityState::allFlags() - WebCore::ActivityState::IsInWindow, true, WebKit::WebPageProxy::ActivityStateChangeDispatchMode::Immediate);
Note: See TracChangeset for help on using the changeset viewer.