[iOS] Occasional crashes in WebPage::elementDidBlur()'s async block.
authorakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 27 Jul 2015 23:01:14 +0000 (23:01 +0000)
committerakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 27 Jul 2015 23:01:14 +0000 (23:01 +0000)
<https://webkit.org/b/147281>
<rdar://problem/21701858>

Reviewed by Anders Carlsson.

Protect the WebPage object until the dispatch_async block has finished.
I have no way to repro this, but there's evidence of some crashing here.

* WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::WebPage::elementDidBlur):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@187459 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebKit2/ChangeLog
Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm

index 1fbea33..2249fe8 100644 (file)
@@ -1,3 +1,17 @@
+2015-07-27  Andreas Kling  <akling@apple.com>
+
+        [iOS] Occasional crashes in WebPage::elementDidBlur()'s async block.
+        <https://webkit.org/b/147281>
+        <rdar://problem/21701858>
+
+        Reviewed by Anders Carlsson.
+
+        Protect the WebPage object until the dispatch_async block has finished.
+        I have no way to repro this, but there's evidence of some crashing here.
+
+        * WebProcess/WebPage/ios/WebPageIOS.mm:
+        (WebKit::WebPage::elementDidBlur):
+
 2015-07-27  Michael Catanzaro  <mcatanzaro@igalia.com>
 
         [Seccomp] Set appropriate filters when trapping syscalls by default
index 5186d46..0864768 100644 (file)
@@ -2532,10 +2532,11 @@ void WebPage::elementDidBlur(WebCore::Node* node)
 {
     if (m_assistedNode == node) {
         m_hasPendingBlurNotification = true;
-        dispatch_async(dispatch_get_main_queue(), ^{
-            if (m_hasPendingBlurNotification)
-                send(Messages::WebPageProxy::StopAssistingNode());
-            m_hasPendingBlurNotification = false;
+        RefPtr<WebPage> protectedThis(this);
+        dispatch_async(dispatch_get_main_queue(), [protectedThis] {
+            if (protectedThis->m_hasPendingBlurNotification)
+                protectedThis->send(Messages::WebPageProxy::StopAssistingNode());
+            protectedThis->m_hasPendingBlurNotification = false;
         });
         m_hasFocusedDueToUserInteraction = false;
         m_assistedNode = nullptr;