-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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: upgrade to newer react-pdf and pdf.js to render high-resolution images properly on the web #33083
Conversation
…sion), added ReactPDFPageRenderer; migrated worker termination react-pdf patch to 7.3.3
Reviewer Checklist
Screenshots/VideosAndroid: Nativeandroid-native-2024-01-03_16.52.51.mp4Android: mWeb Chromeandroid-chrome-2024-01-03_13.54.30.mp4iOS: Nativeios-native-2024-01-03_12.38.15.mp4iOS: mWeb Safariios-safari-2024-01-03_12.25.06.mp4MacOS: Chrome / Safaridesktop-chrome-2023-12-18_11.43.57.mp4MacOS: Desktopdesktop-app-2023-12-18_12.05.20.mp4 |
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
Thank you @jjcoffee, sorry for the trouble - I will track & fix the issues you mentioned. |
…bPDFDocument propTypes
@jjcoffee the updated PR is ready for review now 🚀 |
@artus9033 Thanks and sorry for the delay (I was OOO). Could you resolve conflicts? |
@jjcoffee I have just signed all the commits, the question is - where should I put updated videos? I also believe that checklist changed after Artur created this PR so how should we adjust that? |
Any way to stop the screen going white when resizing the window? I see it also happens on staging so we don't necessarily need to handle it here, but it would be nice if it's straight-forward enough: chrome-resize-2024-01-17_14.29.55.mp4 |
I dont think we are able to fix it right now - this behaviour is strictly connected to the flow of rendering pdf itself while resizing view -> resizing canvas size -> calculating density of pixels -> and then rerendering |
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.
Tests well & LGTM!
Checklist updated to the latest version. |
@jjcoffee shouldn't the new files be created in TS already? |
@danieldoglas Hmm good point! I think since the PR was raised before the announcement it might be best to avoid extra complexity by migrating the existing PR to TS as well. @MrRefactor just added a small tweak to @artus9033's original PR. Once we switch to our custom PDF library, I'd expect all of that to be written in TS, maybe @rezkiy37 can confirm? |
The library is being written in TS. So, I already started to integrate cc @jjcoffee |
@danieldoglas Sounds like we're good to merge this so that we unblock @rezkiy37's work on |
@jjcoffee can you please use the most updated version of the checklist, since this is not passing the test for it? Also, I'm trying to understand why this is not passing the snyk tests |
@danieldoglas Already updated, the check just needs to be rerun, I think! |
@rezkiy37 the snyk error is the following:
Can you please fix it and push it? |
Sorry, but current PR it is not mine. |
e80b8b6
to
bd83d53
Compare
Hi @danieldoglas I have updated the branch, made sure of reinstalling all the depts and merging fresh main to it - as I can see there is still na issue with |
@danieldoglas Apparently the snyk error happens on all PRs where the package file is changed, see here. So I think we're good to ignore for now! |
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
🚀 Deployed to staging by https://github.com/danieldoglas in version: 1.4.29-0 🚀
|
🚀 Deployed to staging by https://github.com/danieldoglas in version: 1.4.29-0 🚀
|
🚀 Deployed to production by https://github.com/thienlnam in version: 1.4.29-1 🚀
|
Details
PDF files carrying images of large resolutions (such as the one posted in this issue) are not rendered on iOS Safari, although we would like them to be rendered properly.
This is because our app on the web uses
react-pdf
, which in turn usespdf.js
(here, from an NPM packagepdfjs-dist
) as renderer. The renderer utilizes a canvas to render PDF contents. Every browser has limitations applicable to the canvas element, since it requires a buffer to be allocated in memory. It is specified and well tested that Safari limits the maximum size to 4096x4096 px. The PDF provided in the original issue carries an image that breaks this limit.The maintainers of
pdf.js
commented that starting from version 3.5.141 they are attempting to use theOffscreenCanvas
to downsize over-large images in PDFs, if it is implemented in the host browser at runtime, which fixes the issue at the expense of rendering quality.This PR concentrates on porting
src/components/PDFView
to work withreact-pdf
version7.3.3
(which relies onpdfjs-dist
version3.6.172
that contains the aforementioned feature) that's aligned with the current work done in (WIP) switch to a custom library here.Fixed Issues
$ #32502
PROPOSAL: #32502 (comment)
Tests
Offline tests
N/A since loading of chat attachments requires an internet connection.
QA Steps
PR Author Checklist
### Fixed Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)myBool && <MyComponent />
.src/languages/*
files and using the translation methodWaiting for Copy
label for a copy review on the original GH to get the correct copy.STYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG)
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)Design
label so the design team can review the changes.ScrollView
component to make it scrollable when more elements are added to the page.main
branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTest
steps.Screenshots/Videos
Android: Native
android-native.mov
Android: mWeb Chrome
android-web.mov
iOS: Native
native-ios.mov
iOS: mWeb Safari
ios-web.mov
MacOS: Chrome / Safari
safari-web.mov
chrome-web.mov
MacOS: Desktop
macos-desktop.mov