Skip to content

fix(android): 避免覆盖安装后恢复旧视图状态并修复首帧绘制 - #40

Merged
zilorn merged 3 commits into
mainfrom
codex/android-update-white-screen
Oct 31, 2026
Merged

zilorn merged 3 commits into
mainfrom
codex/android-update-white-screen

Conversation

@zilorn

@zilorn zilorn commented Oct 26, 2026 •

Copy link
Copy Markdown
Owner

解决的问题 / Problem

Related to #24。Android 覆盖安装后首次启动白屏,强制杀进程后恢复。

改动后的行为 / Resulting behavior

  • MainActivity.onCreate 使用 super.onCreate(null),避免 Android 在 APK 覆盖安装后恢复过期的 Activity 视图层级,由 Tauri 重建其 WebView。
  • WebView 创建且窗口获得焦点后,仅请求一次重绘,处理可能的首帧绘制竞态。
  • 增加 ReaderXActivity 生命周期日志,以便排查 WebView 未创建和未绘制两类问题。
  • 将旧书库与稳定 ID 迁移从 Rust setup 移到页面启动后的 readerx_startup_migrate command:迁移不再占住主线程阻塞 WebView 装配与首帧;前端等待迁移完成后再读取书库 / 分组 / 规则,同步服务也只在迁移成功后启动。

验证 / Validation

  • 前端:tsc --noEmit、i18n:check、vite build 均通过。
  • Rust:cargo check -p readerx 通过;cargo test -p readerx --lib sync:: 28 项通过;cargo test -p readerx --test sync_bridge 26 项通过。
  • Kotlin 编译:未运行(当前仅能通过 GitHub 连接器编辑仓库)。
  • APK 覆盖安装实机复现:未运行,需要在 Android 设备上验证。
  • 手动验证建议:安装旧版 APK,保持最近任务状态,覆盖安装新 APK,首次启动检查 UI;执行 adb logcat -s ReaderXActivity:I 核对 WebView 创建和重绘日志。另需测试正常冷启动、旋转屏幕及后台恢复。

数据与兼容性 / Data and compatibility

不修改用户数据格式、SQLite schema、配置或依赖。迁移逻辑本身未改,仍可重跑并在失败时保留原数据;只调整执行时机,且迁移完成前不会读取依赖稳定 ID 的数据。跳过 Android Activity savedInstanceState 的恢复,可能影响系统级视图状态恢复,但 Tauri 的应用持久化数据不受影响。

风险 / 未解决项: Android 覆盖安装后的真实首启仍待实机验证;如果根因位于 Tauri/tao/wry 的窗口装配而非启动迁移阻塞,本补丁仍可能无法修复。待覆盖安装验证通过前保持 Draft,不自动关闭 #24。

提交前检查 / Checklist

  • 修改包含 Android Kotlin 与启动迁移接线,无二进制图片
  • 前端 / Rust 检查通过
  • Android 构建和实机覆盖安装验证

@zilorn
zilorn marked this pull request as draft October 28, 2026 15:07
@zilorn zilorn changed the title fix(android): 缓解更新后首次启动白屏并补充生命周期日志 fix(android): 避免覆盖安装后恢复旧视图状态并修复首帧绘制 Oct 28, 2026
@zilorn
zilorn marked this pull request as ready for review October 31, 2026 10:44
@zilorn
zilorn merged commit 1b44070 into main Oct 31, 2026
6 checks passed
@zilorn
zilorn deleted the codex/android-update-white-screen branch October 31, 2026 11:00
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.

Android 更新后首次启动白屏且不显示 UI(每次更新均复现),彻底杀掉重开恢复正常

1 participant