-
-
Notifications
You must be signed in to change notification settings - Fork 85
PDF.js + Webpack has drawImage check failure #994
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
Comments
I'm able to reproduce the issue with a very simple repo, which only has the objective of loading a PDF and printing the first page: https://github.com/Cybourgeoisie/webpack-pdfjs-napirscanvas-test |
We have observed the same issue. It looks like this is a regression from 0.1.65 -> 0.1.68. We saw the problem with a dependency upgrade that upgraded pdfjs-dist's dependency on @napi-rs/canvas from 0.1.65 to 0.1.68, and reverting this upgrade fixed it (note that there were some other upgrades as well, I'm not 100% sure that it really was that upgrade). The error occurs on this line of pdfjs ( ctx.drawImage(maskCanvas, mask.offsetX, mask.offsetY); This makes me suspect that it's related to #984. |
The error is coming from decoding this parameter: Line 1521 in 5944ea3
The canvas passed in by pdfjs is coming from which comes from the cached canvases: and the canvas is being created from a canvas factory (without a flag, so a |
The following error occurs only in Electron builds (update: it's occurring in the webpack code, not just electron) with pdfjs-dist (current version, v4.10.38) and @napi-rs/canvas (current version, v0.1.67). This issue does not happen when running the code in development, but does happen after consolidating the code into webpack, and running via electron development or a build.
Error message:
Error: Value is non of these types CanvasElement, SVGCanvas, Image,
In my specific case, I've traced the exact call error down to a pdfjs function that calls drawImage on a canvas.
The inputs, contexts, and canvases are all existent both in development and in the running Electron build, so there isn't a missing parameter, and as far as I can see, it isn't malformed.
The error seems to be triggered early in the
ctx.rs::draw_image
function, possibly when trying to match the type of image on line 1539 - as I was able to find that the Either3 error code is what produces the text for the above error, per https://prisma.github.io/prisma-engines/doc/src/napi/bindgen_runtime/js_values/either.rs.html#91I will keep investigating, but it feels like moving forward is to identify why a valid CanvasElement input from Node.JS would not be identified as a valid type when the rust code is called.
The text was updated successfully, but these errors were encountered: