From a4a2760535949319f7540bdaf01b4bbe0f22656d Mon Sep 17 00:00:00 2001 From: Mahdi Ben Massoud Date: Mon, 20 Jul 2026 20:09:09 +0100 Subject: [PATCH] fix(marketing): detect Mac chip on homepage download button The hero "Download for macOS" button hardcoded arch: "arm64", so Intel Macs were handed an arm64 build that won't launch ("can't run on this Mac"). Detect Apple Silicon vs Intel via the WebGL GPU renderer, since navigator.userAgent reports "Intel" on both chip types. Fixes #4196 Co-Authored-By: Claude Opus 4.8 --- apps/marketing/src/pages/index.astro | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/apps/marketing/src/pages/index.astro b/apps/marketing/src/pages/index.astro index 9d1cfbdd125..aef9bb10f19 100644 --- a/apps/marketing/src/pages/index.astro +++ b/apps/marketing/src/pages/index.astro @@ -383,11 +383,31 @@ const mobileEndorsementRows = [ type Platform = { os: "mac" | "win" | "linux"; label: string; arch?: string }; + // navigator.userAgent reports "Intel Mac OS X" on both Intel and Apple Silicon + // Macs, so probe the GPU renderer instead: Apple Silicon exposes an "Apple" GPU. + function detectMacArch(): "arm64" | "x64" { + try { + const canvas = document.createElement("canvas"); + const gl = (canvas.getContext("webgl") || + canvas.getContext("experimental-webgl")) as WebGLRenderingContext | null; + const debugInfo = gl?.getExtension("WEBGL_debug_renderer_info"); + if (gl && debugInfo) { + const renderer = String(gl.getParameter(debugInfo.UNMASKED_RENDERER_WEBGL) ?? ""); + if (/apple/i.test(renderer)) return "arm64"; + if (/intel|amd|radeon|nvidia|geforce/i.test(renderer)) return "x64"; + } + } catch { + // fall through to the default below + } + // Most current Macs are Apple Silicon; default there when detection is inconclusive. + return "arm64"; + } + function detectPlatform(): Platform | null { const ua = navigator.userAgent; if (/Win/i.test(ua)) return { os: "win", label: "Download for Windows" }; if (/Mac/i.test(ua)) { - return { os: "mac", label: "Download for macOS", arch: "arm64" }; + return { os: "mac", label: "Download for macOS", arch: detectMacArch() }; } if (/Linux/i.test(ua)) return { os: "linux", label: "Download for Linux" }; return null;