2.6 KiB
2.6 KiB
Debug Session: avatar-orientation
- Status: [OPEN]
- Issue: 手机拍照后上传头像,期望经过 EXIF 方向修正后始终正向显示;实际上传成功后仍保持拍照时的方向,未自动转正。
- Debug Server: http://127.0.0.1:7777/event (Android 通过
adb reverse tcp:7777 tcp:7777回传) - Log File: .dbg/trae-debug-log-avatar-orientation.ndjson
Reproduction Steps
- Android 真机打开 App。
- 进入“我的”页,点击头像。
- 选择“拍照”,使用横屏/竖屏拍摄一张照片并确认。
- 等待上传成功,观察最终头像是否已经转正。
Hypotheses & Verification
| ID | Hypothesis | Likelihood | Effort | Evidence |
|---|---|---|---|---|
| A | 拍照返回的字节已被系统或插件提前烘焙,EXIF orientation 不存在或恒为 1,所以 bakeOrientation 无事可做 |
High | Low | Confirmed |
| B | originBytes 读取到的不是原始照片数据,丢失了 EXIF;而 originFile/file 路径上的文件与之不同 |
High | Medium | Confirmed |
| C | 图片确实已旋正上传,但显示层仍在展示未处理的本地预览或缓存图 | Medium | Low | Rejected |
| D | image 包已读到 EXIF,但在当前手机样本上 bakeOrientation 前后宽高/方向无变化,问题出在更早的相机输出阶段 |
Medium | Medium | Pending |
| E | OSS / CDN 返回的是旧缓存图,导致看到的仍是原方向 | Low | Medium | Pending |
Log Evidence
my_page.dart:_onAvatarTap:pick:两次拍照都返回hasEntity=true、source=entity-originBytesmy_page.dart:_onAvatarTap:upload:两次都成功上传,分别得到新的 JPG URL,说明上传链路正常my_page.dart:_onAvatarTap:preview-clear:上传成功后_pickedAvatar已清空,页面不再优先显示本地临时预览my_page.dart:_onAvatarTap:processor:hasExifOrientation=falseexifOrientationBefore=nullexifOrientationAfter=nulldecodedWidth=2160, decodedHeight=3840orientedWidth=2160, orientedHeight=3840resized=true说明进入处理链的字节已经没有 EXIF orientation,bakeOrientation前后没有任何方向变化空间
Verification Conclusion
- 已确认上传成功且显示层已切回服务器图,C 被排除
- 根因已锁定:
- A:相机输出最终交给业务层的字节本身已无 EXIF orientation
- B:
wechat_camera_picker默认保存为AssetEntity后,再走entity-originBytes会丢失最初拍照文件里的方向信息 - D:
bakeOrientation前后没有任何变化,是因为输入里已经没有可烘焙的 orientation