close
Skip to content

perf(MediaSessionManager): 减少时间线更新的节流间隔#840

Merged
apoint123 merged 1 commit intoimsyy:devfrom
MoYingJi:pr/a
Feb 7, 2026
Merged

perf(MediaSessionManager): 减少时间线更新的节流间隔#840
apoint123 merged 1 commit intoimsyy:devfrom
MoYingJi:pr/a

Conversation

@MoYingJi
Copy link
Copy Markdown
Collaborator

@MoYingJi MoYingJi commented Feb 7, 2026

在 MPRIS 上,播放进度有时会有一些奇怪的延迟(最多慢 1~2s)

我尝试降低节流间隔,发现此问题有明显缓解(在我的电脑上测试 3 天,延迟被降低至 1s 以内)

此更改不应影响其他行为,包括其他操作系统的行为,也不应造成性能问题

在 MPRIS 上,播放进度有时会有一些奇怪的延迟(最多慢 1~2s)

我尝试降低节流间隔,发现此问题有明显缓解(在我的电脑上测试 3 天,延迟被降低至 1s 以内)

此更改不应影响其他行为,包括其他操作系统的行为,也不应造成性能问题
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @MoYingJi, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

此拉取请求旨在提高媒体会话时间线更新的响应速度,特别是解决在 MPRIS 上观察到的播放进度延迟问题。通过显著缩短时间线更新的节流间隔,预计此更改将缓解这些延迟,而不会对性能或在其他操作系统上的行为产生负面影响。

Highlights

  • 节流间隔调整: 将 MediaSessionManagersendMediaTimeline 函数的节流间隔从 1000 毫秒减少到 200 毫秒,以改善 MPRIS 上的播放进度延迟问题。
Changelog
  • src/core/player/MediaSessionManager.ts
    • throttledSendTimeline 函数的节流间隔从 1000ms 调整为 200ms。
Activity
  • 目前没有检测到额外的评论或审查活动。
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

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 通过减少 throttledSendTimeline 的节流间隔,有效地解决了 MPRIS 播放进度更新延迟的问题,这是一个很好的性能优化。代码更改本身是正确的。我提出的具体评论是一个关于进一步优化 Web 平台体验的建议,与现有规则没有冲突,因此予以保留。总体来说,这是一个高质量的改进!

Comment on lines 26 to +28
private throttledSendTimeline = throttle((currentTime: number, duration: number) => {
sendMediaTimeline(currentTime, duration);
}, 1000);
}, 200);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

降低此处的节流间隔以匹配 PlayerControlleronTimeUpdate 的 200ms 间隔是很好的优化,可以有效减少 MPRIS 的更新延迟。

为了保持一致性并同样优化 Web 平台的体验,建议也考虑将 throttledUpdatePositionState 的节流间隔(位于第 312 行)从 1000ms 降低到 200ms。

这样可以确保无论是原生集成还是 Web API,媒体会话的进度更新频率都能与播放器的核心时间更新频率保持同步,从而在所有平台上都提供更即时的反馈。

@apoint123 apoint123 merged commit d450521 into imsyy:dev Feb 7, 2026
@MoYingJi MoYingJi deleted the pr/a branch February 7, 2026 13:53
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.

2 participants