Skip to content
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

pdfjs black flicker #1279

Closed
wants to merge 1 commit into from
Closed

Conversation

MattL75
Copy link
Contributor

@MattL75 MattL75 commented Jan 13, 2023

See comment in pdfjs viewer code: https://github.com/mozilla/pdf.js/blob/master/web/pdf_page_view.js#L994

We also encountered this issue after adding alpha: false to canvas context. On zoom or on load the documents now load in from black (a direct consequence of alpha: false). The idea here is to hide the canvas until it loads.

@wojtekmaj Just gonna leave this PR here. Feel free to close and rewrite according to what you think is best :)

// Show the canvas on success and on errors
.then(this.onRenderSuccess)
.catch(this.onRenderError)
.finally(this.showCanvas)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In our fork we actually implemented the following and can confirm it works. However I noticed it failed a test so I changed it to finally, which I believe should have the same effect barring a little different timing.

.then(this.showCanvas, this.showCanvas)
.then(this.onRenderSuccess)
.catch(this.onRenderError)

@kamilkazmierczakMtab
Copy link

I am also experiencing this issue so this PR is helpful

@AsessionGuy
Copy link

This is really helpful. Pages with complex graphics take longer to render and showing black looks bad.
It would be nice to have something similar to Document's loading prop but for Page rendering.

@wojtekmaj wojtekmaj force-pushed the main branch 2 times, most recently from 36a36d4 to e249af6 Compare February 12, 2023 19:18
@wojtekmaj wojtekmaj force-pushed the main branch 4 times, most recently from 744f655 to 5b90b65 Compare March 2, 2023 14:26
@tomalexhughes
Copy link

See comment in pdfjs viewer code: https://github.com/mozilla/pdf.js/blob/master/web/pdf_page_view.js#L994

This comment looks to have been removed (although I can't find the commit for it?), but for anyone who's looking, this is the comment

@wojtekmaj
Copy link
Owner

Closed in favor of fc2ac76 as React-PDF went through major refactoring since then, made you @MattL75 a co-author - thanks for the original idea!

@wojtekmaj wojtekmaj closed this May 8, 2023
wojtekmaj added a commit that referenced this pull request May 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants