rinohtype icon indicating copy to clipboard operation
rinohtype copied to clipboard

rinohtype enters infinite loop when rendering a tall image

Open alexfargus opened this issue 4 years ago • 4 comments

Trying to render the following .rst with the attached image triggers an infinite loop. I have verified that this issue exists on master.

.. figure:: ./loop.png
    :width: 80%

    This figure triggers an infinite loop while rendering.

loop

I believe that the issue is caused by some combination of the width attribute and the dimensions of the image file. Removing the attribute or changing the image dimensions will work around the issue.

I have tried to find the root cause, but I am having trouble following the rendering logic.

@brechtm can you suggest any tips for figuring out what is going wrong?

alexfargus avatar Aug 23 '21 19:08 alexfargus

When the image is scaled to 80% of the width, it's height is too large to fit on the page, and rinohtype moves it to the next page where the same thing happens. We need to check whether the image is the first flowable on the page. If it is, we should always place it, even if it exceeds the available height. You can use container.page._empty for this, which is set to False as soon as a flowable has been placed on the page.

brechtm avatar Aug 25 '21 16:08 brechtm

Something similar happens with inline images if they don't fit in the available width (or height, probably).

brechtm avatar Aug 25 '21 16:08 brechtm

@brechtm We had the same issue already several times.

fdeprey avatar Feb 11 '22 17:02 fdeprey

I had another look at this. This is already handled for images, but not for figures. That possibly requires some redesign, so it might take a while...

brechtm avatar Mar 09 '22 14:03 brechtm