Robust Chrome rendering: persistent session, deterministic font wait, data: URLs - #26
Merged
Conversation
… wait, data: URLs) Rework the chromote-based conversion pipeline inspired by production HTML-to-PDF services: - Deterministic readiness: wait for the page load event and document.fonts.ready instead of fixed Sys.sleep() calls, so captures never happen before web fonts render and never over-wait. New `timeout` argument (default 10s); `load_wait` now means extra wait after readiness and defaults to 0. - Persistent Chrome session: a single health-checked ChromoteSession is reused across calls and replaced transparently when dead, removing the ~1-2s session startup per conversion. Closed in .onUnload. - No temp files: pages load via data: URLs (temp file only for very large documents), avoiding file:// path issues on Windows. - Real alpha transparency: background = "transparent" now yields a PNG with a true alpha channel via Emulation.setDefaultBackgroundColorOverride. Adds tests for the new helpers (Chrome tests skipped on CRAN). R CMD check --as-cran: 0 errors, 0 warnings, 0 notes. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The wrapper HTML declares charset=utf-8, so the base64-encoded bytes must be UTF-8 regardless of the session's native encoding (relevant on Windows with R < 4.2). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
Reworks the chromote-based conversion pipeline (
svg_to_png_chrome(),svg_to_pdf_chrome(),batch_svg_to_*_chrome()) with robustness patterns from production HTML→PDF services:Changes
document.fonts.readyinstead of a fixedSys.sleep(). Captures never happen before web fonts render, and no time is wasted over-waiting. Newtimeoutargument (default 10s);load_waitnow means extra wait after readiness and defaults to 0.ChromoteSessionis reused across calls and replaced transparently when dead (self-healing), removing the ~1–2s startup per conversion. Closed in.onUnload.data:URLs (temp file fallback only for very large documents), avoidingfile://path/permission issues on Windows.background = "transparent"now yields a PNG with a true alpha channel.Validation
tests/testthat/test-chrome.R(pure helpers everywhere; rendering testsskip_on_cran()). Suite: 102 passing.R CMD check --as-cran: 0 errors, 0 warnings, 0 notes.Part of the 0.2.5 CRAN submission.
🤖 Generated with Claude Code