Skip to content

feat(ohos): add lifecycle event RunEvent variants and tests - #61

Open
sb-fy-sb wants to merge 1 commit into
Eulogizethesun:ohdevfrom
sb-fy-sb:feat/ohos-lifecycle-events
Open

feat(ohos): add lifecycle event RunEvent variants and tests#61
sb-fy-sb wants to merge 1 commit into
Eulogizethesun:ohdevfrom
sb-fy-sb:feat/ohos-lifecycle-events

Conversation

@sb-fy-sb

@sb-fy-sb sb-fy-sb commented Jul 2, 2026

Copy link
Copy Markdown

Add Started/SaveStateRequested/ContentRectChanged/Suspended to RunEvent enum across tauri-runtime → tauri-runtime-wry → tauri.

Bridge Event::Resumed and Event::Suspended in wry (fixes hidden bug on Android/iOS where these were never forwarded).

Add event tracking and 3 auto tests:

  • RunEvent::Ready fires on startup
  • RunEvent::Started fires on OHOS (verified via Resumed bridge)
  • RunEvent lifecycle order (Ready → Resumed)

@github-actions

github-actions Bot commented Jul 2, 2026

Copy link
Copy Markdown

Package Changes Through b9cdb49

There are 11 changes which include tauri with minor, @tauri-apps/api with minor, tauri-build with minor, tauri-macos-sign with patch, tauri-bundler with minor, @tauri-apps/cli with minor, tauri-cli with minor, tauri-runtime with minor, tauri-runtime-wry with minor, tauri-utils with minor, tauri-plugin with minor

Planned Package Versions

The following package releases are the planned based on the context of changes in this pull request.

package current next
@tauri-apps/api 2.10.1 2.11.0
tauri-utils 2.8.3 2.9.0
tauri-macos-sign 2.3.3 2.3.4
tauri-bundler 2.8.1 2.9.0
tauri-runtime 2.10.1 2.11.0
tauri-runtime-wry 2.10.1 2.11.0
tauri-codegen 2.5.5 2.5.6
tauri-macros 2.5.5 2.5.6
tauri-plugin 2.5.4 2.6.0
tauri-build 2.5.6 2.6.0
tauri 2.10.3 2.11.0
@tauri-apps/cli 2.10.1 2.11.0
tauri-cli 2.10.1 2.11.0

Add another change file through the GitHub UI by following this link.


Read about change files or the docs at github.com/jbolda/covector

@MingyuChen1 MingyuChen1 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.

OHOS Code Review — tauri#61

🔴 🟡 🔵 ℹ️
1 3 1 1

Architecture

Rust 管道正确且与 tao#14 跨仓一致(Started / SaveStateRequested / ContentRectChanged { rect, reason } 命名跨三 crate 一致)。tauri-runtime-wry 的 on_event_loop_event 正确映射新 variant。

⚠️ 依赖 tao#14 — 本 PR 消费 tao#14 转发的 lifecycle 事件。两笔 PR 需一起合入。

Blocker

🔴 [H6] 测试断言错误事件 (core.ts ~line 1122)
测试名为 RunEvent::Started fires on OHOS,但 body 断言 events.includes('Resumed'),从不检查 Started。三个新 OHOS variant(Started / SaveStateRequested / ContentRectChanged)零测试覆盖。example 为三者接了日志但无测试读取。修复测试以断言真实新事件后再合入。

Warnings

🟡 [D1] 桌面 Resumed 行为变更 (tauri-runtime-wry/src/lib.rs ~line 4411)
新 Event::Resumed => callback(RunEvent::Resumed) arm 与既有 NewEvents(StartCause::Poll) -> RunEvent::Resumed (line 4404) 分离。桌面 winit 的 Event::Resumed 现在也会触发 RunEvent::Resumed,可能改变仅从 NewEvents(Poll) 看到 Resumed 的桌面用户行为。设计注说惠及 Android/iOS,桌面影响应确认而非假定为良性。

🟡 [G4] app.rs unimplemented!() catch-all (~line 2686)
对 #[non_exhaustive] 上游 enum 用 unimplemented!()(非 unreachable!())意味着新的 tao/winit variant 会在运行时 panic 而非静默 fall through。既有模式,但新 OHOS arm 正落在该 footgun 上方。

