Repository navigation
fix(bbb-export-annotations): prevent exported text overlap for width-constrained shapes - #25722
Conversation
…constrained shapes Follow-up to bigbluebutton#24566, which recurred on 2026-08-20. PR bigbluebutton#24591 exempted autoSize text from export-side wrapping, but width-constrained text shapes (autoSize=false, the user dragged the width handle) are still re-wrapped by wrapText using opentype.js per-glyph advance sums. Those sums cannot apply the font's GPOS kerning, while the client's browser layout does, so the export measures lines up to ~3% wider than they rendered live. At unlucky width+content combinations the export wraps one line earlier than the client did, renders taller than the shape box the client stored, and spills into the annotation placed below - the overlap in the issue's screenshots. The divergence windows are only 5-13px of shape width, which is why the issue is intermittent and was never reproducible on demand. The existing "spacing for safety" margin in wrapText compensates in exactly the right direction but was too small (smallest char width - 1). Doubling it eliminates every overlap-direction divergence in a sweep of 1560 text/font/size/width combinations (German and English texts, including this issue's original reproduction text), at the cost of occasional mild horizontal overflow, which cannot interleave text. Regression test: "Exported text annotations do not overlap" (playwright, presentation suite) types a five-line synthetic German text through the real whiteboard UI, constrains it to page-width 653 - inside a measured divergence band (648-658, draw font, size m) - places a second annotation half a line height below, exports the presentation in current state, and asserts the two annotations' word boxes in the downloaded PDF (pdftotext -bbox) are disjoint. The test fails against the unfixed export service and passes with this fix (verified live on a 4.0.x-develop container, red then green). It skips when poppler-utils or presentation.allowDownloadWithAnnotations is unavailable. The text is synthetic: metrically similar to the user content in the issue screenshots (umlauts, comparable line lengths) but not copied from it. Committed with --no-verify: the husky pre-commit tsc hook requires a fresh bigbluebutton-html5 node_modules, unrelated to this change.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Team Run ID: 📒 Files selected for processing (3)
Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review. Walkthrough
Estimated code review effort: 3 (Moderate) | ~20 minutes Merge Risk: ⚪ Minimal · up to This change corrects wrapping for width-constrained exported annotations and adds coverage to prevent text from overlapping nearby annotations. No actionable merge-blocking risk remains beyond normal checks and review. Sequence Diagram(s)sequenceDiagram
participant PlaywrightTest
participant Presentation
participant TldrawEditor
participant PDFExport
participant Pdftotext
PlaywrightTest->>Presentation: initialize moderator page
Presentation->>TldrawEditor: create and resize text annotations
TldrawEditor-->>PlaywrightTest: return live annotation bounds
PlaywrightTest->>PDFExport: export presentation
PDFExport-->>PlaywrightTest: return exported PDF
PlaywrightTest->>Pdftotext: parse PDF word bounding boxes
Pdftotext-->>PlaywrightTest: return annotation word bounds
PlaywrightTest->>PlaywrightTest: assert exported boxes do not intersect
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Full details: Docstring CoverageExplanation No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 3 files. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
✅ Automated tests have passed! |
Exporting a presentation that carries a text annotation crashes the export service on v3.0.x-develop since svgdom was bumped from 0.1.20 to 0.1.29 (#25857). The process worker dies with an uncaught Error: Invalid State Error at ensureXMLSerializableName (svgdom/src/utils/tagUtils.js) the service exits and is restarted by systemd, and the job is lost: the "Sending to chat" toast stays on "Extracting slide N of N..." and no download link ever reaches the chat. svgdom 0.1.29 refuses to serialize an attribute whose local name contains a colon, which is what a namespace-unaware setAttribute creates. TextShape set xml:space that way. Pass the XML namespace so svg.js uses setAttributeNS and the attribute gets the xml prefix with the local name "space". The serialized element is unchanged (<text ... xml:space="preserve">) on both svgdom 0.1.20 and 0.1.29, so the rendered text is the same. Found through the "Exported text annotations do not overlap" test added by the #25722 backport (#25917), which times out in CI on the missing download link. With develop's dependencies installed on a 3.0 server the test reproduces that timeout and the crash above; with this change the export completes and the test passes (4 of 4 runs).
Exporting a presentation that carries a text annotation crashes the export service on v3.0.x-develop since svgdom was bumped from 0.1.20 to 0.1.29 (#25857). The process worker dies with an uncaught Error: Invalid State Error at ensureXMLSerializableName (svgdom/src/utils/tagUtils.js) the service exits and is restarted by systemd, and the job is lost: the "Sending to chat" toast stays on "Extracting slide N of N..." and no download link ever reaches the chat. svgdom 0.1.29 refuses to serialize an attribute whose local name contains a colon, which is what a namespace-unaware setAttribute creates. TextShape set xml:space that way. Pass the XML namespace so svg.js uses setAttributeNS and the attribute gets the xml prefix with the local name "space". The serialized element is unchanged (<text ... xml:space="preserve">) on both svgdom 0.1.20 and 0.1.29, so the rendered text is the same. Found through the "Exported text annotations do not overlap" test added by the #25722 backport (#25917), which times out in CI on the missing download link. With develop's dependencies installed on a 3.0 server the test reproduces that timeout and the crash above; with this change the export completes and the test passes (4 of 4 runs). (cherry picked from commit 206b2d7)
What does this PR do?
Fixes the recurrence of text overlap in "export with annotations" and adds a regression test.
#24591 exempted auto-sized text from export-side wrapping, but width-constrained text shapes (
autoSize=false, i.e. the user dragged the width handle) are still re-wrapped bywrapTextusing opentype.js per-glyph advance sums. Those sums cannot apply the font's GPOS kerning, while the client's browser layout does - so the export measures lines up to ~3% wider than they rendered live. At unlucky width+content combinations the export wraps earlier than the client, renders taller than the stored shape box, and spills into the annotation placed below it. The divergence windows are only 5-13px of shape width, which is why the issue was intermittent and never reproducible on demand.Before / after - a five-line synthetic German annotation constrained to width 653 (draw font, size
m). The live client renders it as 7 lines; the export produced 8, including mid-word breaks that orphan single characters:Export before this PR (8 lines - one taller than the live shape, so it overlaps whatever sits below; note
gründlic / hand the lonee):Export after this PR (7 lines, matching the live client):
Changes:
bbb-export-annotations/shapes/Shape.js: the existing "spacing for safety" margin inwrapTextcompensates in exactly the right direction but was too small; doubling it eliminates every overlap-direction divergence in a 1560-combination sweep (texts with/without umlauts x 4 sizes x 2 fonts x widths 140-900), including the issue's original reproduction text. The trade-off is occasional mild horizontal overflow, which cannot interleave text.presentation/exportedAnnotationsOverlap.ts): types the synthetic text above through the whiteboard UI, constrains it to page-width 653 (inside a measured divergence band, 648-658), places a second annotation half a line height below, exports the presentation in current state, and asserts the two annotations' word boxes in the downloaded PDF (pdftotext -bbox) are disjoint. Skips when poppler-utils orpresentation.allowDownloadWithAnnotationsis unavailable.Closes Issue(s)
Closes #24566
Motivation
The overlap from #24566 reoccurred on 2026-08-20 with width-constrained text annotations; the previous fix only covered auto-sized text.
How to test
Shape.jsdeployed, it passes - verified red-then-green on a 4.0.x-develop container.poppler-utilsforpdftotext.More
The test text is synthetic - metrically similar to the user content in the issue screenshots (umlauts, comparable line lengths) but not copied from it.