Skip to content

Upgrade to Avalonia 12 and enable native Wayland - #2768

Closed
VirgilMing wants to merge 3 commits into
sourcegit-scm:developfrom
VirgilMing:codex/sourcegit-wayland
Closed

VirgilMing wants to merge 3 commits into
sourcegit-scm:developfrom
VirgilMing:codex/sourcegit-wayland

Conversation

@VirgilMing

@VirgilMing VirgilMing commented Oct 8, 2026 •

Copy link
Copy Markdown

中文

English notes follow below.

SourceGit 当前使用 Avalonia 11,Linux 桌面默认通过 X11 运行。本 PR 将应用迁移到 Avalonia 12.1.3,并在 Linux 会话存在 WAYLAND_DISPLAY 时显式启用原生 Wayland 后端;X11 会话和其他操作系统继续使用平台检测。

主要变更

  • 升级 Avalonia 至 12.1.3、DataGrid 至 12.1.2,更新窗口装饰、输入事件、剪贴板、文本渲染和 XAML 占位文字等相关 API。
  • 将代码中定义的绑定迁移为 compiled bindings,保留 Native AOT 构建方式。
  • Linux 自绘窗口保持无系统装饰,避免出现额外边框。
  • 将 AvaloniaEdit 子模块切到维护者已公开的 patch-on-12.x 提交 358f2c9e4ac57667c0183bf68f8869b110a69b1e。保持现有 .gitmodules URL,干净 checkout 可以从配置的远端获取该提交。
  • 添加 Avalonia.Wayland 和按会话环境选择后端的逻辑。
  • 允许使用较新的 .NET 10 SDK feature band,并让 Release 发布使用 Native AOT runtime pack。
  • 在构建文档中记录 DataGrid 的 AOT 警告来源、当前使用约束和重新审计条件,保持 AOT 诊断开启。

提交按“框架迁移 → Wayland 启用 → AOT 文档”分开,目标分支为 develop。

验证

  • Linux amd64 的 Release build、Native AOT publish、完整 dotnet format --verify-no-changes 和 Git 空白检查通过。
  • 新建 checkout,成功从 GitHub 获取公开的 AvaloniaEdit 子模块提交。
  • 取消 DISPLAY 后,原生 Wayland 仓库窗口和 Blame 编辑器均能启动;协议日志记录了 xdg_toplevel 创建和配置,没有对应的 X11 窗口或崩溃日志。
    • 验证环境:Plasma 6.7.5 (Wayland), Gentoo Linux
  • 子模块使用 Avalonia 12.1.2,最终应用解析为 12.1.3,构建未发现版本降级或编译冲突。

已知限制

Avalonia 的 Wayland 后端仍处于早期实现阶段。Windows、macOS 和 arm64 尚未在本地进行运行验证;中文输入、应用间剪贴板和拖放也尚未在最终子模块版本上完整复测。

DataGrid 12.1.2 仍产生已审计的 IL3053 汇总警告,展开后为索引器泛型回退的两条 IL3050 和自动生成列的反射 Binding 警告。
SourceGit 使用手写模板列,并关闭自动生成列和用户列排序;但我还没找到让这些使用约束被AOT编译器消费以消除上述警告的方法。
细节及复查命令见 build/README.md。

English

SourceGit currently uses Avalonia 11 and the X11 backend on Linux. This PR migrates the application to Avalonia 12.1.3 and explicitly selects native Wayland when WAYLAND_DISPLAY is present in a Linux session. X11 sessions and other operating systems retain platform detection.

Changes

  • Upgrade Avalonia to 12.1.3 and DataGrid to 12.1.2, adapting the affected window decorations, input events, clipboard, text rendering, and XAML placeholder APIs.
  • Use compiled bindings for code-defined bindings while retaining Native AOT.
  • Keep custom Linux windows undecorated to avoid an additional frame.
  • Select the maintainer's published AvaloniaEdit patch-on-12.x commit, 358f2c9e4ac57667c0183bf68f8869b110a69b1e. The submodule URL is unchanged, and a fresh checkout can fetch the commit from the configured remote.
  • Add Avalonia.Wayland and session-dependent backend selection.
  • Accept newer .NET 10 SDK feature bands and use the Native AOT runtime pack for Release publishing.
  • Document the DataGrid AOT diagnostics, current usage constraints, and conditions requiring a new audit. AOT diagnostics remain enabled.

The commits separate framework migration, Wayland activation, and AOT documentation. The PR targets develop.

Validation

  • Linux amd64 Release build, Native AOT publish, full dotnet format --verify-no-changes, and whitespace checks passed.
  • A fresh checkout fetched the public AvaloniaEdit submodule commit from GitHub.
  • With DISPLAY unset, the native Wayland repository window and Blame editor started successfully. Protocol logs confirmed xdg_toplevel creation/configuration, with no corresponding X11 window or crash logs.
    • Validated on Plasma 6.7.5 (Wayland) on Gentoo.
  • AvaloniaEdit references Avalonia 12.1.2, while the final application resolves 12.1.3 without downgrade or compilation errors.

Known limitations

Avalonia's Wayland backend is still at an early stage. Windows, macOS, and arm64 runtime behavior has not been validated locally. Chinese input, cross-application clipboard, and drag-and-drop have not yet been fully retested with the final submodule version.

DataGrid 12.1.2 still reports the audited IL3053 aggregate. Expanded diagnostics contain two IL3050 warnings for the indexer generic fallback and one for reflection Binding in automatic column generation.
SourceGit uses explicit template columns and disables automatic columns and user column sorting; but I still haven't found a way to make AOT compiler understand these constraints and eliminate the warning.
build/README.md records the details and reproduction command.

Upgrade Avalonia and DataGrid, update the AvaloniaEdit submodule to its
Avalonia 12 compatibility commit, and migrate the affected input, window,
text rendering, clipboard, binding and XAML APIs. Use compiled bindings
for the code-defined bindings to preserve Native AOT support.

Keep platform detection on X11 in this commit. Preserve undecorated Linux
custom windows and pin a valid .NET 10 SDK feature-band version.

Validation: offline restore, Release Native AOT publish, formatter and
whitespace checks, and an isolated X11 startup opening the local repository.
Add Avalonia.Wayland 12.1.3 and select it explicitly when WAYLAND_DISPLAY
is present in a Linux session. Preserve platform detection for X11 and
other operating systems.
@VirgilMing VirgilMing mentioned this pull request Oct 8, 2026
@love-linger

Copy link
Copy Markdown
Collaborator
  1. SourceGit upgraded AvaloniaUI to 12.x in v2026.13, but soon downgraded it to 11.x in v2026.14 for some performance issues.
  2. I do not think it is the right time to upgrade AvaloniaUI to 12.x now. You can see there are lots of bugs in 12.x in AvaloniaUI issues.

@love-linger love-linger self-assigned this Oct 9, 2026
@love-linger love-linger added the not-planned It's not planned in the future label Oct 9, 2026
@VirgilMing

VirgilMing commented Oct 9, 2026 via email •

Copy link
Copy Markdown
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

not-planned It's not planned in the future

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants