release: v3.25.31 修复画布内嵌网页在 Windows 同步命令里 deadlock
按 Tauri 2 官方文档 Window::add_child Known issues:「On Windows, this function deadlocks when used in a synchronous command」。项目里 canvas_webview_ensure 是同步 fn,第一个触发 add_child 即死锁,导致 Windows 用户开画布网页节点完全无反应。 把 8 个相关 command 改成 async fn(同 open_browser_window 模式,命令内部无 await,但走 async runtime 不占 IPC 主线程): 必改: - canvas_webview_ensure(唯一 add_child 调用点) 防御性对齐 doc.rs 推荐(操作子 webview 主线程 API): - canvas_webview_metrics / bounds / navigate / action / close_all 约定统一(操作独立 webview window): - browser_control / browser_state canvas_webview_state 仅读 url(),保留同步。 JS 层 src/canvas-webview.js 用 Promise 调用,IPC 协议透明,零改动。 未补:cwv_round 非 mac 分支是空 stub,Windows 上画布网页节点无圆角,cosmetic 另排。 未验证:Windows 实测未做(这台 mac arm64 不能交叉编译 win 产物,见 DESKTOP_BUILD.md 第四章)。修完需 win 拉代码构建 v3.25.31 包并跑测试矩阵,三平台同批齐平发布才能上线。 cargo check --release 通过(mac 侧,0 错 0 警)。
This commit is contained in:
1 parent
bff5ccd3e9
commit
dd0e604d80
6 files changed
+49
-12
No files matched your search
@@ -14,6 +14,43 @@
|
||||
> 3. 核验正式地址版本 → 之后才移动 `stable` / `stable-verified-<日期>` 标签、更新本 CHANGELOG、写 GitHub Release(`gh release create`)。
|
||||
> 测试发现问题 → 改 → 再 `deploy:test`,正式环境不受影响。回滚点 `git reset --hard stable`。
|
||||
|
||||
## v3.25.31(2026-11-19)画布内嵌网页在 Windows 上「死锁」修复
|
||||
|
||||
**症状**:v3.25.24 起在画布节点上开网页(浏览器插件「网页」节点 / ↗ 放到画布),macOS 正常;Windows 上一点就没反应 / 后续整个 IPC 主线程被卡住。
|
||||
|
||||
**根因**:`Window::add_child`(tauri `unstable` 多 webview API)官方文档 Known issues 原文:
|
||||
|
||||
> On Windows, this function **deadlocks** when used in a synchronous command or event handlers, see the Webview2 issue. You should use `async` commands and separate threads when creating webviews.
|
||||
|
||||
项目里所有操作子 webview 的 command 都是同步 `fn`,第一个触发的就是 `canvas_webview_ensure` 里的 `add_child`,直接死锁。
|
||||
|
||||
**修法**:把 8 个相关 command 改成 `async fn`,命令内部无 `await`,但放进 Tauri 异步运行时跑、不占 IPC 主线程,跟原本就 `async` 的 `open_browser_window`(独立浏览器窗口)同模式:
|
||||
|
||||
- `canvas_webview_ensure`(必改,唯一 `add_child` 调用点)
|
||||
- `canvas_webview_metrics` / `canvas_webview_bounds` / `canvas_webview_navigate` / `canvas_webview_action` / `canvas_webview_close_all`(防御性,对齐 doc.rs 推荐)
|
||||
- `browser_control` / `browser_state`(约定统一,操作独立 webview window,理论上同步也行)
|
||||
|
||||
`canvas_webview_state` 仅读 `wv.url()`,无 webview 创建 / bounds / navigate 等主线程动作,保留同步。
|
||||
|
||||
JS 层 `src/canvas-webview.js` 本来就用 Promise 调用,签名 async 化对 IPC 协议透明,**零改动**。
|
||||
|
||||
**未补 / 已知缺失**:
|
||||
|
||||
- `cwv_round`(画布网页节点圆角)非 macOS 分支是空 stub(`#[cfg(not(target_os = "macos"))]`),Windows 上网页节点没有圆角,直角贴到卡片上。是 cosmetic,不影响能否打开,另排 backlog 单独处理。
|
||||
- macOS 上原本能用的画布网页,命令执行线程从 IPC 主线程挪到 async runtime,理论上时序有微小差异。`open_browser_window` 一直就是 async 且 mac 工作正常,类比可推无副作用;但仍要走测试矩阵第 1 项确认。
|
||||
|
||||
**验证状态**:
|
||||
|
||||
- mac 上 `cargo check --release` 通过(40s,0 错 0 警)。
|
||||
- **Windows 实测未做** —— 这台是 mac arm64,DESKTOP_BUILD.md 第四章明确「Tauri 不支持从 macOS 交叉编译 Windows 产物」。修完必须把代码推到 gitea,win 拉代码构建 v3.25.31 win 包并跑测试矩阵,三平台同批齐平发布后才能上线。
|
||||
- 测试矩阵:
|
||||
1. mac:画布网页能打开 + 拖动 / 缩放 / 平移 / 框选不白屏 + 关闭 / 切工作区回收正常
|
||||
2. win:独立浏览器窗口能打开(修前修后都行,本来就走 async)
|
||||
3. win:画布网页节点能打开 + 不卡死 + IPC 不阻塞
|
||||
4. win:节点关闭 / 切工作区 / 应用退出,cwv-* webview 正常回收
|
||||
|
||||
**诚实声明**:本条修复方向有 doc.rs Known issues 原文 + 项目里 `open_browser_window` 同款 async 模式 + macOS 上 async 无副作用三条证据支持,但 wry / WebView2 runtime 版本细节我没法覆盖;Windows 上「真的修好了」要在 win 机器实测后才能确认。
|
||||
|
||||
## v3.25.30(2026-11-19)应用内浏览器 1.5.0 配套客户端 + 库面板浮窗可框选
|
||||
|
||||
**客户端(必须先于插件发版)**:插件 1.5.0 依赖本版的两处宿主能力 —— 设置 schema 的 `type:'custom'` 自定义渲染、
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "image-workbench-web",
|
||||
"private": true,
|
||||
"version": "3.25.30",
|
||||
"version": "3.25.31",
|
||||
"description": "Browser-based node canvas image workbench",
|
||||
"scripts": {
|
||||
"build": "node scripts/build.js && node scripts/copy-plugins.js",
|
||||
|
||||
Generated
+1
-1
@@ -1983,7 +1983,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "image-workbench"
|
||||
version = "3.25.30"
|
||||
version = "3.25.31"
|
||||
dependencies = [
|
||||
"arboard",
|
||||
"base64 0.22.1",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "image-workbench"
|
||||
version = "3.25.30"
|
||||
version = "3.25.31"
|
||||
description = "无限画布 · 生图工作台桌面版"
|
||||
authors = ["malongan"]
|
||||
license = ""
|
||||
|
||||
@@ -402,7 +402,7 @@ async fn open_browser_window(app: AppHandle, url: String) -> Result<bool, String
|
||||
// 浏览器窗口控制:由主窗口(有 IPC 权限)驱动,browser 窗口自身仍然无 IPC 权限。
|
||||
// back/forward 用固定字符串且不拼接任何外部输入,不构成注入面。
|
||||
#[tauri::command]
|
||||
fn browser_control(app: AppHandle, action: String) -> Result<bool, String> {
|
||||
async fn browser_control(app: AppHandle, action: String) -> Result<bool, String> {
|
||||
let win = app
|
||||
.get_webview_window("browser")
|
||||
.ok_or_else(|| "浏览器窗口未打开".to_string())?;
|
||||
@@ -419,7 +419,7 @@ fn browser_control(app: AppHandle, action: String) -> Result<bool, String> {
|
||||
|
||||
// 面板用来显示「当前打开的是哪个站」以及窗口是否还活着。
|
||||
#[tauri::command]
|
||||
fn browser_state(app: AppHandle) -> Result<serde_json::Value, String> {
|
||||
async fn browser_state(app: AppHandle) -> Result<serde_json::Value, String> {
|
||||
match app.get_webview_window("browser") {
|
||||
Some(win) => Ok(serde_json::json!({
|
||||
"open": true,
|
||||
@@ -586,7 +586,7 @@ fn cwv_round(_app: &AppHandle, _wv: &tauri::webview::Webview<tauri::Wry>, _zoom:
|
||||
// 这里只回报「窗口边框」尺寸,差值由渲染层用 window.innerHeight 算 —— 全屏时标题栏消失,
|
||||
// 差值自然回到 0,不需要额外分支。
|
||||
#[tauri::command]
|
||||
fn canvas_webview_metrics(app: AppHandle) -> Result<serde_json::Value, String> {
|
||||
async fn canvas_webview_metrics(app: AppHandle) -> Result<serde_json::Value, String> {
|
||||
let win = app.get_window("main").ok_or_else(|| "主窗口不存在".to_string())?;
|
||||
let size = win.inner_size().map_err(|e| e.to_string())?;
|
||||
let scale = win.scale_factor().unwrap_or(1.0);
|
||||
@@ -599,7 +599,7 @@ fn canvas_webview_metrics(app: AppHandle) -> Result<serde_json::Value, String> {
|
||||
|
||||
// 确保某节点对应的子 webview 存在。返回 true = 这次真的新建了。
|
||||
#[tauri::command]
|
||||
fn canvas_webview_ensure(
|
||||
async fn canvas_webview_ensure(
|
||||
app: AppHandle,
|
||||
id: String,
|
||||
url: String,
|
||||
@@ -688,7 +688,7 @@ fn canvas_webview_ensure(
|
||||
// 渲染层推送位置/尺寸/可见性。
|
||||
// 返回 false = Rust 侧没有这个 webview(被 close / 进程重启),前端应回滚并重建。
|
||||
#[tauri::command]
|
||||
fn canvas_webview_bounds(
|
||||
async fn canvas_webview_bounds(
|
||||
app: AppHandle,
|
||||
id: String,
|
||||
x: f64,
|
||||
@@ -740,7 +740,7 @@ fn canvas_webview_bounds(
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
fn canvas_webview_navigate(app: AppHandle, id: String, url: String) -> Result<bool, String> {
|
||||
async fn canvas_webview_navigate(app: AppHandle, id: String, url: String) -> Result<bool, String> {
|
||||
let parsed = cwv_parse(&url)?;
|
||||
let label = cwv_label(&id);
|
||||
let Some(wv) = app.get_webview(&label) else {
|
||||
@@ -752,7 +752,7 @@ fn canvas_webview_navigate(app: AppHandle, id: String, url: String) -> Result<bo
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
fn canvas_webview_action(app: AppHandle, id: String, action: String) -> Result<bool, String> {
|
||||
async fn canvas_webview_action(app: AppHandle, id: String, action: String) -> Result<bool, String> {
|
||||
let label = cwv_label(&id);
|
||||
let Some(wv) = app.get_webview(&label) else {
|
||||
return Err("该节点还没有浏览器".into());
|
||||
@@ -785,7 +785,7 @@ fn canvas_webview_state(app: AppHandle, id: String) -> Result<serde_json::Value,
|
||||
|
||||
// 退出 / 切工作区时回收所有子 webview(label 前缀 cwv-)。
|
||||
#[tauri::command]
|
||||
fn canvas_webview_close_all(app: AppHandle) -> Result<u32, String> {
|
||||
async fn canvas_webview_close_all(app: AppHandle) -> Result<u32, String> {
|
||||
let labels: Vec<String> = app
|
||||
.webviews()
|
||||
.keys()
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"$schema": "../node_modules/@tauri-apps/cli/config.schema.json",
|
||||
"productName": "image-workbench",
|
||||
"version": "3.25.30",
|
||||
"version": "3.25.31",
|
||||
"identifier": "com.malongan.imageworkbench",
|
||||
"build": {
|
||||
"frontendDist": "../dist",
|
||||
|
||||
Reference in new issue
Block a user