fix(marketing): never serve the Intel build to Apple Silicon Macs (#7477)
Co-authored-by: Claude Fable 5 <[email protected]>
This commit is contained in:
1 parent
3b8e7bbbe0
commit
67e2fe71d9
4 files changed
+30
-69
No files matched your search
@@ -1,23 +0,0 @@
|
||||
import { describe, expect, it } from "vite-plus/test";
|
||||
|
||||
import { macArchFromGpuRenderer } from "./macArch";
|
||||
|
||||
describe("macArchFromGpuRenderer", () => {
|
||||
it("detects explicit Apple Silicon renderers", () => {
|
||||
expect(macArchFromGpuRenderer("Apple M4 Pro")).toBe("arm64");
|
||||
});
|
||||
|
||||
it("prefers an Intel GPU marker even when the renderer also mentions Apple", () => {
|
||||
expect(macArchFromGpuRenderer("ANGLE Metal Renderer: Apple, Intel Iris Plus Graphics")).toBe(
|
||||
"x64",
|
||||
);
|
||||
});
|
||||
|
||||
it("detects Safari's generic Apple Silicon renderer", () => {
|
||||
expect(macArchFromGpuRenderer("Apple GPU")).toBe("arm64");
|
||||
});
|
||||
|
||||
it("uses x64 when the renderer is unavailable", () => {
|
||||
expect(macArchFromGpuRenderer("")).toBe("x64");
|
||||
});
|
||||
});
|
||||
@@ -1,14 +0,0 @@
|
||||
const INTEL_GPU_PATTERN = /intel|amd|radeon|nvidia|geforce/i;
|
||||
const APPLE_SILICON_GPU_PATTERN = /\bapple\s+(?:m\d|gpu)\b/i;
|
||||
|
||||
export function macArchFromGpuRenderer(renderer: string): "arm64" | "x64" {
|
||||
if (INTEL_GPU_PATTERN.test(renderer)) {
|
||||
return "x64";
|
||||
}
|
||||
if (APPLE_SILICON_GPU_PATTERN.test(renderer)) {
|
||||
return "arm64";
|
||||
}
|
||||
|
||||
// Keep the fallback compatible with Intel Macs when WebGL is unavailable.
|
||||
return "x64";
|
||||
}
|
||||
@@ -24,11 +24,10 @@ import { ANDROID_PLAY_STORE_URL, IOS_APP_STORE_URL } from "../lib/site";
|
||||
<span class="card-arch">Apple Silicon (arm64)</span>
|
||||
<span class="card-format">.dmg</span>
|
||||
</a>
|
||||
<a class="download-card" data-asset="x64.dmg" href={RELEASES_URL}>
|
||||
<span class="card-arch">Intel (x64)</span>
|
||||
<span class="card-format">.dmg</span>
|
||||
</a>
|
||||
</div>
|
||||
<p class="intel-note">
|
||||
On an Intel Mac? <a data-asset="x64.dmg" href={RELEASES_URL}>Download the x64 build</a>.
|
||||
</p>
|
||||
</section>
|
||||
|
||||
<!-- Windows -->
|
||||
@@ -92,8 +91,8 @@ import { ANDROID_PLAY_STORE_URL, IOS_APP_STORE_URL } from "../lib/site";
|
||||
|
||||
async function init() {
|
||||
const versionLabel = document.getElementById("version-label");
|
||||
// Only release-asset cards; mobile store cards have no data-asset and keep their href.
|
||||
const cards = document.querySelectorAll<HTMLAnchorElement>(".download-card[data-asset]");
|
||||
// Only release-asset links; mobile store cards have no data-asset and keep their href.
|
||||
const cards = document.querySelectorAll<HTMLAnchorElement>("a[data-asset]");
|
||||
|
||||
try {
|
||||
const release = await fetchLatestRelease();
|
||||
@@ -257,6 +256,24 @@ import { ANDROID_PLAY_STORE_URL, IOS_APP_STORE_URL } from "../lib/site";
|
||||
color: var(--fg-dim);
|
||||
}
|
||||
|
||||
.intel-note {
|
||||
font-size: 0.8rem;
|
||||
color: var(--fg-dim);
|
||||
}
|
||||
|
||||
.intel-note a {
|
||||
color: var(--fg-muted);
|
||||
text-decoration: underline;
|
||||
text-decoration-color: rgba(161, 161, 170, 0.4);
|
||||
text-underline-offset: 3px;
|
||||
transition: color 0.3s ease, text-decoration-color 0.3s ease;
|
||||
}
|
||||
|
||||
.intel-note a:hover {
|
||||
color: var(--fg);
|
||||
text-decoration-color: var(--fg);
|
||||
}
|
||||
|
||||
/* ── Releases link ── */
|
||||
|
||||
.releases-link {
|
||||
|
||||
@@ -391,46 +391,27 @@ const mobileEndorsementRows = [
|
||||
|
||||
<script>
|
||||
import { fetchLatestRelease, RELEASES_URL, type ReleaseAsset } from "../lib/releases";
|
||||
import { macArchFromGpuRenderer } from "../lib/macArch";
|
||||
|
||||
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) ?? "");
|
||||
return macArchFromGpuRenderer(renderer);
|
||||
}
|
||||
} catch {
|
||||
// fall through to the default below
|
||||
}
|
||||
return macArchFromGpuRenderer("");
|
||||
}
|
||||
type Platform = { os: "mac" | "win" | "linux"; label: string };
|
||||
|
||||
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: detectMacArch() };
|
||||
}
|
||||
if (/Mac/i.test(ua)) return { os: "mac", label: "Download for macOS" };
|
||||
if (/Linux/i.test(ua)) return { os: "linux", label: "Download for Linux" };
|
||||
return null;
|
||||
}
|
||||
|
||||
// Macs always get the arm64 build. Browsers cannot reliably tell Apple Silicon
|
||||
// from Intel (the UA lies, GPU strings lie), and a wrong guess hands an Apple
|
||||
// Silicon user a broken app. Intel users pick their build on /download.
|
||||
// Do NOT add arch detection back here.
|
||||
function pickAsset(assets: ReleaseAsset[], platform: Platform): string | null {
|
||||
if (platform.os === "win") {
|
||||
return assets.find((a) => a.name.endsWith("-x64.exe"))?.browser_download_url ?? null;
|
||||
}
|
||||
if (platform.os === "mac") {
|
||||
const preferred = assets.find((a) => a.name.endsWith(`-${platform.arch}.dmg`));
|
||||
const fallback = assets.find((a) => a.name.endsWith(".dmg"));
|
||||
return (preferred ?? fallback)?.browser_download_url ?? null;
|
||||
return assets.find((a) => a.name.endsWith("-arm64.dmg"))?.browser_download_url ?? null;
|
||||
}
|
||||
if (platform.os === "linux") {
|
||||
return assets.find((a) => a.name.endsWith(".AppImage"))?.browser_download_url ?? null;
|
||||
|
||||
Reference in new issue
Block a user