Title: [250248] trunk/Source/WebKit
Revision
250248
Author
david_ques...@apple.com
Date
2019-09-23 13:15:19 -0700 (Mon, 23 Sep 2019)

Log Message

[iOS] REGRESSION(r250151): Occasional assertion failures in ShareableBitmap::~ShareableBitmap()
https://bugs.webkit.org/show_bug.cgi?id=202112
rdar://problem/55624598

Reviewed by Chris Dumez.

* Shared/cg/ShareableBitmapCG.cpp:
(WebKit::ShareableBitmap::releaseDataProviderData):
It is possible and valid for a UIImage created from a ShareableBitmap's CGImage representation
to be deallocated on a background thread. When this happens, releaseDataProviderData() should
ensure it's running on the main thread before deref'ing the ShareableBitmap. Otherwise the
bitmap can be deallocated on the background thread, violating an assertion added in r250151.

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (250247 => 250248)


--- trunk/Source/WebKit/ChangeLog	2019-09-23 19:15:37 UTC (rev 250247)
+++ trunk/Source/WebKit/ChangeLog	2019-09-23 20:15:19 UTC (rev 250248)
@@ -1,3 +1,18 @@
+2019-09-23  David Quesada  <david_ques...@apple.com>
+
+        [iOS] REGRESSION(r250151): Occasional assertion failures in ShareableBitmap::~ShareableBitmap()
+        https://bugs.webkit.org/show_bug.cgi?id=202112
+        rdar://problem/55624598
+
+        Reviewed by Chris Dumez.
+
+        * Shared/cg/ShareableBitmapCG.cpp:
+        (WebKit::ShareableBitmap::releaseDataProviderData):
+        It is possible and valid for a UIImage created from a ShareableBitmap's CGImage representation
+        to be deallocated on a background thread. When this happens, releaseDataProviderData() should
+        ensure it's running on the main thread before deref'ing the ShareableBitmap. Otherwise the
+        bitmap can be deallocated on the background thread, violating an assertion added in r250151.
+
 2019-09-23  Joseph Pecoraro  <pecor...@apple.com>
 
         Web Inspector: Improve the Uncaught Exception View file a bug link

Modified: trunk/Source/WebKit/Shared/cg/ShareableBitmapCG.cpp (250247 => 250248)


--- trunk/Source/WebKit/Shared/cg/ShareableBitmapCG.cpp	2019-09-23 19:15:37 UTC (rev 250247)
+++ trunk/Source/WebKit/Shared/cg/ShareableBitmapCG.cpp	2019-09-23 20:15:19 UTC (rev 250248)
@@ -156,6 +156,13 @@
 
 void ShareableBitmap::releaseDataProviderData(void* typelessBitmap, const void* typelessData, size_t)
 {
+    if (!RunLoop::isMain()) {
+        RunLoop::main().dispatch([typelessBitmap, typelessData] {
+            releaseDataProviderData(typelessBitmap, typelessData, 0);
+        });
+        return;
+    }
+
     ShareableBitmap* bitmap = static_cast<ShareableBitmap*>(typelessBitmap);
     ASSERT_UNUSED(typelessData, bitmap->data() == typelessData);
     bitmap->deref(); // Balanced by ref in createCGImage.
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to