Skip to content

Save Idle CPU Cycles from SharpDiscordRPC#845

Merged
neon-nyan merged 3 commits intomainfrom
discordrpc-idlecpufix
Dec 26, 2025
Merged

Save Idle CPU Cycles from SharpDiscordRPC#845
neon-nyan merged 3 commits intomainfrom
discordrpc-idlecpufix

Conversation

@neon-nyan
Copy link
Member

@neon-nyan neon-nyan commented Dec 21, 2025

Main Goal

This PR updates the RPC submodule which contains CPU cycles fix on idle. This switches the loop-based routine on reading RPC frames to timer-based routine. Both previous loop-based and new timer-based routine uses the same Poll rate for 1000ms each. We also switched the buffer allocation to rent-based buffer.

The difference between these two methods are, loop-based uses WaitHandleEvent to Sleep on background threads with endless loop routine, thus continuously wasting thread time on each poll rate (every 1000ms) while performing RPC update. Timer-based routine instead, uses Timer to trigger the RPC update on each poll rate (every 1000ms) and will end the thread once it's done.

The behavior shouldn't be affected as it only switching the loop routine with timer and the poll rate for frame reading is still the same.

image

PR Status :

  • Overall Status : Done
  • Commits : Done
  • Synced to base (Collapse:main) : Yes
  • Build status : OK
  • Crashing : No
  • Bug found caused by PR : 2 (per commented)

Templates

Changelog Prefixes
  **[New]**
  **[Imp]**
  **[Fix]**
  **[Loc]**
  **[Doc]**

@neon-nyan neon-nyan marked this pull request as ready for review December 21, 2025 11:26
@neon-nyan
Copy link
Member Author

@sentry review

@neon-nyan neon-nyan self-assigned this Dec 21, 2025
@neon-nyan neon-nyan added Enhancement New feature or request Area: Runtime Issue labeled for runtime, Hi3Helper.Core and other libraries used by Collapse Priority: Low Size: Small labels Dec 21, 2025
@bagusnl
Copy link
Member

bagusnl commented Dec 21, 2025

Need check behavior on arrpc based clients.
Will do

@bagusnl
Copy link
Member

bagusnl commented Dec 21, 2025

arrpc client works
image

@bagusnl
Copy link
Member

bagusnl commented Dec 21, 2025

Bug found

  1. RPC fails to reconnect on Discord client restart. Both in arrpc and official client

Repro step:
Start Discord -> Start Collapse -> Stop Discord -> Observe log -> start Discord -> Observe log -> Switch Collapse pages (do not switch Game/region)

image
  1. Stuck client did not get disposed/cleared on game switch

Repro step:
Start Discord -> Start Collapse -> Stop Discord -> Observe log -> start Discord -> Observe log -> Switch Collapse game

image

@neon-nyan
Copy link
Member Author

@bagusnl The issue mentioned above should have been fixed with the commit above. Can you confirm it at your end?

@neon-nyan neon-nyan merged commit 0611ec7 into main Dec 26, 2025
8 checks passed
@bagusnl bagusnl mentioned this pull request Jan 4, 2026
bagusnl added a commit that referenced this pull request Jan 4, 2026
# What's changed? - 1.83.14
- **[New]** Allow game process to be run as child process of Collapse,
by @gablm
  - This allows stuff like Steam Overlay/controls to work.
  - User can enable it under Game Settings -> Advanced Settings.
- **[New]** [ZZZ] DirectX 12 and Ray Tracing experimental settings, by
@neon-nyan
- User can use DirectX 12 and RT/Upscaling in-game natively. You will
need to enable the DirectX 12 option under game settings.
- Availability of certain options depends on the system you are running
on.
- Do note that the game **MIGHT stutter** on any new scene/sprite loads,
and depending on your system it might be slow/fast.
  - The longer you play, the stutter should go away.
- Ray tracing comparison:
#853 (comment)
- **[Fix]** Misc settings not loading, by @gablm 
  - This affected stuff like Advanced game settings, command line, etc
- **[Imp]** Reduce CPU usage in Discord RPC module, by @neon-nyan 
  - More details: #845
