Skip to content
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

fix(ext/web): pass createImageBitmap when the argument type is Blob #23518

Merged
merged 5 commits into from May 7, 2024

Conversation

Hajime-san
Copy link
Contributor

fixes #22649

- pass buffer with Unit8Array when the type of argument is `Blob`
- decode with `DynamicImage`
ext/canvas/lib.rs Outdated Show resolved Hide resolved
@Hajime-san Hajime-san marked this pull request as ready for review April 24, 2024 03:29
@Hajime-san
Copy link
Contributor Author

BTW, the reason that I switched to DynamicImage is getting the error as follows after to pass buffer with Unit8Array when the type of argument is Blob.

% target/debug/deno run -A blob.ts

============================================================
Deno has panicked. This is a bug in Deno. Please report this
at https://github.com/denoland/deno/issues/new.
If you can reliably reproduce this panic, include the
reproduction steps and re-run with the RUST_BACKTRACE=1 env
var set and include the backtrace in your report.

Platform: macos aarch64
Version: 1.42.4
Args: ["target/debug/deno", "run", "-A", "blob.ts"]

thread 'main' panicked at /Users/user/.cargo/registry/src/index.crates.io-6f17d22bba15001f/image-0.24.9/src/codecs/png.rs:271:9:
assertion `left == right` failed
  left: Ok(0)
 right: Ok(16384)
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
user@name deno % RUST_BACKTRACE=1 target/debug/deno run -A blob.ts

============================================================
Deno has panicked. This is a bug in Deno. Please report this
at https://github.com/denoland/deno/issues/new.
If you can reliably reproduce this panic, include the
reproduction steps and re-run with the RUST_BACKTRACE=1 env
var set and include the backtrace in your report.

Platform: macos aarch64
Version: 1.42.4
Args: ["target/debug/deno", "run", "-A", "blob.ts"]

thread 'main' panicked at /Users/user/.cargo/registry/src/index.crates.io-6f17d22bba15001f/image-0.24.9/src/codecs/png.rs:271:9:
assertion `left == right` failed
  left: Ok(0)
 right: Ok(16384)
stack backtrace:
   0: rust_begin_unwind
             at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library/std/src/panicking.rs:647:5
   1: core::panicking::panic_fmt
             at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library/core/src/panicking.rs:72:14
   2: core::panicking::assert_failed_inner
   3: core::panicking::assert_failed
             at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library/core/src/panicking.rs:297:5
   4: <image::codecs::png::PngDecoder<R> as image::image::ImageDecoder>::read_image
             at /Users/user/.cargo/registry/src/index.crates.io-6f17d22bba15001f/image-0.24.9/src/codecs/png.rs:271:9
   5: deno_canvas::op_image_decode_png::op_image_decode_png::call
             at ./ext/canvas/lib.rs:135:3
   6: deno_canvas::op_image_decode_png::op_image_decode_png::slow_function_impl
             at ./ext/canvas/lib.rs:118:1
   7: deno_canvas::op_image_decode_png::op_image_decode_png::v8_fn_ptr
             at ./ext/canvas/lib.rs:118:1
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

@crowlKats
Copy link
Member

hm, that is concerning, that should be working

ext/canvas/lib.rs Outdated Show resolved Hide resolved
@Hajime-san
Copy link
Contributor Author

Hi @crowlKats, this PR would fix only the bug currently.
BTW I'm reading the issue here #23563 , should I tackle more work like below?

  • implementation with DynamicImage(Sorry, I reverted it once 52eab19)
  • support other mime type other than image/png within the reange of image-type
  • support other bit depth not only 8-bit

@chirsz-ever
Copy link
Contributor

chirsz-ever commented May 7, 2024

I think it's better to merge this PR first. Now this PR make the RGBA PNG Blob works fine. Adding other more formats would bring more implementation details and unit tests, which is not just a "fix".

@crowlKats
Copy link
Member

I agree with @chirsz-ever; lets land this and continue work via follow-ups

@crowlKats crowlKats merged commit e7a2317 into denoland:main May 7, 2024
17 checks passed
@Hajime-san Hajime-san deleted the fix-web-createimagebitmap branch May 7, 2024 13:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Calling createImageBitmap with a Blob, "TypeError: expected typed ArrayBufferView" occurred.
3 participants