Skip to content

fix(paginate): split columns whose children lie past 2^15 pt - #3584

Open
exoego wants to merge 2 commits into
diegomura:masterfrom
exoego:fix/paginate-float32-overlap
Open

exoego wants to merge 2 commits into
diegomura:masterfrom
exoego:fix/paginate-float32-overlap

Conversation

@exoego

@exoego exoego commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

With experimentalPagination, a View stops splitting once its content goes past 2^15 pt (32,768 pt, about 44 A4 pages). All remaining children are drawn on one page, on top of each other. The legacy engine is fine. I hit this in a real app, where a 50-page report came out as 2 pages.

const HEIGHTS = [60.096, 47.064, 117.16];

<Page size="A4" experimentalPagination>
  <View>
    {Array.from({ length: 450 }, (_, i) => (
      <View key={i} style={{ height: HEIGHTS[i % 3], borderBottom: '1pt solid black' }} />
    ))}
  </View>
</Page>
rows legacy eingine new engine new engine + this PR
400 36 36 36
450 40 1 40
600 54 1 54
3000 267 1 267

isWrapped in toItems.ts treats a column whose siblings overlap by more than 0.001 pt as a wrapped one, and keeps it whole. Yoga lays out in float32, so past 2^15 pt a position is only exact to 1/256 pt. Rounding alone makes touching siblings overlap by about 0.0015 pt. Example: a child at 32,928.015625 with height 47.064 ends at 32,975.0796, but the next child starts at 32,975.078125.

The tolerance now grows with the position (twice the float32 step, at least 0.001 pt). A real wrapped column jumps back by hundreds of points, so it is still detected.

The first commit adds a snapshot test that records the broken output (every row on one page). The second commit fixes it, and the snapshot changes to the split pages.

exoego added 2 commits October 7, 2026 10:45
…w engine

The snapshot records the current, broken output. The new engine does not
split the view, so every row is drawn on one page over the header.
Yoga lays out in float32. Past 2^15 pt a position is only exact to about
1/256 pt, so rounding alone can make touching siblings overlap by more than
the fixed 0.001 pt tolerance. The column was then treated as wrapped and
became one unsplittable leaf. Scale the tolerance with the position.
@changeset-bot

changeset-bot Bot commented Oct 7, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 9233272

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 7 packages
Name Type
@react-pdf/paginate Patch
@react-pdf/layout Patch
@react-pdf/renderer Patch
@react-pdf/examples Patch
@react-pdf/math Patch
@react-pdf/mermaid Patch
@react-pdf/ui Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel

vercel Bot commented Oct 7, 2026

Copy link
Copy Markdown

@exoego is attempting to deploy a commit to the diegomura Team on Vercel.

A member of the Team first needs to authorize it.

This branch has not been deployed

No deployments
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.

1 participant