-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove SVG Blob support from createImageBitmap #10172
base: main
Are you sure you want to change the base?
Conversation
This got added in whatwg#972 but never has been implemented since then. Supporting SVG in Workers is a no-go for most implementers as this would mean at least some DOM would need to be available in these contexts.
cc @whatwg/canvas and particularly @yiyix since you did remove the previous tests. |
This seems fine to me, although it seems surprising it wouldn't be supported anywhere. This is not too different from using an SVG I think it would be okay to add parallel tests for non-support if the canvas harness is too frustrating, although I suspect @fserb probably knows how to get it working. |
Yes, I suppose it could be implemented in a Window context. The issue is with Worker contexts, where you don't have access to the DOM at all and thus can't really load an SVG image since these rely on a DOM. So indeed, another possibility would be to add SVG Blob's support only for Window contexts, but maybe that makes the API more complex for something users can anyway workaround by passing an |
Here's an interesting test:
|
Oh, very good point... There is actually already a test for a similar case where a Blob with a But with the change it should throw because the MIME sniffing algo would return |
I think throwing on the SVG type is probably what we want though. That's a small change that would allow us to introduce this in the future if we wanted to and makes it more consistent with how the |
Not sure if this is useful information, but to add our usecase: We have an extension (yomitan) which stores tons of images in IndexedDB. We are trying to read these images, decode, and render them onto OffscreenCanvas(es) in a worker, to avoid blocking the main browser thread. This works perfectly with raster images, but once we hit an SVG it fails miserably. Our data has tons of SVGs and we cannot control that. (I wish Workers could supports rendering SVGs with some simplified/restricted DOM or something...) I'm not sure how complex the browser implementation is for this, but if it's theoretically feasible in any way, I think it would be nice for this to stay in the spec including even for Worker contexts, so that maybe one day it's supported... Edit: To anyone interested, we sort of worked around this a bit by using resvg-js wasm which allowed us to render our SVGs in the worker context. It's not completely ideal performance-wise but at least allows us to not block the main thread which is worth it. |
This got added in #972 but never has been implemented since then.
It seems that supporting SVG in Workers is a no-go for most implementers as this would mean at least some DOM would need to be available in these contexts.
(See WHATWG Working Mode: Changes for more details.)
/imagebitmap-and-animations.html ( diff )