Title: [173782] trunk/Source/WebCore
Revision
173782
Author
psola...@apple.com
Date
2014-09-19 17:05:13 -0700 (Fri, 19 Sep 2014)

Log Message

[iOS] ASSERTION FAILED: WTF::isMainThread() in WebCore::memoryCache() when using WebKit1
https://bugs.webkit.org/show_bug.cgi?id=136962
<rdar://problem/18342344>

Reviewed by Geoffrey Garen.

The disk cache monitor callback code was being executed on the main thread. This is wrong
when the web thread is being used in WebKit1 on iOS. The code needs to run on the web
thread. Use WebThreadRun to dispatch the block to the web thread. This works for WebKit2 as
well since when web thread is not being used, WebThreadRun invokes the block directly.

* loader/cocoa/DiskCacheMonitorCocoa.mm:
(WebCore::DiskCacheMonitor::DiskCacheMonitor):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (173781 => 173782)


--- trunk/Source/WebCore/ChangeLog	2014-09-19 23:10:41 UTC (rev 173781)
+++ trunk/Source/WebCore/ChangeLog	2014-09-20 00:05:13 UTC (rev 173782)
@@ -1,3 +1,19 @@
+2014-09-19  Pratik Solanki  <psola...@apple.com>
+
+        [iOS] ASSERTION FAILED: WTF::isMainThread() in WebCore::memoryCache() when using WebKit1
+        https://bugs.webkit.org/show_bug.cgi?id=136962
+        <rdar://problem/18342344>
+
+        Reviewed by Geoffrey Garen.
+
+        The disk cache monitor callback code was being executed on the main thread. This is wrong
+        when the web thread is being used in WebKit1 on iOS. The code needs to run on the web
+        thread. Use WebThreadRun to dispatch the block to the web thread. This works for WebKit2 as
+        well since when web thread is not being used, WebThreadRun invokes the block directly.
+
+        * loader/cocoa/DiskCacheMonitorCocoa.mm:
+        (WebCore::DiskCacheMonitor::DiskCacheMonitor):
+
 2014-09-19  Jer Noble  <jer.no...@apple.com>
 
         Unreviewed build fix; pass duration into the lambda.

Modified: trunk/Source/WebCore/loader/cocoa/DiskCacheMonitorCocoa.mm (173781 => 173782)


--- trunk/Source/WebCore/loader/cocoa/DiskCacheMonitorCocoa.mm	2014-09-19 23:10:41 UTC (rev 173781)
+++ trunk/Source/WebCore/loader/cocoa/DiskCacheMonitorCocoa.mm	2014-09-20 00:05:13 UTC (rev 173782)
@@ -43,6 +43,10 @@
 #endif
 #endif
 
+#if USE(WEB_THREAD)
+#include "WebCoreThreadRun.h"
+#endif
+
 #if (PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090)
 
 typedef void (^CFCachedURLResponseCallBackBlock)(CFCachedURLResponseRef);
@@ -88,6 +92,7 @@
     // Set up the disk caching callback to create the ShareableResource and send it to the WebProcess.
     CFCachedURLResponseCallBackBlock block = ^(CFCachedURLResponseRef cachedResponse)
     {
+        ASSERT(isMainThread());
         // If the monitor isn't there then it timed out before this resource was cached to disk.
         if (!rawMonitor)
             return;
@@ -102,7 +107,17 @@
         monitor->resourceBecameFileBacked(fileBackedBuffer);
     };
 
-    _CFCachedURLResponseSetBecameFileBackedCallBackBlock(cachedResponse, block, dispatch_get_main_queue());
+#if USE(WEB_THREAD)
+    CFCachedURLResponseCallBackBlock blockToRun = ^ (const CFCachedURLResponseRef response)
+    {
+        WebThreadRun(^ {
+            block(response);
+        });
+    };
+#else
+    CFCachedURLResponseCallBackBlock blockToRun = block;
+#endif
+    _CFCachedURLResponseSetBecameFileBackedCallBackBlock(cachedResponse, blockToRun, dispatch_get_main_queue());
 }
 
 void DiskCacheMonitor::resourceBecameFileBacked(PassRefPtr<SharedBuffer> fileBackedBuffer)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to