cryptee / web-client

Cryptee's web client source code for all platforms.
https://crypt.ee
Other
450 stars 23 forks source link

[Bug] PDF viewer clipped #131

Closed Parasrah closed 2 years ago

Parasrah commented 3 years ago

Describe the bug When viewing a PDF in cryptee, it does not fill the preview window, and the bottom is clipped out

To Reproduce

  1. upload a PDF
  2. open PDF inside cryptee

Expected behavior The preview takes the entire width and height of the resulting modal

Screenshots

cryptee_pdf_bug

System Information (please complete the following information):

Additional context Tested on both a chromebook and on my NixOS (linux) desktop, seeing a similar issue on my phone. I have tested with other PDF's as well, and am seeing the same issue.

johnozbay commented 3 years ago

Hi there,

Thanks a million for this! This is sooo incredibly strange!

If possible, could you let me now the pixel density of your devices, (i.e. retina / 2x / 3x etc) and whether if they have touchscreens or not?

You mentioned you're experiencing this on your phone as well. We can't seem to reproduce this on any of our test Android or iOS devices. If possible, could you please write your phone's OS / browser / version info here as well? That way we can try to figure out what might be causing this faster.

Many thanks! J

johnozbay commented 3 years ago

We can't seem to reproduce this so far – so I've got one more theory I'd like to put to test.

