Changeset 250187 in webkit


Ignore:
Timestamp:
Sep 21, 2019, 4:13:47 PM (6 years ago)
Author:
Chris Dumez
Message:

Regression(iOS 13) web views do not deal properly with their window's UIScene changing
https://bugs.webkit.org/show_bug.cgi?id=202070
<rdar://problem/55580699>

Reviewed by Tim Horton.

Web views do not deal properly with their window's UIScene changing. If a Safari window is in the
background for 1 minute, its UIScene will be detached and the window will get a new UIScene if
the user later switches to this window. Our web views listen to UIScene notifications to determine
their visibility and currently stop receiving visibility updates once the window’s UIScene has
changed. This causes view freezes because our WebContent process does not know its view is visible
and keeps its layer tree frozen.

Previously, when our view would be added to a window, we would get this window's UIScene and listen
for UISceneDidEnterBackgroundNotification / UISceneWillEnterForegroundNotification for this UIScene
object. Instead, we now listen to these notifications for ALL the application's UIScenes. Our handler
then checks if the notification's UIScene object matches the current window's UIScene before
forwarding the notification to the rest of WebKit.

  • UIProcess/ApplicationStateTracker.mm:

(WebKit::ApplicationStateTracker::ApplicationStateTracker):
(WebKit::ApplicationStateTracker::~ApplicationStateTracker):

Location:
trunk/Source/WebKit
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r250186 r250187  
     12019-09-21  Chris Dumez  <cdumez@apple.com>
     2
     3        Regression(iOS 13) web views do not deal properly with their window's UIScene changing
     4        https://bugs.webkit.org/show_bug.cgi?id=202070
     5        <rdar://problem/55580699>
     6
     7        Reviewed by Tim Horton.
     8
     9        Web views do not deal properly with their window's UIScene changing. If a Safari window is in the
     10        background for 1 minute, its UIScene will be detached and the window will get a new UIScene if
     11        the user later switches to this window. Our web views listen to UIScene notifications to determine
     12        their visibility and currently stop receiving visibility updates once the window’s UIScene has
     13        changed. This causes view freezes because our WebContent process does not know its view is visible
     14        and keeps its layer tree frozen.
     15
     16        Previously, when our view would be added to a window, we would get this window's UIScene and listen
     17        for UISceneDidEnterBackgroundNotification / UISceneWillEnterForegroundNotification for this UIScene
     18        object. Instead, we now listen to these notifications for ALL the application's UIScenes. Our handler
     19        then checks if the notification's UIScene object matches the current window's UIScene before
     20        forwarding the notification to the rest of WebKit.
     21
     22        * UIProcess/ApplicationStateTracker.mm:
     23        (WebKit::ApplicationStateTracker::ApplicationStateTracker):
     24        (WebKit::ApplicationStateTracker::~ApplicationStateTracker):
     25
    1262019-09-21  Dan Bernstein  <mitz@apple.com>
    227
  • trunk/Source/WebKit/UIProcess/ApplicationStateTracker.mm

    r250154 r250187  
    109109        RELEASE_LOG(ViewState, "%p - ApplicationStateTracker::ApplicationStateTracker(): m_isInBackground: %d", this, m_isInBackground);
    110110
    111         m_didEnterBackgroundObserver = [notificationCenter addObserverForName:UISceneDidEnterBackgroundNotification object:window.windowScene queue:nil usingBlock:[this](NSNotification *) {
    112             RELEASE_LOG(ViewState, "%p - ApplicationStateTracker: UISceneDidEnterBackground", this);
    113             applicationDidEnterBackground();
    114         }];
    115 
    116         m_willEnterForegroundObserver = [notificationCenter addObserverForName:UISceneWillEnterForegroundNotification object:window.windowScene queue:nil usingBlock:[this](NSNotification *) {
    117             RELEASE_LOG(ViewState, "%p - ApplicationStateTracker: UISceneWillEnterForeground", this);
    118             applicationWillEnterForeground();
     111        m_didEnterBackgroundObserver = [notificationCenter addObserverForName:UISceneDidEnterBackgroundNotification object:nil queue:nil usingBlock:[this](NSNotification *notification) {
     112            if (notification.object == [[m_view window] windowScene]) {
     113                RELEASE_LOG(ViewState, "%p - ApplicationStateTracker: UISceneDidEnterBackground", this);
     114                applicationDidEnterBackground();
     115            }
     116        }];
     117
     118        m_willEnterForegroundObserver = [notificationCenter addObserverForName:UISceneWillEnterForegroundNotification object:nil queue:nil usingBlock:[this](NSNotification *notification) {
     119            if (notification.object == [[m_view window] windowScene]) {
     120                RELEASE_LOG(ViewState, "%p - ApplicationStateTracker: UISceneWillEnterForeground", this);
     121                applicationWillEnterForeground();
     122            }
    119123        }];
    120124#else
     
    181185ApplicationStateTracker::~ApplicationStateTracker()
    182186{
     187    RELEASE_LOG(ViewState, "%p - ~ApplicationStateTracker", this);
    183188    if (m_applicationStateMonitor) {
    184189        [m_applicationStateMonitor invalidate];
Note: See TracChangeset for help on using the changeset viewer.