Skip to content

🐞 fix: 修复任务栏歌词的歌词意外跳转 bug#857

Merged
imsyy merged 1 commit into
SPlayer-Dev:devfrom
apoint123:fix/lyric-jump
Feb 10, 2026
Merged

🐞 fix: 修复任务栏歌词的歌词意外跳转 bug#857
imsyy merged 1 commit into
SPlayer-Dev:devfrom
apoint123:fix/lyric-jump

Conversation

@apoint123
Copy link
Copy Markdown
Member

只有当 IPC 时间与本地时间误差超过 100ms 时,才同步 IPC 的时间

IPC 传来的时间有约 50ms 的延迟,可能导致 rAF 的时间抢跑了 50ms 显示到了下一行歌词,而 IPC 传的时间又把歌词拉回到上一句

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Warning

Gemini encountered an error creating the summary. You can try again by commenting /gemini summary.

@apoint123
Copy link
Copy Markdown
Member Author

/gemini summary

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

此拉取请求旨在解决任务栏歌词显示中一个令人困扰的意外跳转错误。通过引入一个时间同步阈值,并优化 IPC 消息处理逻辑,确保歌词仅在必要时才进行时间同步,从而显著提升了歌词显示的稳定性和用户体验,避免了因细微时间偏差导致的歌词回溯问题。

Highlights

  • 修复任务栏歌词意外跳转问题: 解决了任务栏歌词在播放过程中可能出现的意外跳转问题,该问题是由于 IPC 时间与本地时间之间的微小延迟导致的。
  • 引入时间同步阈值: 引入了一个名为 "SYNC_THRESHOLD_MS" 的新常量,其值为 100 毫秒,用于定义 IPC 时间与本地时间之间的最大可接受误差。
  • 优化 IPC 时间同步逻辑: 修改了 "taskbar:update-progress" IPC 处理器,使其仅在 IPC 报告的 "currentTime" 与当前 "state.currentTime" 之间的绝对差值超过 "SYNC_THRESHOLD_MS" 时才更新歌词时间,从而避免因微小时间差异导致的歌词频繁回跳。
Changelog
  • src/views/TaskbarLyric/index.vue
    • 新增了一个名为 "SYNC_THRESHOLD_MS" 的常量,并附带详细注释,解释了其作用是定义 IPC 时间与本地时间同步的误差阈值(100ms)。
    • 修改了 "taskbar:update-progress" IPC 事件的处理逻辑。现在,它会计算 IPC 传来的 "currentTime" 与组件内部 "state.currentTime" 之间的绝对差值。
    • 如果这个差值小于或等于 "SYNC_THRESHOLD_MS" 且播放器处于播放状态("state.isPlaying" 为 true),则会跳过 "currentTime" 的更新,以防止歌词因微小的时间差异而频繁跳转。
Activity
  • gemini-code-assist[bot] 报告了创建摘要时遇到的错误。
  • apoint123 再次请求生成摘要。

@apoint123
Copy link
Copy Markdown
Member Author

/gemini review

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

这个 PR 旨在修复任务栏歌词意外跳转的 bug。通过引入一个 100ms 的阈值,只有当 IPC 传输的时间与本地时间的误差超过这个值时,才进行同步。这样可以有效避免因 IPC 的轻微延迟(约 50ms)导致 requestAnimationFrame 估算的时间超前,从而引发歌词在两句之间来回跳动的问题。这个改动逻辑清晰,针对性地解决了问题,代码质量很高。我没有发现其他需要修改的地方。

@imsyy imsyy merged commit c7002c0 into SPlayer-Dev:dev Feb 10, 2026
@apoint123 apoint123 deleted the fix/lyric-jump branch February 10, 2026 16:22
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.

3 participants