– What's your browser's language setting? (i.e. en-US for US English, or fr-CA for Canadian French etc) A few buttons on the PDF viewer are internationalized, and are displayed multilingually, to try and comply with the PDF specs as much as we can. Sometimes, for some languages, on some operating systems, due to the way how the fonts are rendered, text in different languages can take up 1 - 2 extra pixels here and there and break the viewer in unpredictable ways. (Although we did do some intense testing, I still don't want to rule this possibility out)

– Some PDFs have chapters, some don't. Some register page numbers programmatically, some don't. So for example, we have one PDF where the page numbers look like this:

image

And another where it looks like this:

image

Same system, same everything, just different PDFs. I can see on your screenshot the page numbers look like my second screenshot.

So if you wouldn't mind, if you can reproduce this bug with a PDF that doesn't have any private content in it, would you mind sharing it with us and that way we can take a deeper look into this? You can send it to support {at} crypt [dot] ee and we'll take it from there 👍🏻

Many thanks for your understanding and help! Apologies for the extensive questions, PDFs are difficult to debug 😳

Parasrah commented 3 years ago

Many thanks for your understanding and help! Apologies for the extensive questions, PDFs are difficult to debug

No worries! I appreciate how open you are in these bug reports, it helps me learn as well! I took a look at the language settings on my browser and sure enough I have it set to English (Canada), i.e. en-CA. Swapped it to en-US and suddenly PDF's are showing properly. I have a Pixel 5, which if gsmarena is to believed has ~432 ppi density. Unfortunately I cannot share the PDF used in the screenshot, but I also verified I was experiencing this with the PDF for a free d&d one-shot I had floating around, if having the specific PDF would still help I can email it to you as requested.

Thanks so much for all the hard work, cryptee really is a hidden gem, you're doing great work

johnozbay commented 3 years ago

Thanks a million for your kind words and compliments! Deeply appreciated! Glad to hear you're enjoying Cryptee and my GitHub ramblings were helpful in some way! haha

Sounds like I'll have to double check how we do the internationalization and add extra spaces to make sure things can't break. From the sounds of things, there's an i18n bug, and it's breaking the whole PDF viewer. For all I know this may have been happening in other languages like Thai etc too, and we wouldn't know until someone reports. We may be better off not translating for now 😞

Added to the upcoming release's to-do, we'll try our best to get this fixed ASAP! – Once we have a fix ready, we'll push it to beta, and I'll give you a ping so that you can test it out! Perhaps we'll be able to catch what's going on after a couple extra cups of coffee ☕️

So thank you for your patience with all these bugs! I apologize for how silly and unfair this internationalization bug is. I promise we'll get this fixed right away!

Best, J

Parasrah commented 3 years ago

No worries at all, all software products have bugs, not all software products have developers you can speak to about them. No need to apologize, yours is one of the few software products I use that thoroughly impresses me. And a good part of that is how you communicate with your users, although another part is how amazing the product is too.

I did have a chance earlier to test out the PDF I used in the screenshot, and unfortunately that one is still having the issue even with the language set to en-US in my browser. As you mentioned above, it does seem to match the second screenshot you provided for the page numbers. I also tried another pdf from the same company (paizo, they are pathfinder books), and it seemed to be having the same problem intermittently (sometimes it would render perfectly fine).

johnozbay commented 3 years ago

Thanks for your patience with this! Despite our 100 different attempts we still couldn't reproduce this.

I have reason to believe something with the PDF / its font might even be the root cause.

Sometimes the same font can have different widths / heights / sizes. I.e. a local font you have may have the same name, but different kind. For example we use Josefin Sans (Variable Font) – whereas if you have a non-variable version pre-installed on your machine, your browser may use that to save resources etc depending on your system / os etc. Font rendering is different on every device and OS (due to things like font-engine licensing, and display resolutions etc etc) making this a particularly challenging one to debug if font rendering is the cause here.

Despite our best efforts we can't seem to reproduce this on our machines, so for now I'm marking this as "help wanted" – and will forward to a few of our friends who use ChromeOS and perhaps hopefully they can reproduce these and identify what may be the cause.

If you can manage to reproduce this with a PDF you can send our way, please send it over to support {at} crypt [dot] ee and we can probably sort this out much faster that way!

Apologies, and thanks for your patience and understanding!

Best, J

Parasrah commented 3 years ago

No worries! I will definitely send you a pdf if I find one that I can repro with. If I find the time at some point I'll also attempt to debug myself if you welcome that kind of help

johnozbay commented 3 years ago

Thanks a lot! That would be amazing! Please feel free to debug and break things – and if possible, if you wouldn't mind, do it using beta.crypt.ee

– You'll find that it has a bit better logging for console debugging, – It gets feature / bug-fix updates more frequently than our main channel, needless to say would be easier to address and fix stuff on that channel. i.e. if you can find what's causing the issue, we can push a test version to beta, you can try out, see if it's fixed etc. etc.

Many thanks for your kind help, understanding and patience with this 🙏🏻

johnozbay commented 2 years ago

Hi there!

https://github.com/cryptee/web-client/commit/13fec562257ea35b3fec08d5b3a9ec180e457f78 should fix this issue, as we've made major changes and upgrades to our PDF viewer. You can read about all the amazing changes & new features we've added to our PDF viewer here.

Give it a try and let me know if you're still running into this issue!

Many thanks for reporting this bug and for your patience!

All the very best,

J

ghost commented 2 years ago

This bug is still happening. It happened to me 4 times in a row. I could only fix it by opening a different PDF. But now I can't reproduce it — no matter how hard I try.

johnozbay commented 2 years ago

Hey @SteffB44! Can you give it another try now? I believe after an intense one-month work on our PDF Viewer, this time we managed to fix it all for good!

ghost commented 2 years ago

Hello @johnozbay! I opened and closed PDF files like a maniac, every works fine now. Thanks!

ghost commented 2 years ago

EDIT: Actually, there is still something off. giphy

Occasionally, the PDF viewer stays empty:

Bildschirmfoto 2022-01-19 um 18 28 52

Like last time, I can't find a way to reproduce this. Sometimes it works perfectly, sometimes its doesn't work.

I tried it on Firefox and Safari(latest version, without extensions) – same behavior on both. I also tested Chrome (Brave). There it works fine it seems, but I can't tell for sure.

johnozbay commented 2 years ago

giphy

AHAHAHAH MY FACE EXACTLY.

Alright we managed to reproduce this by luck in 1 / 100 manual tests, no idea how, no idea why it's happening, and it's leading me to think there's some weird race condition we're overlooking here.

Looking into what might be causing this! Thanks a million @SteffB44! 🙏🏻