Changeset 260544 in webkit


Ignore:
Timestamp:
Apr 22, 2020 5:04:26 PM (4 years ago)
Author:
Chris Dumez
Message:

[iOS] Crash on RunningBoard process assertion invalidation
https://bugs.webkit.org/show_bug.cgi?id=210873
<rdar://problem/62194917>

Reviewed by Darin Adler.

  • UIProcess/ios/ProcessAssertionIOS.mm:

(-[WKRBSAssertionDelegate assertion:didInvalidateWithError:]):
Capture a weak pointer to self and make sure we only access the invalidation handler on
the main thread if |self| is still alive.

(WebKit::ProcessAssertion::~ProcessAssertion):
Null out the WKRBSAssertionDelegate's observer in the ProcessAssertion destructor, to
make sure processAssertionWasInvalidated() cannot get called after the ProcessAssertion
has been destroyed.

Location:
trunk/Source/WebKit
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r260527 r260544  
     12020-04-22  Chris Dumez  <cdumez@apple.com>
     2
     3        [iOS] Crash on RunningBoard process assertion invalidation
     4        https://bugs.webkit.org/show_bug.cgi?id=210873
     5        <rdar://problem/62194917>
     6
     7        Reviewed by Darin Adler.
     8
     9        * UIProcess/ios/ProcessAssertionIOS.mm:
     10        (-[WKRBSAssertionDelegate assertion:didInvalidateWithError:]):
     11        Capture a weak pointer to self and make sure we only access the invalidation handler on
     12        the main thread if |self| is still alive.
     13
     14        (WebKit::ProcessAssertion::~ProcessAssertion):
     15        Null out the WKRBSAssertionDelegate's observer in the ProcessAssertion destructor, to
     16        make sure processAssertionWasInvalidated() cannot get called after the ProcessAssertion
     17        has been destroyed.
     18
    1192020-04-22  David Kilzer  <ddkilzer@apple.com>
    220
  • trunk/Source/WebKit/UIProcess/ios/ProcessAssertionIOS.mm

    r260453 r260544  
    287287{
    288288    RELEASE_LOG(ProcessSuspension, "%p - WKRBSAssertionDelegate: assertion was invalidated, error: %{public}@", error, self);
     289
     290    __weak WKRBSAssertionDelegate *weakSelf = self;
    289291    dispatch_async(dispatch_get_main_queue(), ^{
    290         if (_invalidationCallback)
    291             _invalidationCallback();
     292        WKRBSAssertionDelegate *strongSelf = weakSelf;
     293        if (strongSelf && strongSelf.invalidationCallback)
     294            strongSelf.invalidationCallback();
    292295    });
    293296}
     
    420423
    421424    if (m_rbsAssertion) {
     425        m_delegate.get().invalidationCallback = nil;
     426        m_delegate = nil;
     427
    422428        [m_rbsAssertion removeObserver:m_delegate.get()];
    423429        [m_rbsAssertion invalidate];
Note: See TracChangeset for help on using the changeset viewer.