Changeset 190593 in webkit


Ignore:
Timestamp:
Oct 5, 2015 4:45:56 PM (9 years ago)
Author:
mmaxfield@apple.com
Message:

REGRESSION(189668?): http/tests/notifications/events.html flakily asserts or times out
https://bugs.webkit.org/show_bug.cgi?id=149218

Reviewed by Alexey Proskuryakov.

Tools:

Because of r189668, WebKitTestRunner now tears down and recreates its WKNotificationManagerRef
when the TestOptions change. Previously, WebNotificationProvider only could handle a single
WKNotificationManagerRef. Because the ower of the WKNotificationManagerRef is reference counted,
and AppKit internally retains some objects which end up retaining the WKNotificationManagerRef,
the old WKNotificationManager may not be destroyed before the new one is created. Therefore,
WebNotificationProvider must be updated to appropriately handle multiple
WKNotificationManagerRefs in flight at the same time.

  • WebKitTestRunner/WebNotificationProvider.cpp:

(WTR::WebNotificationProvider::~WebNotificationProvider):
(WTR::WebNotificationProvider::showWebNotification):
(WTR::WebNotificationProvider::closeWebNotification):
(WTR::WebNotificationProvider::addNotificationManager):
(WTR::WebNotificationProvider::removeNotificationManager):
(WTR::WebNotificationProvider::simulateWebNotificationClick):
(WTR::WebNotificationProvider::reset):

  • WebKitTestRunner/WebNotificationProvider.h:

LayoutTests:

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r190592 r190593  
     12015-10-05  Myles C. Maxfield  <mmaxfield@apple.com>
     2
     3        REGRESSION(189668?): http/tests/notifications/events.html flakily asserts or times out
     4        https://bugs.webkit.org/show_bug.cgi?id=149218
     5
     6        Reviewed by Alexey Proskuryakov.
     7
     8        * TestExpectations:
     9
    1102015-10-05  Dean Jackson  <dino@apple.com>
    211
  • trunk/LayoutTests/TestExpectations

    r190518 r190593  
    677677
    678678http/tests/xmlhttprequest/timeout/xmlhttprequest-timeout-overrides.html [ Failure Pass ]
    679 
    680 webkit.org/b/149218 http/tests/notifications/events.html [ Pass Crash Timeout ]
  • trunk/Tools/ChangeLog

    r190584 r190593  
     12015-10-05  Myles C. Maxfield  <mmaxfield@apple.com>
     2
     3        REGRESSION(189668?): http/tests/notifications/events.html flakily asserts or times out
     4        https://bugs.webkit.org/show_bug.cgi?id=149218
     5
     6        Reviewed by Alexey Proskuryakov.
     7
     8        Because of r189668, WebKitTestRunner now tears down and recreates its WKNotificationManagerRef
     9        when the TestOptions change. Previously, WebNotificationProvider only could handle a single
     10        WKNotificationManagerRef. Because the ower of the WKNotificationManagerRef is reference counted,
     11        and AppKit internally retains some objects which end up retaining the WKNotificationManagerRef,
     12        the old WKNotificationManager may not be destroyed before the new one is created. Therefore,
     13        WebNotificationProvider must be updated to appropriately handle multiple
     14        WKNotificationManagerRefs in flight at the same time.
     15
     16        * WebKitTestRunner/WebNotificationProvider.cpp:
     17        (WTR::WebNotificationProvider::~WebNotificationProvider):
     18        (WTR::WebNotificationProvider::showWebNotification):
     19        (WTR::WebNotificationProvider::closeWebNotification):
     20        (WTR::WebNotificationProvider::addNotificationManager):
     21        (WTR::WebNotificationProvider::removeNotificationManager):
     22        (WTR::WebNotificationProvider::simulateWebNotificationClick):
     23        (WTR::WebNotificationProvider::reset):
     24        * WebKitTestRunner/WebNotificationProvider.h:
     25
    1262015-10-05  Daniel Bates  <dabates@apple.com>
    227
  • trunk/Tools/WebKitTestRunner/WebNotificationProvider.cpp

    r189668 r190593  
    6666WebNotificationProvider::~WebNotificationProvider()
    6767{
    68     if (m_currentNotificationManager)
    69         WKNotificationManagerSetProvider(m_currentNotificationManager.get(), nullptr);
     68    for (auto& manager : m_ownedNotifications)
     69        WKNotificationManagerSetProvider(manager.key.get(), nullptr);
    7070}
    7171
     
    8585}
    8686
    87 void WebNotificationProvider::showWebNotification(WKPageRef, WKNotificationRef notification)
     87void WebNotificationProvider::showWebNotification(WKPageRef page, WKNotificationRef notification)
    8888{
    89     if (!m_currentNotificationManager)
    90         return;
     89    auto context = WKPageGetContext(page);
     90    auto notificationManager = WKContextGetNotificationManager(context);
     91    uint64_t id = WKNotificationGetID(notification);
    9192
    92     uint64_t id = WKNotificationGetID(notification);
    93     ASSERT(!m_shownNotifications.contains(id));
    94     m_shownNotifications.add(id);
     93    ASSERT(m_ownedNotifications.contains(notificationManager));
     94    auto addResult = m_ownedNotifications.find(notificationManager)->value.add(id);
     95    ASSERT_UNUSED(addResult, addResult.isNewEntry);
     96    auto addResult2 = m_owningManager.set(id, notificationManager);
     97    ASSERT_UNUSED(addResult2, addResult2.isNewEntry);
    9598
    96     WKNotificationManagerProviderDidShowNotification(m_currentNotificationManager.get(), WKNotificationGetID(notification));
     99    WKNotificationManagerProviderDidShowNotification(notificationManager, id);
    97100}
    98101
    99102void WebNotificationProvider::closeWebNotification(WKNotificationRef notification)
    100103{
    101     if (!m_currentNotificationManager)
    102         return;
     104    uint64_t id = WKNotificationGetID(notification);
     105    ASSERT(m_owningManager.contains(id));
     106    auto notificationManager = m_owningManager.get(id);
    103107
    104     uint64_t id = WKNotificationGetID(notification);
     108    ASSERT(m_ownedNotifications.contains(notificationManager));
     109    bool success = m_ownedNotifications.find(notificationManager)->value.remove(id);
     110    ASSERT_UNUSED(success, success);
     111    m_owningManager.remove(id);
     112
    105113    WKRetainPtr<WKUInt64Ref> wkID = WKUInt64Create(id);
    106114    WKRetainPtr<WKMutableArrayRef> array(AdoptWK, WKMutableArrayCreate());
    107115    WKArrayAppendItem(array.get(), wkID.get());
    108     m_shownNotifications.remove(id);
    109     WKNotificationManagerProviderDidCloseNotifications(m_currentNotificationManager.get(), array.get());
     116    WKNotificationManagerProviderDidCloseNotifications(notificationManager, array.get());
    110117}
    111118
    112119void WebNotificationProvider::addNotificationManager(WKNotificationManagerRef manager)
    113120{
    114     m_currentNotificationManager = manager;
     121    m_ownedNotifications.add(manager, HashSet<uint64_t>());
    115122}
    116123
    117124void WebNotificationProvider::removeNotificationManager(WKNotificationManagerRef manager)
    118125{
     126    auto iterator = m_ownedNotifications.find(manager);
     127    ASSERT(iterator != m_ownedNotifications.end());
     128    auto toRemove = iterator->value;
     129    WKRetainPtr<WKNotificationManagerRef> guard(manager);
     130    m_ownedNotifications.remove(iterator);
     131    WKRetainPtr<WKMutableArrayRef> array = adoptWK(WKMutableArrayCreate());
     132    for (uint64_t notificationID : toRemove) {
     133        bool success = m_owningManager.remove(notificationID);
     134        ASSERT_UNUSED(success, success);
     135        WKArrayAppendItem(array.get(), adoptWK(WKUInt64Create(notificationID)).get());
     136    }
     137    WKNotificationManagerProviderDidCloseNotifications(manager, array.get());
    119138}
    120139
     
    127146void WebNotificationProvider::simulateWebNotificationClick(uint64_t notificationID)
    128147{
    129     if (!m_currentNotificationManager)
    130         return;
    131 
    132     ASSERT(m_shownNotifications.contains(notificationID));
    133     WKNotificationManagerProviderDidClickNotification(m_currentNotificationManager.get(), notificationID);
     148    ASSERT(m_owningManager.contains(notificationID));
     149    WKNotificationManagerProviderDidClickNotification(m_owningManager.get(notificationID), notificationID);
    134150}
    135151
    136152void WebNotificationProvider::reset()
    137153{
    138     if (!m_currentNotificationManager) {
    139         m_shownNotifications.clear();
    140         return;
     154    for (auto& notificationPair : m_ownedNotifications) {
     155        if (notificationPair.value.isEmpty())
     156            continue;
     157        WKRetainPtr<WKMutableArrayRef> array = adoptWK(WKMutableArrayCreate());
     158        for (uint64_t notificationID : notificationPair.value)
     159            WKArrayAppendItem(array.get(), adoptWK(WKUInt64Create(notificationID)).get());
     160
     161        notificationPair.value.clear();
     162        WKNotificationManagerProviderDidCloseNotifications(notificationPair.key.get(), array.get());
    141163    }
    142 
    143     WKRetainPtr<WKMutableArrayRef> array(AdoptWK, WKMutableArrayCreate());
    144     HashSet<uint64_t>::const_iterator itEnd = m_shownNotifications.end();
    145     for (HashSet<uint64_t>::const_iterator it = m_shownNotifications.begin(); it != itEnd; ++it) {
    146         WKRetainPtr<WKUInt64Ref> wkID = WKUInt64Create(*it);
    147         WKArrayAppendItem(array.get(), wkID.get());
    148     }
    149 
    150     m_shownNotifications.clear();
    151     WKNotificationManagerProviderDidCloseNotifications(m_currentNotificationManager.get(), array.get());
     164    m_owningManager.clear();
    152165}
    153166
  • trunk/Tools/WebKitTestRunner/WebNotificationProvider.h

    r189668 r190593  
    3030#include <WebKit/WKNotificationProvider.h>
    3131#include <WebKit/WKRetainPtr.h>
     32#include <wtf/HashMap.h>
    3233#include <wtf/HashSet.h>
    3334
     
    5051
    5152private:
    52     WKRetainPtr<WKNotificationManagerRef> m_currentNotificationManager;
    53     HashSet<uint64_t> m_shownNotifications;
     53    // Inverses of each other.
     54    HashMap<WKRetainPtr<WKNotificationManagerRef>, HashSet<uint64_t>> m_ownedNotifications;
     55    HashMap<uint64_t, WKNotificationManagerRef> m_owningManager;
    5456};
    5557
Note: See TracChangeset for help on using the changeset viewer.