Skip to content

[DiscordRPC] Fix RPC showing previous song on Linux#202

Merged
Inrixia merged 2 commits intoInrixia:devfrom
Alan7A:dev
Dec 8, 2025
Merged

[DiscordRPC] Fix RPC showing previous song on Linux#202
Inrixia merged 2 commits intoInrixia:devfrom
Alan7A:dev

Conversation

@Alan7A
Copy link
Copy Markdown
Contributor

@Alan7A Alan7A commented Dec 8, 2025

Discord RPC displayed the previous track after a song transition.
This seems to be caused by a race condition between the TIME_UPDATE and onMediaTransition events, combined with asyncDebounce. A delayed, debounced TIME_UPDATE could call updateActivity with stale data and overwrite the newer info from onMediaTransition, so Discord ends up showing the previous track.

What I changed:

  • Removed TIME_UPDATE interception: Discord calculates playback progress locally using startTimestamp/endTimestamp, making constant updates unnecessary
  • Pass mediaItem directly to updateActivity in onMediaTransition: Ensures the correct media item is used immediately, avoiding stale data from fromPlaybackContext()
  • Removed asyncDebounce: No longer needed since TIME_UPDATE was the main source of rapid calls

Result:

  • Fewer RPC calls
  • Song transitions now update Discord immediately and correctly

I tested on Linux and Windows, the plugin seems to work as expected on both. Any feedback is welcome :)

Copy link
Copy Markdown
Owner

@Inrixia Inrixia left a comment

Choose a reason for hiding this comment

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

This looks awesome!
Could you unwrap MediaItem.onMediaTransition

Otherwise is perfect and will merge as soon as that's sorted 💜

Comment thread plugins/DiscordRPC/src/index.ts Outdated
@Alan7A
Copy link
Copy Markdown
Contributor Author

Alan7A commented Dec 8, 2025

Sure!! It's done :)

@Inrixia Inrixia merged commit 065e9fc into Inrixia:dev Dec 8, 2025
@Inrixia
Copy link
Copy Markdown
Owner

Inrixia commented Dec 8, 2025

Perfect! Thanks

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