Skip to content

fix: graceful WebGL fallback for Firefox/Linux blank page#1

Open
ibarrajo wants to merge 2 commits intomainfrom
fix/webgl-firefox-blank-page
Open

fix: graceful WebGL fallback for Firefox/Linux blank page#1
ibarrajo wants to merge 2 commits intomainfrom
fix/webgl-firefox-blank-page

Conversation

@ibarrajo
Copy link
Owner

@ibarrajo ibarrajo commented Mar 2, 2026

Problem

On Firefox/Linux (e.g. Fedora) with missing or incompatible GPU drivers, the site rendered a completely blank page. The browser console showed:

Uncaught Error: Failed to initialize WebGL

Both landing-map.web.tsx and map-view.web.tsx called new mapboxgl.Map() inside useEffect with no mapboxgl.supported() check and no try/catch. When WebGL initialization fails, the Map constructor throws an uncaught error that crashes the entire React app before it can mount.

Fix

  • Check mapboxgl.supported({ failIfMajorPerformanceCaveat: false }) before constructing the map instance; set error state if WebGL is unavailable
  • Wrap new mapboxgl.Map() in try/catch as a secondary safety net
  • Show a graceful fallback UI with a user-friendly message (map.webglUnavailable) instead of crashing
  • Switched cleanup in both components to use mapRef.current?.remove() (safer, consistent)
  • Added map.webglUnavailable i18n key in en.json and es.json

Test plan

  • Verify site loads normally on Chrome/macOS (no regression)
  • Verify site loads normally on Firefox/macOS (no regression)
  • On Firefox/Linux or any browser with WebGL disabled (about:configwebgl.disabled = true): confirm the map section shows the fallback message instead of a blank page
  • Confirm the rest of the landing page (hero, stats, case list) renders correctly even when the map fallback is shown

🤖 Generated with Claude Code

ibarrajo and others added 2 commits March 2, 2026 15:41
…hen WebGL unavailable

Both landing-map.web.tsx and map-view.web.tsx called `new mapboxgl.Map()`
inside useEffect with no try/catch and no mapboxgl.supported() check.
On Firefox/Linux with missing or incompatible GPU drivers, the Map constructor
throws "Failed to initialize WebGL", which propagates as an uncaught error
and crashes the React app before it can mount — resulting in a completely
blank page.

Fix:
- Check mapboxgl.supported({ failIfMajorPerformanceCaveat: false }) before
  constructing the map; set error/webglUnavailable state if false
- Wrap `new mapboxgl.Map()` in try/catch as a second safety net
- Show a graceful fallback UI with a user-friendly message instead of crashing
- Add map.webglUnavailable i18n key in en.json and es.json

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
When WebGL fails, both the landing map and main map now show a Mapbox
Static Images API tile of Tijuana instead of a blank placeholder, with
a semi-transparent banner explaining WebGL is unavailable and a link
to get.webgl.org/troubleshooting/ for browser-specific help.

- landing-map: static 800x400 image + bottom banner + troubleshoot link
- map-view: static 1280x720 image + centered overlay banner + link
- i18n: split webglUnavailable into short description + webglTroubleshoot
  link key; Spanish version notes the link is in English

Static Images API: 50k free requests/month; URL is deterministic so
browser/CDN cache handles repeat views at no cost.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.

1 participant