If you decode an SVG off the main thread via ImageBitmap, this results in a crash. You can test this by enabling offscreen-canvas and running either of these two tests: imported/w3c/web-platform-tests/offscreen-canvas/drawing-images-to-the-canvas/2d.drawImage.svg.worker.html imported/w3c/web-platform-tests/offscreen-canvas/drawing-images-to-the-canvas/2d.drawImage.zerosource.image.worker.html
None of the SVG code is thread safe. You'll need to bounce to the main thread for SVG.
Created attachment 427409 [details] Patch
Comment on attachment 427409 [details] Patch ImageBitmap obviously doesn't need an actual SVG document, it was only using Image to get the bitmap data. Instead, use BitmapImage directly and bypass the SVG and PDF document image loaders.
Comment on attachment 427409 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=427409&action=review > Source/WebCore/html/ImageBitmap.cpp:739 > + auto image = BitmapImage::create(&observer.get()); The better idiom here is observer.ptr(). > Source/WebCore/html/ImageBitmap.cpp:760 > + bitmapData->context().drawImage(image.get(), destRect, sourceRectangle.releaseReturnValue(), { interpolationQualityForResizeQuality(options.resizeQuality), imageOrientationForOrientation(options.imageOrientation) }); Not sure we need ".get()" here. Ref typically converts itself to a reference when passing it as an argument. > Source/WebCore/svg/graphics/SVGImage.cpp:83 > + ASSERT(isMainThread()); Consider also having this assertion in Image::create itself? The assertion without a comment seems a little mysterious; not that Iād want a long comment.
Created attachment 427544 [details] Patch
Committed r276895 (237241@main): <https://commits.webkit.org/237241@main> All reviewed patches have been landed. Closing bug and clearing flags on attachment 427544 [details].
<rdar://problem/77448836>