- **[Fix]** Plugin news not reloaded on page/region refresh, by @gablm 
- **[Fix]** [ZZZ] Game Settings reset after using Collapse' GSP, by
@shatyuka
- **[Fix]** Discord RPC did not get disabled globally, by @bagusnl
@neon-nyan
  - More details: #849
- **[Fix]** HSR Repair/Cache update method, by @neon-nyan 
  - More details: #852
  - TL;DR: Completely rewritten
- **[Fix]** Sophon not resuming update, by @neon-nyan 
- After cancelling/pausing game update, the launcher should now perform
checks on which assets already updated so only the necessary files are
getting downloaded.
- **[Fix]** [ZZZ] Deleted assets gets redownloaded on update, by
@neon-nyan
  - More details: #854
- **[Fix]** Game update does not work on games without separate audio
package, by @gablm
- **[Fix]** Playtime counter not stopped after user switched game/region
mid-session, by @gablm
- **[Fix]** Directory might not get created when updating game through
Sophon, by @neon-nyan
- **[Fix]** Main Page's Carousel did not get stopped/paused when told
to, by @bagusnl
- Carousel now should get paused if you sent Collapse to tray or when
Collapse is not on the foreground.
- This is interim fix while the whole background subsystem is getting
rewritten by @neon-nyan.
  - More details: #846

### Templates

<details>
  <summary>Changelog Prefixes</summary>
  
  ```
    **[New]**
    **[Imp]**
    **[Fix]**
    **[Loc]**
    **[Doc]**
  ```

</details>
@bagusnl bagusnl mentioned this pull request Jan 10, 2026
bagusnl added a commit that referenced this pull request Jan 10, 2026
# What's changed? - 1.83.14
- **[New]** Allow game process to be run as child process of Collapse,
by @gablm
  - This allows stuff like Steam Overlay/controls to work.
  - User can enable it under Game Settings -> Advanced Settings.
- **[New]** [ZZZ] DirectX 12 and Ray Tracing experimental settings, by
@neon-nyan
- User can use DirectX 12 and RT/Upscaling in-game natively. You will
need to enable the DirectX 12 option under game settings.
- Availability of certain options depends on the system you are running
on.
- Do note that the game **MIGHT stutter** on any new scene/sprite loads,
and depending on your system it might be slow/fast.
  - The longer you play, the stutter should go away.
- Ray tracing comparison:
#853 (comment)
- **[Fix]** Misc settings not loading, by @gablm 
  - This affected stuff like Advanced game settings, command line, etc
- **[Imp]** Reduce CPU usage in Discord RPC module, by @neon-nyan 
  - More details: #845
- **[Fix]** Plugin news not reloaded on page/region refresh, by @gablm 
- **[Fix]** [ZZZ] Game Settings reset after using Collapse' GSP, by
@shatyuka
- **[Fix]** Discord RPC did not get disabled globally, by @bagusnl
@neon-nyan
  - More details: #849
- **[Fix]** HSR Repair/Cache update method, by @neon-nyan 
  - More details: #852
  - TL;DR: Completely rewritten
- **[Fix]** Sophon not resuming update, by @neon-nyan 
- After cancelling/pausing game update, the launcher should now perform
checks on which assets already updated so only the necessary files are
getting downloaded.
- **[Fix]** [ZZZ] Deleted assets gets redownloaded on update, by
@neon-nyan
  - More details: #854
- **[Fix]** Game update does not work on games without separate audio
package, by @gablm
- **[Fix]** Playtime counter not stopped after user switched game/region
mid-session, by @gablm
- **[Fix]** Directory might not get created when updating game through
Sophon, by @neon-nyan
- **[Fix]** Main Page's Carousel did not get stopped/paused when told
to, by @bagusnl
- Carousel now should get paused if you sent Collapse to tray or when
Collapse is not on the foreground.
- This is interim fix while the whole background subsystem is getting
rewritten by @neon-nyan.
  - More details: #846

### Templates

<details>
  <summary>Changelog Prefixes</summary>
  
  ```
    **[New]**
    **[Imp]**
    **[Fix]**
    **[Loc]**
    **[Doc]**
  ```

</details>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: Runtime Issue labeled for runtime, Hi3Helper.Core and other libraries used by Collapse Enhancement New feature or request Priority: Low Size: Small

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants