Repository navigation
Bundle mPDF from the fork's gravitypdf-v6 branch to fix slow float layouts (6.18.0) - #1951
Merged
gravitypdf-bot merged 1 commit intoOct 26, 2026
Merged
Conversation
jakejackson1
marked this pull request as draft
October 26, 2026 04:14
1 of 2 tasks
gravitypdf-bot
force-pushed
the
fix/mpdf-prune-buried-floats-6.18.0
branch
from
October 26, 2026 05:28
7aac3d3 to
09dd06a
Compare
jakejackson1
marked this pull request as ready for review
October 26, 2026 05:28
… floats mPDF keeps every float it has closed in a document-wide list and rescans all of it each time it places a float, so a long layout of floated rows slows down quadratically. PDF for GravityView 2.0.0 stops pruning that list itself on Gravity PDF 6.18, because it expects 6.18 to bundle the fork's fix (GravityPDF/mpdf#9), but 6.18 bundled upstream mPDF. A 1,000-row directory PDF took 7.8 s instead of 1.9 s. GravityPDF/mpdf's gravitypdf-v6 branch is upstream mPDF's development HEAD (a981bb7b) plus the float pruning (GravityPDF/mpdf#819, from #9) and the Cache fix for writable directories is_writable() calls read-only (GravityPDF/mpdf#820, #708). Composer installs it from there, so the php-scoper patcher for the Cache fix is gone, and a future mPDF update brings both fixes along instead of failing the build. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
gravitypdf-bot
force-pushed
the
fix/mpdf-prune-buried-floats-6.18.0
branch
from
October 26, 2026 05:30
09dd06a to
508a9fd
Compare
2 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
mPDF keeps every float it has closed in a document-wide list, and rescans the whole list each time it places a float, so a long layout of floated rows slows down quadratically. PDF for GravityView 2.0.0 stops pruning that list itself on Gravity PDF 6.18+, because it expects 6.18 to bundle the mPDF fork's fix (GravityPDF/mpdf#9). 6.18 bundles upstream mPDF instead, so neither side prunes, and long directory PDFs slow down: 1,000 rows take 7.8 s instead of 1.9 s. 6.18 now bundles mPDF from the fork's new
gravitypdf-v6branch, which is upstream mPDF'sdevelopmentHEAD plus Gravity PDF's fixes:Mpdf::addFloatDiv()drops the float records a new float has buried, andTag\BlockTagrecords both of its floats through it.Cache::createBasePath()rejecting a writable network share thatis_writable()calls read-only (Cache rejects a writable directory when is_writable() gives a false negative (network storage) mpdf#708).composer.jsoninstallsmpdf/mpdfdev-gravitypdf-v6from the fork, and the lock pins2a88146a. No other package changes.Cache.phpfix is removed, since mPDF now carries it.Try it
composer install, thencomposer prefix.vendor_prefixed/mpdf/mpdf/src/Mpdf.phpnow hasaddFloatDiv(), andvendor_prefixed/mpdf/mpdf/src/Cache.phpno longer callsis_writable().Test plan
yarn test:php -- --filter 'Test_Mpdf|Test_Cache'vendor_prefixed/mpdf/mpdf/src/Mpdf.phpcontainsaddFloatDiv()More info
Benchmark (PHP 8.3), with rows of three floated cells streamed into one open container, as PDF for GravityView 2.0.0 writes a directory on 6.18 (its own pruning off):
The page counts are the same in every case. The benchmark was taken with the earlier scoper-patch version of this PR, which applied the same code as Drop float records the layout has already buried (v6) mpdf#819.
gravitypdf-v6ismpdf/mpdfdevelopmentata981bb7b(what RC1 locks) plus $this->data->template_fontdata_location no longer used #819 and Clear mPDF cache when font is deleted #820. mPDF's full suite (1,000 tests) passes on it on PHP 8.5, and the fork's CI (tests, snapshots, static analysis, coding standard) passes on the branch since Run CI on gravitypdf-v6 mpdf#821 turned it on.The
ServiceFactorypatcher stays: it points mPDF at Gravity PDF's ownCacheclass.Tests:
test_dropping_buried_floats_leaves_the_pages_unchangedwrites 50 rows with and without pruning and compares the page content streams, as mpdf#9's own tests do.test_floats_buried_by_a_new_float_are_droppedfails if the bundled mPDF doesn't prune: 150 float records instead of 3. That catches a latercomposer updatethat loses the fork's fix.composer install/composer prefixhaven't been run locally for the fork switch. This PR's CI builds and tests it.On a test site with the earlier build's mPDF, PDF for GravityView 2.0.0's single and directory PDFs for six Views have the same page counts as on RC1. A directory PDF with signed shortcodes still signs all 16 row links.
This is for 6.18.0 only, with no
developmentPR.developmentstill locks upstreammpdf/mpdfand will move to the fork with 7.0.Adds a CHANGELOG line, because it also speeds up any long float layout in a custom template.
🤖 Generated with AI