macOS button text differs from SwiftUI in interaction snapshots
维护者通常 1 天内回复
评估
调研方向
从 renderKeyedText 开始;issue 指出它使用白色绘制仅含 alpha 的文本蒙版。比较它使用已解析前景色的方式。然后在禁用参考更新的情况下运行 ButtonInteractionTests,并检查启用和禁用状态的快照用例。全部六张截图都与 SwiftUI 参考结果一致即表示完成。
由索引模型根据 Issue 内容生成。
描述
Description
Default button labels rendered by OpenSwiftUI differ from SwiftUI at the glyph
edges on macOS. Both enabled and disabled buttons are affected. The differences
remain when the reference and actual images use the same macOS version.
Button actions work: repeated presses update the count, and disabled buttons do
not run their actions. The failures are snapshot mismatches, with no crash.
Reproduction
- Platform: macOS 15.7.3 (24G419), arm64.
- Configuration: OpenSwiftUI renderer with IAG.
- References: SwiftUI snapshots recorded on macOS 15.7.3.
- Source: The Button implementation merged in #1138.
Run the existing
ButtonInteractionTests
with reference updates disabled. The two cases capture the initial appearance
and the appearance after each of two presses:
actionUpdatesCount: The enabled button displays counts 0, 1, and 2.disabledButtonDoesNotRunAction: The disabled button keeps count 0.
Expected and actual results
All six captures should match the SwiftUI references. Instead, each capture has
differences confined to the text. The button backgrounds and borders match.
| Case | Initial | After first press | After second press |
|---|---|---|---|
| Enabled | 604 | 543 | 556 |
| Disabled | 583 | 583 | 583 |
Values are the number of changed RGBA pixels in each reference/actual pair from
the focused CI run.
The reference, actual, and difference images are available in the snapshot
artifact of the CI run linked above.
Findings
A local comparison on macOS 15.7.3 reproduced the CI images. View and layer
geometry, glyph positions, fonts, transforms, and text color matched between the
two renderers.
The difference comes from the fill color used to draw the alpha-only text mask
in renderKeyedText. OpenSwiftUI uses white. On macOS, font smoothing depends on
the fill color even in an alpha-only context, so this changes glyph coverage.
Using the resolved foreground RGB for a solid fill removes the differences in
these button snapshots.
A standalone text probe confirmed that black and white fills produce different
alpha masks on macOS 15.7.3 with font smoothing enabled. The masks match with
smoothing disabled. The same probe on iOS 18.5 produced identical masks for both
colors.
- 主要语言
- Swift
- 星标
- 2.5k
- 派生
- 84
- 平均合并
- 2 小时 10 分钟
- 30 天内合并 PR
- 62
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
OpenSwiftUIProject/OpenSwiftUI 的其他 Issue
-
Add Accessibility support可能已有人在做 @Kyle-Ye 于 16 天前认领。 未关闭area: accessibility area: hosting-bridge type: feature
OpenSwiftUIProject/OpenSwiftUI#1112 · 已指派 1 人 ·
维护者通常 1 天内回复
-
area: rendering area: view type: feature
难度 4/5 3-5 天 新手友好度 42/100
OpenSwiftUIProject/OpenSwiftUI#1022 ·
维护者通常 1 天内回复
-
area: animation area: rendering contrib: help wanted impact: visual-diff type: bug
难度 4/5 3-5 天 新手友好度 48/100
OpenSwiftUIProject/OpenSwiftUI#984 ·
维护者通常 1 天内回复
-
Add List support未关闭area: layout area: rendering area: view type: feature
难度 5/5 一周以上 新手友好度 28/100
OpenSwiftUIProject/OpenSwiftUI#919 ·
维护者通常 1 天内回复
-
area: layout area: rendering area: view type: feature
难度 5/5 一周以上 新手友好度 35/100
OpenSwiftUIProject/OpenSwiftUI#918 · 1 条评论 ·
维护者通常 1 天内回复
查看 OpenSwiftUIProject/OpenSwiftUI 的全部 Issue
相似的 Issue
-
fyi-ecosystem platform-ios team-ios
难度 1/5 1 小时以内 新手友好度 70/100
flutter/flutter#194348 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 88/100
freestylefly/WeChatBridge#44 ·
维护者通常 1 天内回复
-
难度 2/5 半天 新手友好度 62/100
swiftwasm/JavaScriptKit#818 ·
-
难度 2/5 半天 新手友好度 62/100
-
难度 2/5 1-3 小时 新手友好度 72/100
capawesome-team/capacitor-plugins#1134 ·
维护者通常 1 天内回复