Data race: VideoReader::onReportPerformance / SequenceReader::reportPerformance read videoDecoder and decodingTime without a lock
Nobody has claimed this yet.
- Dominant language
- HTML
- Stars
- 5.8k
- Forks
- 531
- Avg merge
- 8d 55m
- Merged PRs (30d)
- 17
Description
背景
由 PR #3709 的 review(@shlzxjp)提出,属于 #3709 范围之外的既有问题,单独跟踪。
问题
VideoReader::onReportPerformance(src/rendering/sequences/VideoReader.cpp:94-107)在不持有locker的情况下解引用videoDecoder(读取videoDecoder->isHardwareBacked())。- 基类
SequenceReader::reportPerformance(src/rendering/sequences/SequenceReader.cpp:33-38)也在无锁的情况下读写decodingTime。
竞争窗口
异步解码任务(tgfx TaskGroup 线程)可在 VideoReader::onMakeBuffer 内 destroyVideoDecoder() / 重建 videoDecoder;与此同时,渲染线程在 flush 末尾经 RenderCache::recordPerformance(src/rendering/caches/RenderCache.cpp:512)→ SequenceImageQueue::reportPerformance → SequenceReader::reportPerformance → VideoReader::onReportPerformance 走到同一路径,形成对 videoDecoder 与 decodingTime 的无锁并发读写。
与 #3709 的关系
#3709 为析构路径加锁,缓解了「析构 vs onMakeBuffer」一侧的风险,但上述 reportPerformance 读写竞争与析构锁无关,仍然存在。
建议
评估在 onReportPerformance / reportPerformance 读写 videoDecoder 和 decodingTime 时补充与 onMakeBuffer 一致的加锁保护,或改用原子/快照方式规避竞争。
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Read VideoReader.cpp at onReportPerformance and onMakeBuffer, then trace SequenceReader.cpp, RenderCache.cpp, and SequenceImageQueue::reportPerformance. Compare the existing locking around decoder changes with the performance-reporting reads and writes. Done means videoDecoder and decodingTime are accessed safely across these threads, with the relevant race no longer reproducible.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- computer-graphics
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100