Skip to content

htmlToImage.toPng Freezes in Firefox with Heavy DOM – Works Fine till Chrome 137 and Edge #536

@ashutosh-aneja

Description

@ashutosh-aneja

Expected Behavior
screenshot = await htmlToImage.toPng(element) should generate a screenshot smoothly across all major browsers including Firefox, Chrome, and Edge.

Current Behavior
On Firefox, when trying to generate a screenshot of a heavy DOM element, the process freezes the browser tab (sometimes indefinitely).

The same code works smoothly on Chrome and Edge.

Screenshot is eventually generated, but user experience is very poor due to the hanging UI.

Possible Solution
Look into performance optimizations when rendering large DOM trees in Firefox.

Consider offloading processing to a Web Worker or using incremental rendering (if possible).

A flag to batch/render in chunks, or break the DOM tree into manageable parts, might help.

Provide guidance or best practices for usage with large DOM elements in Firefox.

Steps To Reproduce
Use htmlToImage.toPng or htmlToImage.toJpeg on a large DOM element.

Run the code on Firefox (latest version).

Observe that the browser hangs during screenshot generation.

Try same in Chrome or Edge – works without any noticeable lag.

htmlToImage.toJpeg(element, { pixelRatio: 1, quality: 0.9 })
.then(dataUrl => {
observer.next({ homeScreenControl, dataUrl });
observer.complete();
});

No specific error — the browser tab simply becomes unresponsive until the image is generated.

I'm using this in a corporate production environment for generating user-facing screenshots.

For our customer base, Firefox is the default browser, so this issue is critical.

We’ve tested multiple options and configurations, but none solve the freezing behavior in Firefox.

Happy to share a simplified HTML structure if needed to reproduce.
Working on angular web app.

Your Environment
html-to-image: 1.11.11 (latest)

OS: Windows 10

Browser: Firefox 126.0 (Issue happens in all recent versions)

Working Fine On: Chrome 125.0, Edge 125.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions