镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

discord: fix rich presence never initialising due to early return - #20097

Open
deltaryz wants to merge 1 commit into
libretro:masterfrom
deltaryz:master
Open

deltaryz wants to merge 1 commit into
libretro:masterfrom
deltaryz:master

Conversation

@deltaryz

@deltaryz deltaryz commented Nov 15, 2026 •

Copy link
Copy Markdown

Discord_Initialize() returns early when discord_rpc_inst is NULL, then allocates it below that check.

Because of the early return, the allocation is unreachable, and discord_rpc_inst is not initialized. discord_rpc_create() never runs at all, discord_rpc_inst_valid stays false, and every discord_update_connection() returns before discord_pipe_open() is reached. Presence could not initialize at all, rendering the whole feature nonfunctional.

Discord_Initialize() has one caller:

  • discord_init() via CMD_EVENT_DISCORD_INIT
    Nothing else assigns that pointer, so this is not configuration- or platform-specific.

Cause

Introduced in 7f64df9, which turned the RPC instance into a pointer and placed the NULL check above the allocation that sets it. Presence has been dead in every build with HAVE_DISCORD since.

Testing

  • built with HAVE_DISCORD = 1 and ran against a listener bound at $XDG_RUNTIME_DIR/discord-ipc-0
    • before the change discord_pipe_open() is never called.
    • after applying the fix, the initial handshake arrives and presence shows Playing / In-Menu in Discord
  • re-init after Discord_Shutdown() still allocates and re-validates cleanly

Pinging @LibretroAdmin

Fixes #20096

image

`Discord_Initialize()` returns early when `discord_rpc_inst` is NULL, then allocates it below that check. Because of the early return, the allocation is unreachable, and `discord_rpc_inst` is not initialized. `discord_rpc_create()` never runs at all, `discord_rpc_inst_valid` stays false, and every `discord_update_connection()` returns before `discord_pipe_open()` is reached. Presence could not initialise in any build with HAVE_DISCORD, rendering the whole feature nonfunctional.

Remove the early return (the check further down already handles failure).
@deltaryz

Copy link
Copy Markdown
Author

I'm not sure if editing the body after opening the PR does a ping, so just in case it didnt (sorry) - pinging discord.c contributor @LibretroAdmin for review

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.

Discord Rich Presence never initialises (no connection attempt, no log line)

1 participant