Skip to content

Plugin Game Settings Subsystem - #900

Merged
neon-nyan merged 22 commits into
mainfrom
plugin
Oct 21, 2026
Merged

neon-nyan merged 22 commits into
mainfrom
plugin

Conversation

@Cryotechnic

@Cryotechnic Cryotechnic commented Aug 18, 2026 •

Copy link
Copy Markdown
Member

Main Goal

Add declarative plugin-defined game settings support to Plugin.Core and render those settings in Collapse.
Also harden plugin integration by:

  • Keeping the game-log callback alive throughout asynchronous game sessions.
  • Hydrating background notifications from an already-running activity’s current progress and status.
  • Correcting Wuthering Waves preload progress totals.

PR Status

  • Overall Status: Complete
  • Commits: Complete
  • Synced to base (Collapse:main): Yes
  • Build status: x64 Debug build passed
  • Crashing: None reported
  • Bugs found caused by PR: 0 reported

Changelog

  • [New] Add declarative plugin-defined game settings support to Plugin.Core and render those settings in Collapse.
  • [Fix] Keep the game-log callback alive throughout asynchronous game sessions.
  • [Fix] Initialize background notifications using the running activity’s current progress and status.
  • [Fix] Correct Wuthering Waves preload progress totals.
  • [Fix] Harden callback lifetimes and native-resource cleanup in plugin integration and background rendering.

Expose `Progress` and `Status` on `IBackgroundActivity` and use them when wiring notification handlers in `BackgroundActivityManager`. This immediately initializes notification text/progress for already-running activities instead of waiting for the next event, preventing placeholder content from lingering.
Add a reusable speed-calculator reset helper in `ProgressBase` and use it in plugin install progress updates to avoid bogus speed deltas after state transitions. The wrapper now resets its download baseline when install state changes, computes per-tick bytes only from monotonic progress, and clears speed/time-left values appropriately. It also ensures completed installs report zero time left and clamp per-file progress to 100%.
Refactor GSP into a responsive multi-column layout while keeping informational sections full width
@socket-security

socket-security Bot commented Sep 16, 2026 •

Copy link
Copy Markdown

No dependency changes detected. Learn more about Socket for GitHub.

👍 No dependency changes detected in pull request

@Cryotechnic
Cryotechnic marked this pull request as ready for review September 30, 2026 16:30
@Cryotechnic Cryotechnic changed the title [DRAFT] Plugin Game Settings Subsystem Plugin Game Settings Subsystem Sep 30, 2026

@neon-nyan neon-nyan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Any changes to the BG-related so far. For the game settings related, still waiting for my game to be installed first.

public sealed partial class PluginGameSettingsPage
{
private readonly GameSettingsExtension.GameSettingsContext _context;
private readonly TextBlock _statusText = new()

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Bug: The _statusText TextBlock, intended for displaying plugin setting errors, is never added to the visual tree, so error messages are invisible to the user.
Severity: MEDIUM

Suggested Fix

The _statusText TextBlock should be added to a visible parent container within the page's XAML layout, such as a Grid or StackPanel. This will ensure that when its Text property is updated with an error message, it is rendered and becomes visible to the user.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.

Location:
CollapseLauncher/XAMLs/MainApp/Pages/GameSettingsPages/PluginGameSettingsPage.cs#L31

Potential issue: In `PluginGameSettingsPage`, a `TextBlock` named `_statusText` is
instantiated to display error messages that occur when a plugin setting is changed.
However, this control is never added to the page's visual tree. When a user interacts
with a setting and the plugin's `_context.SetValue()` method throws an exception, the
`SetStatus(ex.Message, true)` method is called. This updates the `Text` property of
`_statusText`, but because the control is not rendered, the error message remains
invisible to the user, leading to silent failures.

Also affects:

