Kroki-rs implements a native Rust browser engine strategy to eliminate the dependency on Node.js and external Puppeteer/Playwright CLI wrappers.
Native Browser Strategy¶
We use the headless_chrome crate to communicate directly with Chromium via the DevTools Protocol (CDP).
Performance: Zero-latency evaluation via pre-warmed tabs.
Security: Strict process isolation and memory limits.
Simplicity: No Node.js or
npmrequired in the runtime environment.
The Browser Manager¶
The BrowserManager orchestrates the lifecycle of the Chromium instance:
Tab Pooling: A pool of pre-warmed tabs is maintained to handle bursts of diagram requests.
Harness Evaluation: Diagrams are rendered using a specialized
browser-harness.jsthat loads the required JS libraries (Mermaid, BPMN, etc.) from local resources.Adaptive Recycling: Tabs are gracefully recycled after a fixed number of requests to prevent memory accumulation.
Font Management¶
Consistent font rendering is achieved by:
Packaging core fonts (Inter, Roboto) in the Docker image.
Mounting system font directories into the container.
Configuring
fontconfigto prioritize these paths.