Skip to content

AI-native design editor. Open-source Figma alternative.

fix(shaders): never save blank frames, and deploy docs on published releases (#1206)

Danila Poyarkove6dbaa5b84d9
diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml
index c3e22d1be..fbec1651a 100644
--- a/.github/workflows/docs.yml
+++ b/.github/workflows/docs.yml
@@ -1,10 +1,10 @@
name: Deploy docs
on:
- push:
- tags:
- - "v*"
- - "!v*-*"
+ # The download page reads GitHub's releases when the site is built, so the docs deploy when a
+ # release is published, not when its tag is pushed and the release is still a draft.
+ release:
+ types: [published]
workflow_dispatch:
inputs:
dry-run:
@@ -42,7 +42,7 @@ jobs:
name: landing-posters
path: packages/docs/.vitepress/dist/landing-posters
- # A tag push has no inputs, so it always deploys.
+ # A published release has no inputs, so it always deploys.
- uses: cloudflare/wrangler-action@v4
if: ${{ !inputs.dry-run }}
with:
diff --git a/changes/1206/fixed.md b/changes/1206/fixed.md
new file mode 100644
index 000000000..c10cb496e
--- /dev/null
+++ b/changes/1206/fixed.md
@@ -0,0 +1 @@
+- Shader covers on openpencil.dev and in the `/demo` tour show their first frame instead of a blank square, and the editor keeps a shader's saved frame instead of replacing it with a blank one in a browser whose WebGPU cannot draw.
diff --git a/packages/vue/src/canvas/surface/shader/rasterizer.ts b/packages/vue/src/canvas/surface/shader/rasterizer.ts
index 24cea14bc..1d5748db8 100644
--- a/packages/vue/src/canvas/surface/shader/rasterizer.ts
+++ b/packages/vue/src/canvas/surface/shader/rasterizer.ts
@@ -54,6 +54,9 @@ export function createShaderRasterizer(): ShaderRasterizer | null {
// pipelines, so the one kept is the second; reading the canvas waits for the GPU.
await renderer.renderFrame({ deltaSeconds: 0, waitForGpu: false })
await renderer.renderFrame({ deltaSeconds: 0, waitForGpu: false })
+ // Without a usable GPU the renderer draws nothing and says so only here; keeping that
+ // empty canvas would save a blank frame over the paint's own.
+ if (renderer.getFailureReason() !== null) return null
const blob = await encodeFrame(canvas)
if (isDestroyed() || !blob) return null
const bytes = new Uint8Array(await blob.arrayBuffer())
diff --git a/tools/AGENTS.md b/tools/AGENTS.md
index c4d519e3a..5e8e0066c 100644
--- a/tools/AGENTS.md
+++ b/tools/AGENTS.md
@@ -23,7 +23,7 @@ Private tooling lives under `tools/<role>/<domain>/{src,tests}`; Steiger enforce
- `tools/ci/policy` runs right after Bun is set up, before any install, so it imports only Node built-ins; `oxlint.json` switches `open-pencil/prefer-es-toolkit` off there. Other CI tools install their workspace first, as `pr-review-guidance.yml` does through `.github/actions/setup-bun`.
- Required checks must also run on `merge_group`, the merge queue's event; read base and head from `merge_group.base_sha`/`head_sha` there (`ci.yml`, `pr-title.yml`).
- A passing pull request run records the tree it tested as the `CI verified tree` status on the PR head; a merge queue commit with that exact tree is classified `verified` and runs only the always-on checks. Any other tree, including a group with other PRs ahead, gets the full run (`tools/ci/policy/src/verified-tree/`).
-- App and docs production workflows run on `v*` tags or `workflow_dispatch`, not ordinary `master` pushes. `build.yml` checks the tooling out under `.pipeline/` and runs `tools/release/release-packages` from there.
+- The app production workflow runs on `v*` tags, and the docs workflow when a release is published, since the download page reads GitHub's releases at build time; both also run on `workflow_dispatch`, never on ordinary `master` pushes. `build.yml` checks the tooling out under `.pipeline/` and runs `tools/release/release-packages` from there.
## Releases
diff --git a/tools/generate/demo/src/shaders/page.ts b/tools/generate/demo/src/shaders/page.ts
index 770a6e701..4c821db72 100644
--- a/tools/generate/demo/src/shaders/page.ts
+++ b/tools/generate/demo/src/shaders/page.ts
@@ -22,6 +22,9 @@ const page: ShaderStillPage = {
// The first frame only prepares the effects' pipelines; the second is the still.
await renderer.renderFrame({ deltaSeconds: 0, waitForGpu: false })
await renderer.renderFrame({ deltaSeconds: 0, waitForGpu: false })
+ // Without a usable GPU the renderer draws nothing and says so only here.
+ const failure = renderer.getFailureReason()
+ if (failure !== null) throw new Error(`WebGPU is unavailable (${failure})`)
// A WebGPU canvas has no pixels to read; a 2D copy does.
const copy = document.createElement('canvas')
copy.width = canvas.width
diff --git a/tools/generate/demo/src/shaders/stills.ts b/tools/generate/demo/src/shaders/stills.ts
index 2888acea8..d6f3fbfe1 100644
--- a/tools/generate/demo/src/shaders/stills.ts
+++ b/tools/generate/demo/src/shaders/stills.ts
@@ -16,11 +16,18 @@ import {
import type { ShaderStillPage } from './page'
-/** Headless Chromium has WebGPU only with SwiftShader, and only on a secure origin. */
+/**
+ * Headless Chromium has WebGPU only with SwiftShader, and only on a secure origin. On Linux,
+ * where the deploy and preview workflows build the demo, WebGPU also needs Vulkan, served by
+ * SwiftShader since the runners have no GPU.
+ */
const BROWSER_ARGS = [
'--enable-unsafe-webgpu',
'--use-angle=swiftshader',
- '--enable-unsafe-swiftshader'
+ '--enable-unsafe-swiftshader',
+ ...(process.platform === 'linux'
+ ? ['--enable-features=Vulkan', '--use-vulkan=swiftshader', '--use-webgpu-adapter=swiftshader']
+ : [])
]
interface Job {