fix(ai-avatar): B-roll时间戳/标题重影/TTS卡死防护 #1873

Merged
xiaoxia merged 4 commits from fix/ai-avatar-broll-title-worker-issues into develop 2026-09-12 22:37:12 +08:00
Owner

修复项

  1. B-roll 时间全 0.0~0.0s(P0):sentences.ts 优先使用后端 sentence_timings,修正参数顺序与 ModalBRollEditor 调用对齐;之前后端虽然返回了精确时间戳,但前端 splitScriptIntoSentences(text, timings, duration) 的第二/三参数错位,导致时间被忽略而全部走默认0估算。

  2. 标题重影(P0):bold=true 时原本用 borderw=3 + 同色描边 模拟粗体,在竖屏小字号上会产生字形偏移,视觉上像文字被打印了两次(用户截图中“曝光曝光…”重影)。改为黑色细描边 borderw=2, black,加粗清晰且不重影。

  3. 对口型卡 tts_processing 10+ 分钟不失败(P0):给 Celery TTS 任务加 soft_time_limit=180s / time_limit=200s,防止因网络/CosyVoice异常导致任务永久挂起;任务开头加 INFO 日志(job_id/voice_id/text_len)便于排查 worker 是否真的收到任务。

测试

  • Python 单测 74 passed(ai_avatar_render/lipsync_tts/ai_avatar_render_routes)
  • video_filter_builder 单测 110 passed
  • 前端 tsc 无新增错误

关联

staging 用户反馈 5 问题中 1/2/3 项修复;带宽问题(问题4)将另行评估;问题5用户未写完。

## 修复项 1. **B-roll 时间全 0.0~0.0s(P0)**:sentences.ts 优先使用后端 `sentence_timings`,修正参数顺序与 ModalBRollEditor 调用对齐;之前后端虽然返回了精确时间戳,但前端 `splitScriptIntoSentences(text, timings, duration)` 的第二/三参数错位,导致时间被忽略而全部走默认0估算。 2. **标题重影(P0)**:bold=true 时原本用 `borderw=3 + 同色描边` 模拟粗体,在竖屏小字号上会产生字形偏移,视觉上像文字被打印了两次(用户截图中“曝光曝光…”重影)。改为黑色细描边 `borderw=2, black`,加粗清晰且不重影。 3. **对口型卡 tts_processing 10+ 分钟不失败(P0)**:给 Celery TTS 任务加 `soft_time_limit=180s / time_limit=200s`,防止因网络/CosyVoice异常导致任务永久挂起;任务开头加 INFO 日志(job_id/voice_id/text_len)便于排查 worker 是否真的收到任务。 ## 测试 - Python 单测 74 passed(ai_avatar_render/lipsync_tts/ai_avatar_render_routes) - video_filter_builder 单测 110 passed - 前端 tsc 无新增错误 ## 关联 staging 用户反馈 5 问题中 1/2/3 项修复;带宽问题(问题4)将另行评估;问题5用户未写完。
xiaoxia added 1 commit 2026-09-12 21:09:34 +08:00
fix(ai-avatar): B-roll时间戳、标题粗体重影、TTS卡死防护
CI/CD Pipeline / Dedup Check - skip PR tests when covered by push pipeline (pull_request) Successful in 2s
CI/CD Pipeline / Check if frontend-only change (pull_request) Successful in 2s
CI/CD Pipeline / Frontend Lint (pull_request) Successful in 1m23s
CI/CD Pipeline / PR Build Web Image (pull_request) Successful in 1m19s
CI/CD Pipeline / PR Build API Image (pull_request) Successful in 2m18s
Preview Deploy / Deploy Preview Environment (pull_request) Successful in 2m38s
CI/CD Pipeline / PR Build Worker Image (pull_request) Successful in 2m40s
PR Automation / Auto Approve on CI Green (pull_request) Successful in 3m11s
CI/CD Pipeline / Frontend Unit Tests (pull_request) Successful in 3m45s
AI Code Review / AI Code Review (pull_request) Successful in 6m59s
CI/CD Pipeline / Integration Tests (pull_request) Successful in 6m58s
CI/CD Pipeline / Unit Tests (pull_request) Successful in 7m11s
CI/CD Pipeline / Validate - Style (pull_request) Successful in 7m14s
CI/CD Pipeline / Validate - Python (mypy + alembic) (pull_request) Successful in 9m16s
PR Automation / Auto Merge on CI Green + Approved (pull_request) Successful in 10m40s
CI/CD Pipeline / Validate - Security (pull_request) Successful in 25m22s
CI/CD Pipeline / Production Browser E2E (pull_request) Has been skipped
CI/CD Pipeline / CI Gate (pull_request) Successful in 3s
CI/CD Pipeline / Deploy Production (pull_request) Failing after 89h48m47s
CI/CD Pipeline / ACR Image Cleanup (pull_request) Failing after 90h13m53s
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (pull_request) Failing after 90h14m1s
CI/CD Pipeline / Build Staging Web Image (pull_request) Failing after 90h14m13s
CI/CD Pipeline / Build Production API Image (pull_request) Failing after 89h48m28s
CI/CD Pipeline / Retag skipped Staging Worker Image (pull_request) Failing after 90h13m45s
CI/CD Pipeline / Retag skipped Staging Web Image (pull_request) Failing after 90h13m45s
CI/CD Pipeline / Retag skipped Staging API Image (pull_request) Failing after 90h13m46s
CI/CD Pipeline / Build Staging Worker Image (pull_request) Failing after 90h13m52s
CI/CD Pipeline / Build Staging API Image (pull_request) Failing after 90h13m52s
CI/CD Pipeline / Canary Release to Production (pull_request) Failing after 89h48m25s
CI/CD Pipeline / Build Production Worker Image (pull_request) Failing after 89h48m28s
CI/CD Pipeline / Build Production Web Image (pull_request) Failing after 89h48m28s
CI/CD Pipeline / Staging API Integration Tests (pull_request) Failing after 90h13m31s
CI/CD Pipeline / Staging E2E Tests (pull_request) Failing after 90h13m34s
CI/CD Pipeline / Check push changed paths (pull_request) Failing after 90h13m53s
a83b53ae58
1. B-roll时间戳全0修复:
   - sentences.ts 新增 sentenceTimings 参数优先使用后端精确时间戳,
     降级才按字数比例估算
   - 修正参数顺序,与 ModalBRollEditor 现有调用 (scriptText, timings, duration) 对齐
   - 前端 AiAvatarPage 已通过 props 传 sentenceTimings(旧版已传但因顺序错位被忽略)

2. 标题粗体重影修复:
   - 之前 bold=true 时使用 borderw=3 + font_color 同色描边模拟粗体,
     会在小字号/竖屏视频上造成字形边缘偏移,视觉上文字像被打印了两次
     (用户截图中的'曝光曝光…'重影)
   - 改为黑色细描边(borderw=2, 黑色),既保留清晰加粗效果又不重影
   - 用户显式开启 stroke 时仍按用户配置走
   - 新增 _resolve_font_path(bold=True) 预留粗体字体查找能力(当前镜像
     无独立 Bold 字体文件,沿用 VF 常规字重)

3. TTS 任务防卡死:
   - 给 tts_synthesize_and_submit 加 soft_time_limit=180s / time_limit=200s,
     避免因网络/上游问题导致 Celery 任务永久挂起(用户之前卡10+分钟
     tts_processing 不失败)
   - 任务开头加 INFO 日志(job_id/voice_id/text_len),方便排查 worker
     是否真的收到任务

相关:staging 用户反馈 5 问题中的 1/2/3 项(B-roll时间、标题重影、对口型卡死)

🚀 预览环境已部署

项目 详情
PR号 #1873
预览链接 https://pr-1873.preview.xiaoxiajianji.com
API环境 staging

💡 预览环境使用 staging API 数据,请勿在预览环境中操作重要数据。

🔄 每次提交新代码后预览环境会自动更新。

🗑️ PR 关闭或合并后,预览环境会自动清理。

🚀 **预览环境已部署** | 项目 | 详情 | |------|------| | PR号 | #1873 | | 预览链接 | [https://pr-1873.preview.xiaoxiajianji.com](https://pr-1873.preview.xiaoxiajianji.com) | | API环境 | staging | > 💡 预览环境使用 staging API 数据,请勿在预览环境中操作重要数据。 > > 🔄 每次提交新代码后预览环境会自动更新。 > > 🗑️ PR 关闭或合并后,预览环境会自动清理。
xiaoxia added 1 commit 2026-09-12 21:40:13 +08:00
test(ai-avatar): 补充B-roll/标题单测,修正断言
CI/CD Pipeline / Dedup Check - skip PR tests when covered by push pipeline (pull_request) Successful in 2s
CI/CD Pipeline / Check if frontend-only change (pull_request) Successful in 2s
CI/CD Pipeline / PR Build Web Image (pull_request) Successful in 1m29s
CI/CD Pipeline / PR Build API Image (pull_request) Successful in 1m31s
CI/CD Pipeline / Frontend Lint (pull_request) Successful in 1m49s
CI/CD Pipeline / Frontend Unit Tests (pull_request) Successful in 2m6s
Preview Deploy / Deploy Preview Environment (pull_request) Successful in 2m20s
CI/CD Pipeline / PR Build Worker Image (pull_request) Successful in 2m49s
PR Automation / Auto Approve on CI Green (pull_request) Successful in 3m22s
AI Code Review / AI Code Review (pull_request) Successful in 6m28s
CI/CD Pipeline / Integration Tests (pull_request) Successful in 6m40s
CI/CD Pipeline / Unit Tests (pull_request) Successful in 7m5s
CI/CD Pipeline / Validate - Style (pull_request) Successful in 7m13s
CI/CD Pipeline / Validate - Python (mypy + alembic) (pull_request) Successful in 8m24s
PR Automation / Auto Merge on CI Green + Approved (pull_request) Successful in 10m38s
CI/CD Pipeline / Validate - Security (pull_request) Has been cancelled
CI/CD Pipeline / Build Production API Image (pull_request) Has been cancelled
CI/CD Pipeline / Build Production Web Image (pull_request) Has been cancelled
CI/CD Pipeline / Build Production Worker Image (pull_request) Has been cancelled
CI/CD Pipeline / Deploy Production (pull_request) Has been cancelled
CI/CD Pipeline / Production Browser E2E (pull_request) Has been cancelled
CI/CD Pipeline / Canary Release to Production (pull_request) Has been cancelled
CI/CD Pipeline / CI Gate (pull_request) Has been cancelled
CI/CD Pipeline / Staging API Integration Tests (pull_request) Failing after 89h43m16s
CI/CD Pipeline / Retag skipped Staging API Image (pull_request) Failing after 89h43m34s
CI/CD Pipeline / Build Staging Web Image (pull_request) Failing after 89h43m13s
CI/CD Pipeline / Build Staging Worker Image (pull_request) Failing after 89h43m13s
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (pull_request) Failing after 89h43m6s
CI/CD Pipeline / ACR Image Cleanup (pull_request) Failing after 89h42m53s
CI/CD Pipeline / Retag skipped Staging Worker Image (pull_request) Failing after 89h43m12s
CI/CD Pipeline / Retag skipped Staging Web Image (pull_request) Failing after 89h43m12s
CI/CD Pipeline / Build Staging API Image (pull_request) Failing after 89h43m14s
CI/CD Pipeline / Staging E2E Tests (pull_request) Failing after 89h42m54s
CI/CD Pipeline / Check push changed paths (pull_request) Failing after 89h43m14s
831075a9c0
xiaoxia added 1 commit 2026-09-12 21:59:18 +08:00
fix(lipsync): 修复Celery事务竞态导致job永远卡在tts_processing(P0)
CI/CD Pipeline / Dedup Check - skip PR tests when covered by push pipeline (pull_request) Successful in 1s
CI/CD Pipeline / Check if frontend-only change (pull_request) Successful in 2s
CI/CD Pipeline / PR Build Web Image (pull_request) Successful in 30s
CI/CD Pipeline / PR Build API Image (pull_request) Successful in 33s
CI/CD Pipeline / Frontend Lint (pull_request) Successful in 1m39s
CI/CD Pipeline / PR Build Worker Image (pull_request) Successful in 1m39s
CI/CD Pipeline / Frontend Unit Tests (pull_request) Successful in 1m47s
PR Automation / Auto Approve on CI Green (pull_request) Successful in 2m44s
Preview Deploy / Deploy Preview Environment (pull_request) Successful in 2m55s
AI Code Review / AI Code Review (pull_request) Successful in 6m31s
CI/CD Pipeline / Integration Tests (pull_request) Successful in 8m15s
CI/CD Pipeline / Unit Tests (pull_request) Successful in 8m17s
CI/CD Pipeline / Validate - Python (mypy + alembic) (pull_request) Successful in 10m28s
CI/CD Pipeline / Validate - Style (pull_request) Has been cancelled
CI/CD Pipeline / Validate - Security (pull_request) Has been cancelled
CI/CD Pipeline / Build Production API Image (pull_request) Has been cancelled
CI/CD Pipeline / Build Production Web Image (pull_request) Has been cancelled
CI/CD Pipeline / Build Production Worker Image (pull_request) Has been cancelled
CI/CD Pipeline / Deploy Production (pull_request) Has been cancelled
CI/CD Pipeline / Production Browser E2E (pull_request) Has been cancelled
CI/CD Pipeline / Canary Release to Production (pull_request) Has been cancelled
CI/CD Pipeline / CI Gate (pull_request) Has been cancelled
PR Automation / Auto Merge on CI Green + Approved (pull_request) Has been cancelled
CI/CD Pipeline / Staging API Integration Tests (pull_request) Failing after 89h23m49s
CI/CD Pipeline / Retag skipped Staging Web Image (pull_request) Failing after 89h23m53s
CI/CD Pipeline / Build Staging Web Image (pull_request) Failing after 89h23m55s
CI/CD Pipeline / Build Staging API Image (pull_request) Failing after 89h23m33s
CI/CD Pipeline / ACR Image Cleanup (pull_request) Failing after 89h23m27s
CI/CD Pipeline / Retag skipped Staging Worker Image (pull_request) Failing after 89h23m31s
CI/CD Pipeline / Build Staging Worker Image (pull_request) Failing after 89h23m33s
CI/CD Pipeline / Staging E2E Tests (pull_request) Failing after 89h23m27s
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (pull_request) Failing after 89h23m28s
CI/CD Pipeline / Retag skipped Staging API Image (pull_request) Failing after 89h23m31s
CI/CD Pipeline / Check push changed paths (pull_request) Failing after 89h24m9s
2fa6de29bc
根因:create_job() 先 apply_async() 发送 Celery 任务,再 db.commit() 提交事务。
worker 是独立进程+独立DB连接,任务<4ms就被消费,但此时 API 事务还未 commit,
worker 查询 job 返回 None → 静默 return 不重试 → job 永远卡在 tts_processing。

修复:
1. API侧(lipsync_service.py):先 db.commit()+db.refresh(job),再 apply_async() 发任务;
   投递失败/MediaKit提交失败分支也各自 commit,确保状态及时落库。
2. Worker侧(lipsync_tts.py):job not found 时改用 self.retry() 递增重试3次
   (1s/3s/7s退避),作为竞态场景的第二道防线;
   增加 autoretry_for=(OSError, ConnectionError) 自动重试网络抖动;
   max_retries 从2调整到5。

子agent在staging实锤:受影响job共5个,手工重投递后全部3秒内完成TTS+提交MediaKit,
证实TTS本身只需要2秒,卡顿完全是因为竞态。

单测:新增 TestCreateJobCommitOrder 验证 commit 在 apply_async 之前。
auto-approve-bot added 1 commit 2026-09-12 22:10:27 +08:00
style: auto-format with black + isort + ruff + prettier [skip ci-format-check]
CI/CD Pipeline / Dedup Check - skip PR tests when covered by push pipeline (pull_request) Successful in 2s
CI/CD Pipeline / Check if frontend-only change (pull_request) Successful in 1s
CI/CD Pipeline / PR Build Web Image (pull_request) Successful in 42s
CI/CD Pipeline / PR Build API Image (pull_request) Successful in 43s
CI/CD Pipeline / PR Build Worker Image (pull_request) Successful in 45s
CI/CD Pipeline / Frontend Unit Tests (pull_request) Successful in 1m4s
CI/CD Pipeline / Frontend Lint (pull_request) Successful in 1m9s
Preview Deploy / Deploy Preview Environment (pull_request) Successful in 2m3s
PR Automation / Auto Approve on CI Green (pull_request) Successful in 2m41s
AI Code Review / AI Code Review (pull_request) Successful in 6m31s
CI/CD Pipeline / Integration Tests (pull_request) Successful in 7m40s
CI/CD Pipeline / Unit Tests (pull_request) Successful in 7m55s
CI/CD Pipeline / Validate - Style (pull_request) Successful in 8m8s
CI/CD Pipeline / Validate - Python (mypy + alembic) (pull_request) Successful in 9m43s
PR Automation / Auto Merge on CI Green + Approved (pull_request) Successful in 10m31s
CI/CD Pipeline / Validate - Security (pull_request) Successful in 23m32s
CI/CD Pipeline / Production Browser E2E (pull_request) Has been skipped
CI/CD Pipeline / CI Gate (pull_request) Successful in 1s
ACR Cleanup / ACR Image Cleanup (pull_request_target) Successful in 8s
Preview Cleanup / Cleanup Preview Environment (pull_request) Successful in 58s
CI/CD Pipeline / Deploy Production (pull_request) Failing after 88h49m41s
CI/CD Pipeline / ACR Image Cleanup (pull_request) Failing after 89h12m30s
CI/CD Pipeline / Build Staging Web Image (pull_request) Failing after 89h12m43s
CI/CD Pipeline / Build Production API Image (pull_request) Failing after 88h49m23s
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (pull_request) Failing after 89h12m9s
CI/CD Pipeline / Retag skipped Staging Worker Image (pull_request) Failing after 89h12m14s
CI/CD Pipeline / Retag skipped Staging API Image (pull_request) Failing after 89h12m15s
CI/CD Pipeline / Build Staging Worker Image (pull_request) Failing after 89h12m21s
CI/CD Pipeline / Build Staging API Image (pull_request) Failing after 89h12m21s
CI/CD Pipeline / Build Production Worker Image (pull_request) Failing after 88h49m23s
CI/CD Pipeline / Staging E2E Tests (pull_request) Failing after 89h12m8s
CI/CD Pipeline / Build Production Web Image (pull_request) Failing after 88h49m23s
CI/CD Pipeline / Canary Release to Production (pull_request) Failing after 88h49m19s
CI/CD Pipeline / Staging API Integration Tests (pull_request) Failing after 89h12m8s
CI/CD Pipeline / Check push changed paths (pull_request) Failing after 89h12m58s
CI/CD Pipeline / Retag skipped Staging Web Image (pull_request) Failing after 89h47m32s
1a4f475fbf
xiaoxia merged commit 4a93aaaf4c into develop 2026-09-12 22:37:12 +08:00

🗑️ 预览环境已清理

PR #1873 已关闭或合并,对应的预览环境已被清理。

如有需要,可以重新打开 PR 来重新生成预览环境。

🗑️ **预览环境已清理** PR #1873 已关闭或合并,对应的预览环境已被清理。 > 如有需要,可以重新打开 PR 来重新生成预览环境。
Sign in to join this conversation.