-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Infinite loop hanging megathread (minPresenceAhead, margin, break) #2659
Comments
So regarding my main issue 1D) I've dug around for 6 hours without a definite conclusion. Total weirdness ensures:
It really looks like a certain vertical flow position of a certain View or certain Text results in the infinite loop and the margin and different font size or breaking just contribute to that awkward spot. I'm inclined my logging strategy doesn't work as a marginBottom can't have an effect on |
I'm seeing roughly the same issue as well. We're rendering a list of entry components (elements in a medical record). Certain combinations will cause ReactPDF to go into an infinite loop in the For one of our problem documents:
Like @tom2strobl said above, it seems like the margins might be a red herring and the bug is actually caused by a node with specific attributes being split. I'm continuing to investigate the page splitting logic to see where the loop might be happening. Apologies for the relative lack of details and clarity in my comment 😁
|
Did a bunch of digging and debugging into this. I believe the root cause is We have Example (in the form of params to
|
I'm also running into an infinite loop hanging and ultimately crashing the browser. I don't have much to add except that I tried removing any and all bottom margin in my entire document, and I still got the infinite loop hanging. Was also using React-pdf version 3.3.8 on chrome, and I was not using any minPresenceAhead. Edit: I solved my problem. It seems that my issue was that I had a |
Description
Note that I use 3.3.8 which afaik should already include #2400
Preliminary work
Regarding 1)
Regarding 2)
Reproducable cases
(note I'm using @jeetiss REPL for hanging issues since you obviously can't share an url of the official REPL if the process hangs)
1A) Simplest reproducible case REPL: (yes, this is still a thing, nobody confirmed it's fix really)
1B) Reducing available space to make it not fit REPL
1C) It's not padding-bound either, as decreasing padding, but increasing font-size has the same effect REPL
1D) In my production app I also have a case (it's a larger document and more complex case that I can't 1:1 easily copy over to a REPL) where marking one of the
<View>
s withbreak={true}
also suddenly introduces the infinite loop hanging. Changing anywrap
orminPresenceAhead
props don't affect the outcome, yet changing some margins does (although I was not able to find a real pattern yet unfortunately). So I think it's not the implementation of wrap/minPresenceAhead per se but likely a more general flaw in the layout (splitting?) logic. I'll try to spend some more time somehow getting this into a REPL. My gut says that some certain composition of Views with certain paddings/margins (and/or page padding) is getting too large for the Page and then in the splitting logic it somehow falls into the infinite loop hole.2A) A more contrived Real-life scenario REPL with the minPresenceAhead issue
I removed any fancy logic, but kept a lot of styling on purpose so there's something more elaborate to test again when we're confirming a fix.
Thoughts
Interestingly in my hundreds (?) of manual tests I never saw this:
react-pdf/packages/layout/src/steps/resolvePagination.js
Line 44 in fab09cc
@carlobeltrame Does
react-pdf/packages/layout/src/node/shouldBreak.js
Line 29 in fab09cc
work recursively in a sense that the size and margin/paddings of child Texts of Views of Views are taken into accout? Also – is page size and padding taken into account for the bounding box of the flow? I am asking because of this comment:
react-pdf/packages/layout/src/node/shouldBreak.js
Line 38 in fab09cc
What I mean is, if the page has paddingBottom (green) and minPresenceAhead is within the canvas but inside the padding then maybe the following siblings are not taken into account correctly(?):
I understand that this GH issue might actually be multiple issues at once, but I have the feeling that there must be some general connection.
Desktop (please complete the following information):
The text was updated successfully, but these errors were encountered: