Title: [250151] trunk/Source/WebKit
Revision
250151
Author
[email protected]
Date
2019-09-20 14:06:26 -0700 (Fri, 20 Sep 2019)

Log Message

[iOS] ASSERTION FAILED: Unsafe to ref/deref of ShareableBitmap from different threads
https://bugs.webkit.org/show_bug.cgi?id=201712
<rdar://problem/55289916>

Reviewed by Tim Horton.

Make sure ShareableBitmap objects are always ref'd / deref'd on the main thread by dispatching to
the main thread in ShareableBitmap::releaseBitmapContextData() before calling deref().

* Shared/ShareableBitmap.cpp:
(WebKit::ShareableBitmap::ShareableBitmap):
(WebKit::ShareableBitmap::~ShareableBitmap):
* Shared/cg/ShareableBitmapCG.cpp:
(WebKit::ShareableBitmap::createGraphicsContext):
(WebKit::ShareableBitmap::releaseBitmapContextData):

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (250150 => 250151)


--- trunk/Source/WebKit/ChangeLog	2019-09-20 21:01:10 UTC (rev 250150)
+++ trunk/Source/WebKit/ChangeLog	2019-09-20 21:06:26 UTC (rev 250151)
@@ -1,3 +1,21 @@
+2019-09-20  Chris Dumez  <[email protected]>
+
+        [iOS] ASSERTION FAILED: Unsafe to ref/deref of ShareableBitmap from different threads
+        https://bugs.webkit.org/show_bug.cgi?id=201712
+        <rdar://problem/55289916>
+
+        Reviewed by Tim Horton.
+
+        Make sure ShareableBitmap objects are always ref'd / deref'd on the main thread by dispatching to
+        the main thread in ShareableBitmap::releaseBitmapContextData() before calling deref().
+
+        * Shared/ShareableBitmap.cpp:
+        (WebKit::ShareableBitmap::ShareableBitmap):
+        (WebKit::ShareableBitmap::~ShareableBitmap):
+        * Shared/cg/ShareableBitmapCG.cpp:
+        (WebKit::ShareableBitmap::createGraphicsContext):
+        (WebKit::ShareableBitmap::releaseBitmapContextData):
+
 2019-09-20  Alex Christensen  <[email protected]>
 
         Begin moving WebsiteDataStore setters to WebsiteDataStoreConfiguration

Modified: trunk/Source/WebKit/Shared/ShareableBitmap.cpp (250150 => 250151)


--- trunk/Source/WebKit/Shared/ShareableBitmap.cpp	2019-09-20 21:01:10 UTC (rev 250150)
+++ trunk/Source/WebKit/Shared/ShareableBitmap.cpp	2019-09-20 21:06:26 UTC (rev 250151)
@@ -163,6 +163,7 @@
     , m_configuration(configuration)
     , m_data(data)
 {
+    ASSERT(RunLoop::isMain());
 }
 
 ShareableBitmap::ShareableBitmap(const IntSize& size, Configuration configuration, RefPtr<SharedMemory> sharedMemory)
@@ -171,6 +172,8 @@
     , m_sharedMemory(sharedMemory)
     , m_data(nullptr)
 {
+    ASSERT(RunLoop::isMain());
+
 #if USE(DIRECT2D)
     createSharedResource();
 #endif
@@ -178,6 +181,8 @@
 
 ShareableBitmap::~ShareableBitmap()
 {
+    ASSERT(RunLoop::isMain());
+
     if (!isBackedBySharedMemory())
         fastFree(m_data);
 #if USE(DIRECT2D)

Modified: trunk/Source/WebKit/Shared/cg/ShareableBitmapCG.cpp (250150 => 250151)


--- trunk/Source/WebKit/Shared/cg/ShareableBitmapCG.cpp	2019-09-20 21:01:10 UTC (rev 250150)
+++ trunk/Source/WebKit/Shared/cg/ShareableBitmapCG.cpp	2019-09-20 21:06:26 UTC (rev 250151)
@@ -87,6 +87,7 @@
 
 std::unique_ptr<GraphicsContext> ShareableBitmap::createGraphicsContext()
 {
+    ASSERT(RunLoop::isMain());
     ref(); // Balanced by deref in releaseBitmapContextData.
 
     unsigned bytesPerPixel = calculateBytesPerPixel(m_configuration);
@@ -141,6 +142,13 @@
 
 void ShareableBitmap::releaseBitmapContextData(void* typelessBitmap, void* typelessData)
 {
+    if (!RunLoop::isMain()) {
+        RunLoop::main().dispatch([typelessBitmap, typelessData] {
+            releaseBitmapContextData(typelessBitmap, typelessData);
+        });
+        return;
+    }
+
     ShareableBitmap* bitmap = static_cast<ShareableBitmap*>(typelessBitmap);
     ASSERT_UNUSED(typelessData, bitmap->data() == typelessData);
     bitmap->deref(); // Balanced by ref in createGraphicsContext.
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to