🟡 [G1] reason: u32 类型擦除 (ContentRectChanged)
RectChangeReason 被转为裸 u32 暴露给 app 作者,丢失枚举语义。考虑 re-export 枚举或 Tauri 自有镜像枚举。

🔵 examples 中 OHOS arm cfg-gated,Suspended 未 gate(与 variant cfg 策略一致)

ℹ️ Suspended 未 cfg-gate 是设计意图(惠及 Android/iOS),与 tao 一致

与 tao#14 一起合入。 请修复 🔴 测试断言错误事件。

@MingyuChen1 MingyuChen1 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.

OHOS Code Review (Round 2) — tauri#61

🔴 🟡 🔵 ℹ️
0 3 1 1

✅ Round 77 blocker resolved

🔴 test asserting wrong event → Fixed. The 'RunEvent::Started fires on OHOS' test now uses was_started_received static AtomicBool tracker (instead of asserting Resumed), properly testing the Started event. SaveStateRequested and ContentRectChanged variants also wired in wry layer.

Remaining (non-blocking, from round 77)

🟡 Desktop Event::Resumed behavior change (now also fires RunEvent::Resumed) — confirm benign
🟡 app.rs unimplemented!() catch-all on non_exhaustive enum
🟡 reason: u32 type erasure in ContentRectChanged

🔵 Suspended cfg strategy consistent
ℹ️ Suspended ungated by design (Android/iOS)

LGTM — ready to merge (with tao#14).

@sb-fy-sb
sb-fy-sb force-pushed the feat/ohos-lifecycle-events branch from 85a80d6 to 4470629 Compare July 9, 2026 01:37

@MingyuChen1 MingyuChen1 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.

OHOS Code Review — tauri#61 (re-review 2026-07-09)

🔴 🟡 🔵 ℹ️
0 0 0 2

概述

新增 4 个 OHOS 生命周期 RunEvent 变体(Started / SaveStateRequested / ContentRectChanged / Suspended),并在 tauri-runtime-wry 桥接。RectChangeReason 枚举 #[non_exhaustive] + From<u32> 把未知值映射到 Undefined,处理未来 OHOS 新增 reason。openspec 已归档到 openspec/changes/archive/2026-07-02-ohos-lifecycle-events/(H3/H6✓)。3 个自动测试覆盖 Ready/Started/生命周期顺序,Started 因早于 EventTracker 用 STARTED_RECEIVED static AtomicBool 兜底,合理。

ℹ️ I1 — on_event_loop_eventother => unreachable!

RuntimeRunEvent#[non_exhaustive],通配臂从 _ => unimplemented!() 改为 other => unreachable!("unhandled RuntimeRunEvent variant: {other:?}")。注释说明“panic 优于静默丢事件”。行为不变(仍 panic),消息更清晰。注意:若上游 tao 新增 Event 变体未在此 match 加臂,会在运行时 panic——这是有意的 fail-loud,可接受,但合入上游时需留意。

ℹ️ I2 — doc/manual_tests.md 未更新(H5 边界)

本 PR 在 TestRunner.svelte 新增生命周期事件监控 UI(Monitor 按钮,1s 轮询,切后台/回前台/弹键盘可视化)。生命周期事件是后台事件而非用户可操作功能(createPdf/tray 类),H5 是否适用属边界。若视为手动测试用例,可在 manual_tests.md 追加一条;否则可忽略。

无阻塞问题,可合入。

Cherry-picked from PR Eulogizethesun#61 (fb44709 + 0a8d5f3). Resolved core.ts
conflict by keeping existing mouse/cookie/vibrancy tests and adding
RunEvent lifecycle tests.

New Event variants:
- RunEvent::Started / RunEvent::SaveStateRequested
- Event::Started / Event::SaveStateRequested / Event::ContentRectChanged
- MainEvent::Pause/Stop mapped to Event::Suspended

Co-Authored-By: Claude <noreply@anthropic.com>
@sb-fy-sb
sb-fy-sb force-pushed the feat/ohos-lifecycle-events branch from 4470629 to b9cdb49 Compare July 22, 2026 09:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants