stephanrauh / ngx-extended-pdf-viewer

A full-blown PDF viewer for Angular 16, 17, and beyond
https://pdfviewer.net
Apache License 2.0
484 stars 184 forks source link

Mobile Chrome crash on Pinch and Zoom > 200% ( Android 13,built in Web View but latest Chrome as well) #2568

Open dtrbi opened 1 month ago

dtrbi commented 1 month ago

Hi,

we found one issue with Pinch and Zoom on the mobile Chrome and Android 13. We can reproduce even with https://pdfviewer.net/extended-pdf-viewer/simple. Just try to zoom and it will crash.

We can not reproduce on Firefox Android or any browser on Android 14. As well https://mozilla.github.io/pdf.js/web/viewer.html works on Android 13 and does not crash.

All latest updates are installed on Android 13 device.

Version info

Demo PDF file Any .pdf file

Thank you and best regards.

stephanrauh commented 1 month ago

I don't own an Android device, let alone Android 13, so there's little I can do.

However, does this bug occur on https://mozilla.github.io/pdf.js/web/viewer.html or https://mozilla.github.io/pdf.js/legacy/web/viewer.html? If so, it's a bug of the base library, and you can forward it to the pdf.js team.

dtrbi commented 1 month ago

On both https://mozilla.github.io/pdf.js/web/viewer.html and https://mozilla.github.io/pdf.js/legacy/web/viewer.html it is working fine.

But as already said we can reproduce problem on most of Android 13 devices and some of Android 14 (mostly low level) on https://pdfviewer.net/extended-pdf-viewer/simple.

Steps to reproduce:

  1. Zoom in/zoom out with pinch and zoom several times

I am pretty sure there is some kind of memory leak.

Thank you for all your hard work and making our life with Angular and PDF.js much easier.

raphjutras commented 1 month ago

I can confirm that we also experience this problem on both Android and iOS.

It will happen when we zoom a lot on the PDF: ex, on construction plans, they are really zoomed-out and to be able to see any detail, the user must pinch to zoom it, more than 200%.

Example PDF file: https://vancouver.ca/files/cov/sample-drawing-package-1and2family.pdf

I have noticed that, while pinch-zooming, the screen will tear and freeze. Our app also crashed when zooming-in-out multiple time (with a bigger PDF plan than the sample provided here). Also, while zoomed, if we move to left-right, some part of the PDF just dissapear/blank. we have to zoom-out then re-zoom in to see it. There is clearly somethign strange happening.

stephanrauh commented 1 month ago

Phew. First of all, sorry for answering late. It's because I'm ill.

However, I still don't know how to solve the issue. I understand there's a difference between my fork of pdf.js and the original that causes crashes. But how to solve that? As I've mentioned earlier, I don't own an Android device, so I'm at a loss. @raphjutras I do own an iOS device, so maybe I can debug the problem, but it's still a major challenge.

Can I talk you into helping me? Does the debugger or the console show anything useful?

raphjutras commented 1 month ago

@stephanrauh I have made a simple test with original pdf.js in my Safari browser (iPhone) by accessing PDF.js official demo: https://mozilla.github.io/pdf.js/web/viewer.html

It seem that the original script suffer from same tearing bug when pinch-zooming a lot.

I havent had the chance to look at debuger/console.

raphjutras commented 1 month ago

Just did a research on PDF.js github, looks like the issue had already been flagged..! https://github.com/mozilla/pdf.js/issues/17713

dtrbi commented 1 month ago

Phew. First of all, sorry for answering late. It's because I'm ill.

Get well soon. Wishing you a speedy recovery. This bug is not so important.

stephanrauh commented 1 month ago

@raphjutras Are your referring to this workaround?

.pdfViewer .canvasWrapper,
.pdfViewer .page canvas[zooming] {
  width: inherit !important;
}
raphjutras commented 1 month ago

@stephanrauh Yes, I will definitely need to give this a try!

raphjutras commented 1 month ago

On both https://mozilla.github.io/pdf.js/web/viewer.html and https://mozilla.github.io/pdf.js/legacy/web/viewer.html it is working fine.

But as already said we can reproduce problem on most of Android 13 devices and some of Android 14 (mostly low level) on https://pdfviewer.net/extended-pdf-viewer/simple. .

I think this might be two separate/different bugs.. Tearing is something, app crashing is something else hehe

stephanrauh commented 1 month ago

Yes, you're right. I hoped it might be the same bug, but it was a wild shot.

stephanrauh commented 2 weeks ago

What about version 22.0.0? Currently, that's an alpha version, but it's running on a new version of pdf.js. Maybe that solves the issue?

raphjutras commented 2 weeks ago

Hello @stephanrauh, I have installed 21.4.6 and I still encouter problems when zomming a lot. I tried installing version 22.0.0 by adding this line to my package.json: "ngx-extended-pdf-viewer": "git://github.com/stephanrauh/ngx-extended-pdf-viewer.git#22.0.0-alpha.2"

It successfully installs it, I can see the changes in node_modules folder, however I am unable to build my Angular app after that, it will hrow a lot of errors (about my own components? I don't know why) and the last error is: Error: src/app/shared/shared.module.ts:79:44 - error TS2307: Cannot find module 'ngx-extended-pdf-viewer' or its corresponding type declarations. [ng] [ng] 79 import { NgxExtendedPdfViewerModule } from 'ngx-extended-pdf-viewer';

So I can't really test v22.0.0 on browser or mobile.