  • CollapseLauncher/XAMLs/MainApp/Pages/GameSettingsPages/PluginGameSettingsPage.cs:279~296

bagusnl and others added 11 commits October 1, 2026 10:02
- Extract FFmpeg decoder checks into `RequiresFFmpegDecoder` and reuse it across codec detection and loader paths.
- Treat 10-bit YUV420 (`AV_PIX_FMT_YUV420P10LE/BE`) as requiring FFmpeg, improving handling for High 10 H.264 backgrounds that Windows decoders may not support.
- Tighten background reload behavior by comparing decoder mode before skipping reloads.
- Layer setup now starts hidden, restores opacity after attach, and only sets a foreground overlay for video backgrounds.
- Improves `LayeredBackgroundImage` video initialization robustness by logging `MediaFailed` events, handling stale/invalid playback session size reads, and making render-target setup fail-safe with explicit success/failure returns.

- Add proper native interface acquisition for DrawImageToRect, ensures acquired COM references are released correctly, detaches NaturalVideoSizeChanged on teardown, and clears frame player state during disposal to prevent leaks and stale callbacks.
- Improve LayeredBackgroundImage media handling to avoid race conditions and invalid state during video setup.
- Render target initialization now fails safely and resets init state, FFmpeg source opening validates the active player before wiring it, and media-open flow now responds to natural size changes before creating the frame image.
- Fix UI layering by hiding the foreground grid for static backgrounds (and restoring it for normal mode), and allows non-autoplay video to start when play was explicitly requested.
Use GameSettingsPageBase
+ Change CanvasVirtualImageSource -> CanvasImageSource
+ Simplify atomic check on the renderer state
+ Handle device lost and context lost catch correctly
+ Remove lock-based spin
Still had issues with hard crash while trying to re-create the device context for the CanvasImageSource
The .Dispose() still require to be called from the UI thread
@neon-nyan

Copy link
Copy Markdown
Member

As per internal discussion, this PR is approved. Merging for now

@neon-nyan
neon-nyan merged commit be512bb into main Oct 21, 2026
8 of 10 checks passed
@neon-nyan neon-nyan mentioned this pull request Oct 21, 2026
neon-nyan added a commit that referenced this pull request Oct 21, 2026
![UpdateIsAvailable-Campaign-Columbina](https://github.com/user-attachments/assets/e7043018-4d49-48f2-adf1-3c846fd3c3e4)
# Preview 1.84.7 (Codename: Columbina)

# What's Changed? - 1.84.7
## **[New]** [Game Settings Subsystem Support for Supported Plugin-based
Games](#900), by
@Cryotechnic
We have implemented a new Update 6 extension for v1 API Standard. The
plugin developer could now add customizations to the game into Collapse
Launcher. To see the example of the implementation, see the source code
of our Wuthering Waves plugin
[here](https://github.com/CollapseLauncher/Hi3Helper.Plugin.Wuwa/tree/main/Hi3Helper.Plugin.Wuwa/Management/Settings).

<img width="962" height="541" alt="image"
src="https://github.com/user-attachments/assets/1f668111-fbf7-445a-b90c-70c1693ba87b"
/>

## **[Imp]** [Optimizing Background Video/Image
Renderer](#915), by
@neon-nyan
Optimizing the Background Video/Image Load routines and provides better
memory allocation after dispose/use of each frames. The following PR
also provides major improvements on the frame renderer for the
background video playback, including direct GPU drawn to the frame's
IDirect3DTexture outside of the UI thread, which reduces the VRAM usage
and (hopefully) stutters.

### Video Background Playing (Honkai Impact 3rd - Mainland China -
Picture 2 1080p)
| Mem: Current Release | Mem: This PR | VRAM: Current Release | VRAM:
This PR |
|----|----|----|----|
|
![](https://github.com/user-attachments/assets/571431d9-aebc-438b-b2de-6386eb91654f)
|
![](https://github.com/user-attachments/assets/81a8c619-c29c-44cf-b35a-c17b92399c4a)
|
![](https://github.com/user-attachments/assets/29a3d4b7-fc4d-4e2c-9795-793d089efde9)
|
![](https://github.com/user-attachments/assets/455d75ae-bba1-4b73-aa0b-350114b6227b)
|
### Video Background On-Pause/Window minimized (Custom Video 2160p)
| Mem: Current Release | Mem: This PR | VRAM: Current Release | VRAM:
This PR |
|----|----|----|----|
|
![](https://github.com/user-attachments/assets/8894a3f4-f67c-4d17-a008-189ad2299a75)
|
![](https://github.com/user-attachments/assets/4da743c4-ba44-4859-bd8f-b080bd61038b)
|
![](https://github.com/user-attachments/assets/1f1dcb14-5998-4ec3-b967-bd4cc2a1bd0f)
|
![](https://github.com/user-attachments/assets/a5101117-eb56-41c5-84da-ca28f1d02fcf)
|

- **[Fix]** Race Conditions in Sophon API Loader causing Available Game
Version reverted to Deprecated ZIP API, by @neon-nyan
- **[New]** Sync game settings to database by @bagusnl, @neon-nyan 
- Now users with DB subsystem set-up can backup their game settings to
the configured DB endpoint. Uses Collapse' way of saving registry so
storage shouldn't be a problem.
- Guide on setting Collapse' DB subsystem is here
https://collapselauncher.com/feature/database.html
- **[Imp]** DiscordRPC fixes and stability improvements by @neon-nyan 
- **[Imp]** Improved Collapse settings loading time by initializing
Waifu2x at startup time by @neon-nyan
- **[Imp]** Improved video background playback by reducing animation in
carousel by @neon-nyan
  - Should be smoother and less prone of frame skip now
- **[Imp]** Background CPU and Memory utilizations by @neon-nyan 
- CPU utilization should be next to 0 when Collapse is minimized (and to
tray) by hiding WinUI elements.
- Memory utilization is improved by running more aggressive
garbage-collections
- **[Fix]** Region without static images uses last loaded region
background resources by @neon-nyan


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

</details>
@neon-nyan neon-nyan mentioned this pull request Oct 21, 2026
neon-nyan added a commit that referenced this pull request Oct 21, 2026
![UpdateIsAvailable-Campaign-Columbina](https://github.com/user-attachments/assets/e7043018-4d49-48f2-adf1-3c846fd3c3e4)
# Stable 1.84.7 (Codename: Columbina)

# What's Changed? - 1.84.7
## **[New]** [Game Settings Subsystem Support for Plugin-based
Games](#900), by
@Cryotechnic
We have implemented a new Update 6 extension for v1 API Standard. The
plugin developer could now add customizations to the game into Collapse
Launcher. To see the example of the implementation, see the source code
of our Wuthering Waves plugin
[here](https://github.com/CollapseLauncher/Hi3Helper.Plugin.Wuwa/tree/main/Hi3Helper.Plugin.Wuwa/Management/Settings).

<img width="962" height="541" alt="image"
src="https://github.com/user-attachments/assets/1f668111-fbf7-445a-b90c-70c1693ba87b"
/>

## **[Imp]** [Optimizing Background Video/Image
Renderer](#915), by
@neon-nyan
Optimizing the Background Video/Image Load routines and provides better
memory allocation after dispose/use of each frames. The following PR
also provides major improvements on the frame renderer for the
background video playback, including direct GPU drawn to the frame's
IDirect3DTexture outside of the UI thread, which reduces the VRAM usage
and (hopefully) stutters.

### Video Background Playing (Honkai Impact 3rd - Mainland China -
Picture 2 1080p)
| Mem: Current Release | Mem: This PR | VRAM: Current Release | VRAM:
This PR |
|----|----|----|----|
|
![](https://github.com/user-attachments/assets/571431d9-aebc-438b-b2de-6386eb91654f)
|
![](https://github.com/user-attachments/assets/81a8c619-c29c-44cf-b35a-c17b92399c4a)
|
![](https://github.com/user-attachments/assets/29a3d4b7-fc4d-4e2c-9795-793d089efde9)
|
![](https://github.com/user-attachments/assets/455d75ae-bba1-4b73-aa0b-350114b6227b)
|
### Video Background On-Pause/Window minimized (Custom Video 2160p)
| Mem: Current Release | Mem: This PR | VRAM: Current Release | VRAM:
This PR |
|----|----|----|----|
|
![](https://github.com/user-attachments/assets/8894a3f4-f67c-4d17-a008-189ad2299a75)
|
![](https://github.com/user-attachments/assets/4da743c4-ba44-4859-bd8f-b080bd61038b)
|
![](https://github.com/user-attachments/assets/1f1dcb14-5998-4ec3-b967-bd4cc2a1bd0f)
|
![](https://github.com/user-attachments/assets/a5101117-eb56-41c5-84da-ca28f1d02fcf)
|

- **[Fix]** Race Conditions in Sophon API Loader causing Available Game
Version reverted to Deprecated ZIP API, by @neon-nyan
- **[New]** Sync game settings to database by @bagusnl, @neon-nyan 
- Now users with DB subsystem set-up can backup their game settings to
the configured DB endpoint. Uses Collapse' way of saving registry so
storage shouldn't be a problem.
- Guide on setting Collapse' DB subsystem is here
https://collapselauncher.com/feature/database.html
- **[Imp]** DiscordRPC fixes and stability improvements by @neon-nyan 
- **[Imp]** Improved Collapse settings loading time by initializing
Waifu2x at startup time by @neon-nyan
- **[Imp]** Improved video background playback by reducing animation in
carousel by @neon-nyan
  - Should be smoother and less prone of frame skip now
- **[Imp]** Background CPU and Memory utilizations by @neon-nyan 
- CPU utilization should be next to 0 when Collapse is minimized (and to
tray) by hiding WinUI elements.
- Memory utilization is improved by running more aggressive
garbage-collections
- **[Fix]** Region without static images uses last loaded region
background resources by @neon-nyan


<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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants