-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
feat(ext/canvas): enhance createImageBitmap
specification compliance
#25517
Conversation
…xcept for JPG and animated image - https://mimesniff.spec.whatwg.org/#matching-an-image-type-pattern
- adding `DOMExceptionInvalidStateError` in global due to handling not supported image format - animation image is not supported currently
a234586
to
1de527f
Compare
055395a
to
bd77fb9
Compare
Overall looking very good, though one nitpick: in the newly added error messages, could you remove the trailing |
@Hajime-san Happy new year! I updated copyright notice by #27509. Please merge main into this branch and update the same 🙏 |
@Hajime-san I know this took a while, but it had its reasons. The merge window for 2.2 is open now, so i want to get this landed this week; could you rebase it? and i will review it once more to be sure and then we can land it! |
@Hajime-san so i just compiled the PR locally, and noticed that the binary increased 604kb; do you have any insight into the cause behind this? probably one of the dependencies being really big? regardless, it is a bit too much of an increase. that aside this PR looks good to land, so thats the only blocker. |
@crowlKats MEMO: % uname -a
Darwin user.local 23.5.0 Darwin Kernel Version 23.5.0: Wed May 1 20:16:51 PDT 2024; root:xnu-10063.121.3~5/RELEASE_ARM64_T8103 arm64 main on d9db0b3 % cargo b -r --target-dir target/d9db0b35e && ls -l target/d9db0b35e/release/deno
-rwxr-xr-x 1 user 46682944 110354728 Jan 31 11:39 target/d9db0b35e/release/deno this pr ca52fe8 % cargo b -r --target-dir target/ca52fe82f && ls -l target/ca52fe82f/release/deno
-rwxr-xr-x 1 user 46682944 110646296 Jan 31 12:46 target/ca52fe82f/release/deno approximately 291kb larger |
if its one of the image formats that is causing massive increase, i think its fine to drop support for it and we can think about adding it in the future |
@crowlKats From my research, of the newly added image formats, In addition, I think that in terms of actual demand, I can follow your instructions and make additional commits to not include certain image formats in this PR. Here are simplified steps to reproduce for comparison of build sizes:
build resultmy pc % uname -a
Darwin user.local 23.5.0 Darwin Kernel Version 23.5.0: Wed May 1 20:16:51 PDT 2024; root:xnu-10063.121.3~5/RELEASE_ARM64_T8103 arm64 main on d9db0b3% ls -l target/d9db0b35e/release/deno
-rwxr-xr-x 1 user 46682944 110354728 Jan 31 11:39 target/d9db0b35e/release/deno based on this pr ca52fe8original% ls -l target/ca52fe82f/release/deno
-rwxr-xr-x 1 user 46682944 110646296 Jan 31 12:46 target/ca52fe82f/release/deno 291kb larger dynamic link
|
@Hajime-san lets disable gif and webp for now then |
I commented out the relevant lines with an explanation of the implementation, changed them to throw an error for each MIME type |
commenting out sounds better so we can re-enable it when we want to |
Signed-off-by: Leo Kettmeir <crowlkats@toaxl.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
As a follow-up and to enable #23783 given the changes in #27665, it would be nice if the |
@crowlKats @petamoriken BTW, it would be nice if you update the doc of the |
Feature
resolves #26032
basic support for decoding image format
jpeg
,png
,bmp
,ico
webp
,gif
Temporarily, these formats are not supported due to increases of build size.
issues for supporting AVIF
The AVIF image format is supported by all browsers today.
However, the standardization of sniffing mime type seems to have hard going.
supportcolorSpace
forImageData
There can convert color space fromsrgb
todisplay-p3
withcreateImageBitmap
.This was a misunderstanding on my part, so I reverted it.
The conversion using the
ImageData
colorSpace option was probably the responsibility ofCanvasRenderingContext2D
.I've left the implementation commented out as it may be useful as a reference for implementing
CanvasRenderingContext2D
orOffscreenCanvasRenderingContext2D
.support
colorSpaceConversion
optionThe specifications are not particularly clear about the implementation details, and I had a hard time understanding its behavior, but I eventually do reverse engineering the results of wpt and implemented it to be consistent with those results.
support receives
ImageBitmap
port to Rust
To simplify code, almost logic moved to Rust side.
added a simple architecture document for README
It is basically based on the
image
implementation, and I wrote roughly how you can handle data effectively.performance impact
I was curious to see if the increased amount of Rust code, especially static dispatch, was affecting the bootstrap time of the runtime.
I'm not very confident about the suitability of this benchmark.
bootstrap
API benchmark
extra
The benchmarks below are for when the argument to
op_create_image_bitmap
is a struct except for the first argument ofbuf
.It seems that serializing the argument to
op
as a struct has a fairly large impact on performance.This may apply to things other than
op_create_image_bitmap
as well.plans for enhancement in another PRs
improve performance
There is known to that processing image is a cpu-bound task. So,
op_create_image_bitmap
consider to be data-parallelism with usingrayon
.align error message