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
Support preview for DDS images #17564
base: development
Are you sure you want to change the base?
Conversation
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.
First of all thanks for your contribution! It looks great overall, but we have some concerns about it:
- We see many dependencies installed to get to render the DDS image in a canvas. Given how (seemingly) "simple" the rendering process is for this, could you try to get rid of all new dependencies (except for
parse-dds
) and just implement the minimum WebGL stuff needed in thedds-converter.ts
file? - We have seen in the past a number of security issues related to GPU work, so we were hoping this WebGL render code could be moved to a utility process that would run independently from the main and renderer processes.
Thanks for the review! Both of those suggestions seem like good ideas, I can definitely do them. |
I pushed commits to remove the |
Oops! You're right, I think in this case we'd need a new Sorry about that 😅 and thanks for cleaning up those two dependencies! ❤️
Nothing specific, just being extra cautious 😅 |
Hmm, I've been working the new Without any specific security concerns we're solving for, is all that worth it? It certainly makes the code harder to process, follow, and work on. And it adds additional opportunities for failures/exceptions. Plus, all that additional complexity has it's own security risks. Not to mention that these are official and long-standing WebGL APIs which are sandboxed and field-tested with thousands (if not a lot more) of websites. Heck, I'd venture to guess that those APIs have way more eyes on them and testing (including pen-testing) then Electron's process separation, IPC, etc. I've pushed the changes to a separate branch if you'd like to review the commit and tell me if I'm making this way more complicated than needed or missed something obvious mkafrin@d4c5c16. However, if that's basically on the mark and what would need to be done to support process separation, I think it's worth reviewing whether it's worth it and if there's a real concern we're solving for. |
Thank you for that! 🙏 I'll discuss your comment with the team and let you know as soon as possible. |
Any update on this by chance? |
@mkafrin We appreciate your patience on this, unfortunately, we have not been able to discuss this yet. It may be some time before we can circle back. |
No problem! Just wanted to keep up with it. Thanks for the update! |
Uses WebGL2 to render DDS images to a canvas, then extract that canvas image to a dataURL that can be passed into the existing logic to render image previews. This also necessitates adding the rawContents (buffer) to the Image class so we can use that in the conversion later on. This is technically an optimization since we could decode the base64 contents, but that would introduce an additional (and significant) delay in the conversion that is unnecessary.
5961bfe
to
2cdd194
Compare
Avoid having an additional dependency by hand-rolling simple gl shader/program compilation helpers.
Avoid having an additional dependency by hand-rolling WebGL triangle drawing.
2cdd194
to
f92a8f0
Compare
Rebased to fix some conflicts and also to remove the type packages in the original commits, rather than having an additional commit on top. |
Any updates by chance? @tidy-dev |
Closes #5337
Description
Uses WebGL2 to render DDS images to a canvas, then extract that canvas image to a dataURL that can be passed into the existing logic to render image previews.
This also necessitates adding the rawContents (buffer) to the Image class so we can use that in the conversion later on. This is technically an optimization since we could decode the base64 contents, but that would introduce an additional (and significant) delay in the conversion that is unnecessary.
The alternative option is to enhance the ImageContainer to be able to render to canvas directly, so it can use canvas for DDS and img for anything else. I played around with this and got pretty far, but kept running into issues so decided to push that off for a potential future enhancement. At the end of the day, this solution produces the same results, just a bit slower due to the toDataURL call to convert the canvas to a dataURL for rendering.
Screenshots
Preview of DDS in deletion diff:
Preview of DDS in addition diff:
Preview of DDS in modification diff (in all four modes):
Release notes
Notes: