Changeset 268421 in webkit


Ignore:
Timestamp:
Oct 13, 2020 2:38:21 PM (3 years ago)
Author:
pvollan@apple.com
Message:

[iOS 14] Hang in -[WKUserDefaults _notifyObserversOfChangeFromValuesForKeys:toValuesForKeys:]
https://bugs.webkit.org/show_bug.cgi?id=217183
<rdar://problem/69916673>

Reviewed by Geoffrey Garen.

Dispatch this work on a non-main thread, in order to avoid blocking the main thread.

  • UIProcess/Cocoa/PreferenceObserver.mm:

(-[WKUserDefaults _notifyObserversOfChangeFromValuesForKeys:toValuesForKeys:]):

Location:
trunk/Source/WebKit
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r268420 r268421  
     12020-10-13  Per Arne Vollan  <pvollan@apple.com>
     2
     3        [iOS 14] Hang in -[WKUserDefaults _notifyObserversOfChangeFromValuesForKeys:toValuesForKeys:]
     4        https://bugs.webkit.org/show_bug.cgi?id=217183
     5        <rdar://problem/69916673>
     6
     7        Reviewed by Geoffrey Garen.
     8
     9        Dispatch this work on a non-main thread, in order to avoid blocking the main thread.
     10
     11        * UIProcess/Cocoa/PreferenceObserver.mm:
     12        (-[WKUserDefaults _notifyObserversOfChangeFromValuesForKeys:toValuesForKeys:]):
     13
    1142020-10-13  Keith Rollin  <krollin@apple.com>
    215
  • trunk/Source/WebKit/UIProcess/Cocoa/PreferenceObserver.mm

    r265740 r268421  
    3636    WKPreferenceObserver *m_observer;
    3737}
     38- (void)findPreferenceChangesAndNotifyForKeys:(NSDictionary<NSString *, id> *)oldValues toValuesForKeys:(NSDictionary<NSString *, id> *)newValues;
    3839@end
    3940
     
    4647@implementation WKUserDefaults
    4748
    48 - (void)_notifyObserversOfChangeFromValuesForKeys:(NSDictionary<NSString *, id> *)oldValues toValuesForKeys:(NSDictionary<NSString *, id> *)newValues
     49- (void)findPreferenceChangesAndNotifyForKeys:(NSDictionary<NSString *, id> *)oldValues toValuesForKeys:(NSDictionary<NSString *, id> *)newValues
    4950{
    50     [super _notifyObserversOfChangeFromValuesForKeys:oldValues toValuesForKeys:newValues];
    51 
    5251    if (!m_observer)
    5352        return;
     
    8584            [m_observer preferenceDidChange:m_suiteName key:key encodedValue:encodedString];
    8685    }
     86}
     87
     88- (void)_notifyObserversOfChangeFromValuesForKeys:(NSDictionary<NSString *, id> *)oldValues toValuesForKeys:(NSDictionary<NSString *, id> *)newValues
     89{
     90    [super _notifyObserversOfChangeFromValuesForKeys:oldValues toValuesForKeys:newValues];
     91
     92    if (!isMainThread()) {
     93        [self findPreferenceChangesAndNotifyForKeys:oldValues toValuesForKeys:newValues];
     94        return;
     95    }
     96
     97    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), [self, protectedSelf = retainPtr(self), oldValues = retainPtr(oldValues), newValues = retainPtr(newValues)] {
     98        [self findPreferenceChangesAndNotifyForKeys:oldValues.get() toValuesForKeys:newValues.get()];
     99    });
    87100}
    88101
Note: See TracChangeset for help on using the changeset viewer.