Skip to content

Fix download button not working on Linux browsers#102

Open
labradorite-dev wants to merge 4 commits intoTechForPalestine:mainfrom
labradorite-dev:fix/download-button-linux-browsers
Open

Fix download button not working on Linux browsers#102
labradorite-dev wants to merge 4 commits intoTechForPalestine:mainfrom
labradorite-dev:fix/download-button-linux-browsers

Conversation

@labradorite-dev
Copy link
Copy Markdown

@labradorite-dev labradorite-dev commented Jan 4, 2026

Summary

Fixes #82 - Download button not working on Linux browsers (Firefox, Chromium, GNOME Web)

This PR replaces the html-to-image library with html2canvas to fix compatibility issues with Linux browsers and adds comprehensive cross-browser testing.

Problem

The html-to-image library has well-documented compatibility issues with Firefox and Linux browsers:

The current implementation used a workaround of calling generateImage() 4 times, but this still failed for users on Firefox/Chromium/GNOME Web on Linux systems.

Solution

Replace html-to-image with html2canvas, which was already installed as a project dependency. This avoids adding new dependencies while solving the compatibility issues.

Changes Made

1. Fixed Download Functionality (src/app/page.tsx)

  • Replaced html-to-image (toPng) with html2canvas (already in package.json)
  • Added image preloading verification before capture
  • Configured html2canvas with proper CORS settings:
    • useCORS: true - enables cross-origin image handling
    • allowTaint: true - allows cross-origin images
    • scale: 2 - increases output quality
  • Removed hacky workaround of calling generateImage() 4 times
  • Added proper error handling with user-facing feedback

2. Added Playwright E2E Tests

  • Created comprehensive cross-browser test suite
  • Tests verify download functionality across:
    • Chromium (Chrome, Edge, etc.)
    • Firefox (where the bug was originally reported)
    • WebKit (Safari)
  • Validates:
    • Download button successfully triggers a download
    • Downloaded file is a valid PNG image
    • Proper error handling when no image is uploaded
    • html2canvas integration works correctly

3. Added GitHub Actions CI

  • Automated cross-browser testing on every PR
  • Runs tests in parallel across all three browser engines
  • Uploads test reports as artifacts for debugging failures

4. Updated Documentation

  • Added Testing section to README with instructions for running tests locally

Test Results

All 9 tests pass across all three browser engines ✅

Running 9 tests using 5 workers
  9 passed (13.7s)

Test Plan

  • Run Playwright tests on Chromium, Firefox, and WebKit
  • Verify download works with uploaded images
  • Verify download works with external profile pictures (GitHub, Twitter, etc.)
  • Verify error handling when no image is uploaded
  • Build succeeds with no TypeScript errors

Technical Details

Since html2canvas was already listed in package.json as a dependency, we leveraged it instead of adding a new library. With proper CORS configuration (useCORS and allowTaint), the download feature now works reliably across all platforms and browsers, eliminating the Firefox and Linux compatibility issues present in html-to-image.

Replace html-to-image library with html2canvas to fix compatibility
issues with Linux browsers (Firefox, Chromium, GNOME Web).

Changes:
- Replace toPng from html-to-image with html2canvas
- Add image preloading verification before capture
- Configure html2canvas with useCORS and allowTaint for cross-origin images
- Increase output quality with scale: 2
- Remove hacky workaround of calling generateImage() 4 times
- Add proper error handling with user-facing feedback

Fixes TechForPalestine#82
Add comprehensive cross-browser testing infrastructure using Playwright
to verify the download button works correctly across major browsers.

Test coverage:
- Chromium (Chrome, Edge, etc.)
- Firefox (where the bug was originally reported)
- WebKit (Safari)

The tests verify:
- Download button successfully triggers a download
- Downloaded file is a valid PNG image
- Proper error handling when no image is uploaded
- html2canvas integration works correctly

All tests pass across all three browser engines.
Add CI workflow that runs on PRs and pushes to main:

- Runs Playwright E2E tests across Chromium, Firefox, and WebKit in parallel
- Uploads test reports as artifacts for 30 days when tests fail
- Uses efficient dependency caching with npm ci
- Ensures all code merged to main is validated and tested

This automates cross-browser testing to prevent regressions.
Add documentation for running Playwright tests with instructions for:
- Running the full test suite
- Running tests in headed mode to watch browsers
- Running tests in UI mode for interactive debugging

This helps contributors understand how to validate their changes.
@labradorite-dev labradorite-dev force-pushed the fix/download-button-linux-browsers branch from 89768cf to e51d453 Compare January 4, 2026 15:36
Comment thread src/app/page.tsx
Comment on lines +108 to +112
const canvas = await html2canvas(ref.current, {
useCORS: true,
allowTaint: true,
scale: 2,
});
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

html2canvas Configuration

useCORS: true - Enables Cross-Origin Resource Sharing for loading external images. Critical because profile pictures come from Twitter, GitHub, GitLab, etc. Without this, browsers block cross-origin images.

allowTaint: true - Allows canvas to be "tainted" by cross-origin data. Necessary trade-off since we're only using the image for local download, not sending it anywhere.

scale: 2 - Renders at 2x resolution (e.g., 300x300 → 600x600 PNG) for sharper images on high-DPI displays and social media.

@labradorite-dev labradorite-dev marked this pull request as ready for review January 4, 2026 15:52
@labradorite-dev
Copy link
Copy Markdown
Author

@h4p-t4p, can I get a look at this PR?

@zoeyAhmed
Copy link
Copy Markdown

zoeyAhmed commented Jan 4, 2026

I can confirm with both GNOME Web and Chromium on GNOME-OS, using a local image, the edited image downloads fine, From my stance, this fixes my original issue 💜

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Download button does not download the image.

2 participants