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

minPresenceAhead crashed application #2303

Closed
romasho opened this issue May 19, 2023 · 7 comments · Fixed by #2400
Closed

minPresenceAhead crashed application #2303

romasho opened this issue May 19, 2023 · 7 comments · Fixed by #2400

Comments

@romasho
Copy link

romasho commented May 19, 2023

Describe the bug
Using minPresenceAhead completely breaks the application in some cases (most likely when the content is larger than the page)

To Reproduce
Steps to reproduce the behavior including code snippet (if applies):

  1. Go to https://react-pdf.org/repl?example=orphans-and-widows
  2. Change widows={4} to minPresenceAhead={4}
  3. See error
@zakpucci
Copy link

zakpucci commented Aug 8, 2023

+1 experienced this as well.

@carlobeltrame
Copy link
Contributor

carlobeltrame commented Sep 18, 2023

I have occasionally run into the same problem. I'll try to debug it soon.
It looks to me like react-pdf gets into an infinite loop layouting and re-layouting the same page over and over again.
Setting a lower value to minPresenceAhead often reduces the chances of the problem happening.

@carlobeltrame
Copy link
Contributor

carlobeltrame commented Sep 18, 2023

First results indicate that a vertical margin on the element following the minPresenceAhead element causes the issue - when I remove the margin or replace it with padding, it seems to work. This can also be observed in the REPL: It works if you first remove the style={{ marginTop: 550 }} from the "Orphans example" Text element.

@carlobeltrame
Copy link
Contributor

I reworked the code which deals with minPresenceAhead and created a PR in #2400. @romasho @zakpucci If you can, please test whether it fixes the problems you observed on your side.

@zakpucci
Copy link

zakpucci commented Sep 21, 2023

Thanks @carlobeltrame, will test this out today. Experiencing another anomaly that I'll drop an issue in for later today. Very long PDF document halts at a specific page and jumbles all of the remaining text onto one page overlapping itself. Only happening on very long documents. Wondering if this could also be a side effect of the minPresenceAhead bug, will will test and get back to you with what I find.

@carlobeltrame
Copy link
Contributor

I haven't experienced that one myself, and I'm generating documents of up to 120 pages sometimes. But let's see.

@carlobeltrame
Copy link
Contributor

@zakpucci have you had a chance to test whether my fix works in your case?

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 a pull request may close this issue.

3 participants