Skip to content

[bugfix] canvas: preserve PNG transparency over other nodes - #667

Merged
FayeSpica merged 1 commit into
ThinkFlowLab:mainfrom
FayeSpica:fix/canvas-png-alpha
Dec 4, 2026
Merged

FayeSpica merged 1 commit into
ThinkFlowLab:mainfrom
FayeSpica:fix/canvas-png-alpha

Conversation

@FayeSpica

Copy link
Copy Markdown
Collaborator

Summary

The canvas painted a solid background behind loaded images, so transparent pixels hid the canvas and any lower node. Remove the background from the loaded image frame and media well. Empty image placeholders keep their existing appearance.

Linked issue

No issue applies.

Test plan

  • node tests/browser/canvas_png_alpha.mjs against the isolated creation API and Vite in Chromium
  • node tests/browser/canvas_progressive_load.mjs against the same fixture
  • npm run check:browser-manifest, npm run check:browser-locale, npm run check:i18n, and npm run build
  • python -m pre_commit run --from-ref upstream/main --to-ref HEAD

Test result

  • The same PNG pixel test failed on the base because the transparent area showed the media well. On the candidate, fully transparent pixels showed the underlying image, half-opacity pixels blended with it, and opaque pixels covered it in both themes. The empty image placeholder kept its fill.
  • The existing canvas loading, retry, and project switch regression passed.
  • Browser manifest, locale checks, and the production build passed.
  • Full-diff static checks passed. Release checks will run on the PR.

Evidence

In an isolated project, place the synthetic PNG with transparent, half-opacity, and opaque bands over a solid green image. The base masks the green area with the image well. The candidate shows green through the clear band and blends it with the half-opacity band. Before in dark theme · After in dark theme · After in light theme

The before image was captured at 26e155aea8faff21b565603d574bc7bd653a881a. Both after images were captured at 37c8200bcb6bee745f879f7867e2fdb9049d9af1. The fixture uses browser-rendered synthetic PNGs and makes no provider calls.

Candidate review

  • Base 26e155aea8faff21b565603d574bc7bd653a881a
  • Head 37c8200bcb6bee745f879f7867e2fdb9049d9af1
  • Independent pre-review score 93/100. No blocking findings for submission. Release checks are pending.

Signed-off-by: Weiming Liao <liaowm5@gmail.com>
@FayeSpica FayeSpica added area:canvas Canvas, nodes and direct manipulation type:bug Something is broken labels Dec 3, 2026 — with ChatGPT Codex Connector

@david6666666 david6666666 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

PASS 37c8200 · 无关联 Issue / no linked issue

Dot,代表 @david6666666。技术评审通过,以下是非表决 COMMENT。

这个修法只清掉已加载图像后面的两层底色,没动空节点和加载/失败占位。三张前后截图我打开后取了同一位置的像素:修复前全透明带是深灰 (32,33,36);修复后深浅主题都能透出下层绿 (0,220,144),半透明红叠成 (128,110,72),不透明白仍覆盖下层。没有发现需要阻塞的代码问题。

Ran: 独立检查了截图像素、完整 diff 和渲染分支;同 SHA 的 Release checks、CodeQL、DSH 均通过。作者报告新像素用例在 base 失败、在此 head 通过。
Not run: 我没有重跑 Chromium 用例;canvas_png_alpha.mjs 在 extended lane,不把本次 Release 绿灯当成它已在 CI 执行。

93/100:Scope 3/3(修复范围明确);Correctness 3/3(只改已加载图片);Validation 2/3(新用例有作者记录,未独立复跑);Claim evidence 3/3(三张截图与声明 SHA 对齐,关键像素已核对);Simplicity 3/3(小范围 CSS 变更)。后续可在 extended lane 留存像素回归的运行结果,非合入阻塞。

Coordinator: 当前未请求 @david6666666 正式投票,本条不计 Approve;交由已受邀 reviewer 和仓库 Coordinator 按流程处理。

@FayeSpica
FayeSpica merged commit 9f24de1 into ThinkFlowLab:main Dec 4, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:canvas Canvas, nodes and direct manipulation type:bug Something is broken

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants