Skip to content
Permalink
Browse files
Regression(r279601) ProcessAssertion may get destroyed on a backgroun…
…d thread

https://bugs.webkit.org/show_bug.cgi?id=227875
<rdar://76972252>

Reviewed by Geoffrey Garen.

r279601 added an internal WorkQueue to ProcessAssertion, so that we could acquire the RunningBoard assertion
asynchronously on the background queue. When dispatching to the background queue, we capture |protectedThis|,
which means that ProcessAssertion may now get destroyed on the background queue. To address the isuse, we
now make sure to dispatch |protectedThis| back to the main thread in acquireAsync().

* UIProcess/ios/ProcessAssertionIOS.mm:
(WebKit::ProcessAssertion::acquireAsync):


Canonical link: https://commits.webkit.org/239630@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@279877 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
cdumez committed Jul 13, 2021
1 parent 96ea6d4 commit f60d0cb6b57bc5cc16381ba3804202b31c16cafd
Showing 2 changed files with 22 additions and 2 deletions.
@@ -1,3 +1,19 @@
2021-07-13 Chris Dumez <cdumez@apple.com>

Regression(r279601) ProcessAssertion may get destroyed on a background thread
https://bugs.webkit.org/show_bug.cgi?id=227875
<rdar://76972252>

Reviewed by Geoffrey Garen.

r279601 added an internal WorkQueue to ProcessAssertion, so that we could acquire the RunningBoard assertion
asynchronously on the background queue. When dispatching to the background queue, we capture |protectedThis|,
which means that ProcessAssertion may now get destroyed on the background queue. To address the isuse, we
now make sure to dispatch |protectedThis| back to the main thread in acquireAsync().

* UIProcess/ios/ProcessAssertionIOS.mm:
(WebKit::ProcessAssertion::acquireAsync):

2021-07-13 Kate Cheney <katherine_cheney@apple.com>

Allow layout tests to specify app initiated loads or not
@@ -343,10 +343,14 @@ - (void)assertion:(RBSAssertion *)assertion didInvalidateWithError:(NSError *)er

void ProcessAssertion::acquireAsync(CompletionHandler<void()>&& completionHandler)
{
ASSERT(isMainRunLoop());
assertionsWorkQueue().dispatch([protectedThis = makeRef(*this), completionHandler = WTFMove(completionHandler)]() mutable {
protectedThis->acquireSync();
if (completionHandler)
RunLoop::main().dispatch(WTFMove(completionHandler));
if (completionHandler) {
RunLoop::main().dispatch([protectedThis = WTFMove(protectedThis), completionHandler = WTFMove(completionHandler)]() mutable {
completionHandler();
});
}
});
}

0 comments on commit f60d0cb

Please sign in to comment.