[Bug] Android 多设备离线时首页启动仍因嵌套更新过深崩溃
- Dominant language
- TypeScript
- Stars
- 2.7k
- Forks
- 395
- Avg merge
- 21h 48m
- Merged PRs (30d)
- 776
Description
## 问题描述 / What happened
Android 端同账号存在约 60 台远程设备时,启动 Cindy 后首页加载过程中会闪退。
实际行为:应用抛出 `Maximum update depth exceeded` 并退出。
期望行为:设备集中离线或其离线宽限同时到期时,首页应完成同步并展示离线状态,不应因 React 嵌套更新过深而崩溃。
关联修复 PR:#4259
## 环境 / Environment
- Cindy 版本或 commit / version or commit: Android Global v0.1.82;已安装包 versionName `0.1.15`、versionCode `21`
- 平台与版本 / platform & OS version: Android 16,SM-S918N
- 安装方式 / install method: 已安装的 Global 构建
## 复现步骤 / Steps to reproduce
1. 使用同一账号准备约 60 台已绑定远程设备。
2. 保持这些设备处于离线状态,或使其离线宽限在应用启动期间集中到期。
3. 启动 Cindy 并等待首页加载设备与会话列表。
4. 观察应用闪退。
## 日志与截图 / Logs & screenshots
错误上下文:
```text
Error: Maximum update depth exceeded. This can happen when a component repeatedly calls setState inside componentWillUpdate or componentDidUpdate.
emit
invalidateDeviceMirrors
markOfflineDeviceMirrors
```
## 源码定位
PR #4259 新增的 `createOfflineMirrorWipeQueue` 仅在同一个 JavaScript task 内通过 `queueMicrotask` 合并离线设备。
但每台设备的离线宽限分别由 timer 调度。Android/RN 中这些 timer 回调可分别执行;每次回调完成后微任务即被清空,因此后续设备不会加入前一次的队列。结果是每台设备仍可能单独调用 `markOfflineDeviceMirrors`,进而调用 `remoteScheduleEventStore.invalidateDeviceMirrors` 并触发一次 `emit()`。
建议将合并边界调整为能够覆盖同一批离线宽限到期的多个 timer 回调,并增加 Android 真实调度语义下的多设备回归验证。
Contributor guide
Research direction
Start by reading createOfflineMirrorWipeQueue and the callers markOfflineDeviceMirrors and remoteScheduleEventStore.invalidateDeviceMirrors, then reproduce the Android timer behavior with the 60-device scenario. Verify that simultaneous offline-grace expirations are coalesced across timer callbacks, homepage sync completes, offline states appear, and Maximum update depth exceeded is not raised.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, react-native, typescript
- Domain
- mobile
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 62/100