Plugin management rewrite#20
Merged
Merged
Conversation
| finally | ||
| { | ||
| plugin.LoadContext = null; | ||
| loadContext = null; |
| } | ||
|
|
||
| bool leaked = weakRef.IsAlive; | ||
| weakRef = null; |
|
|
||
| for (int i = 0; weakRef.IsAlive && i < MaxUnloadGCAttempts; i++) | ||
| { | ||
| GC.Collect(); |
| { | ||
| GC.Collect(); | ||
| GC.WaitForPendingFinalizers(); | ||
| GC.Collect(); |
xUnit Tests4 tests 4 ✅ 0s ⏱️ Results for commit c38244c. ♻️ This comment has been updated with latest results. |
Member
Author
|
There's still some missing bits, like the plugin installation, but they can be added later |
| get | ||
| { | ||
| if (RegisteredPlugins[registry].Plugin != null) return; | ||
| return Path.Combine(InstallPath!, "Plugins"); |
| { | ||
| get | ||
| { | ||
| return Path.Combine(PluginPath!, "plugins.json"); |
Member
Author
|
It's slightly hard to tell, but plugin unloading may be fixed now. It still says reference leaks exist, but previous issues like the app staying alive after closing when plugins have been unloaded no longer happens. More testing is needed though. |
Comment on lines
+150
to
+156
| catch (Exception ex) | ||
| { | ||
| SDK.logger.WriteLine( | ||
| ILogger.Level.Error, | ||
| $"Plugin \"{id}\" threw an exception during OnShutdown: {ex}" | ||
| ); | ||
| } |
Comment on lines
+286
to
+292
| } catch(Exception ex) | ||
| { | ||
| plugin.LoadContext = null; | ||
| } | ||
|
|
||
| for (int i = 0; weakRef.IsAlive && i < MaxUnloadGcAttempts; i++) | ||
| SDK.logger.WriteLine( | ||
| ILogger.Level.Warn, | ||
| $"Could not fully uninstall plugin with the ID \"{id}\": {ex.Message}" | ||
| ); | ||
| } finally |
Comment on lines
+375
to
+388
| } catch (Exception ex) | ||
| { | ||
| SDK.logger.WriteLine( | ||
| ILogger.Level.Error, | ||
| $"Failed to load plugins list: " + ex.Message | ||
| ); | ||
| SDK.logger.WriteLine( | ||
| ILogger.Level.Warn, | ||
| "Rewriting plugin list with default values. " + | ||
| "The user will need to reinstall plugins." | ||
| ); | ||
|
|
||
| RegisteredPlugins[registry].Enabled = true; | ||
| GenerateDefault(); | ||
| } |
Member
Author
|
Not much I can do for the generic catch clauses |
MrBisquit
marked this pull request as ready for review
July 24, 2026 15:05
Comment on lines
+230
to
+236
| } catch(Exception ex) { | ||
| SDK.logger.WriteLine( | ||
| ILogger.Level.Warn, | ||
| $"Failed to load plugin with ID \"{id}\": {ex.Message}" | ||
| ); | ||
| UnloadPlugin(id); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
https://trello.com/c/x9gHPswn