You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I don't know if SPL is supposed to do anything with additional threads, but the way it works right now is that if a plugin spawns a new thread, the thread will persist after reloading. New plugin instance will spawn it's own thread too, so as a result there will be 2 threads existing at the same time.
New threads can spawn implicitly. FileSystemWatcher fires it's events in a separate thread, and it persists after a reload too.
The result is this mess:
Screenshot
PS. Also it seems that SPL fires events for reloaded plugins before OnLoad(). This does not happen without reloading, when the game is launched from zero.
publicvoidOnLoad(){localizationManager.Init();configManager.Init();}publicvoidOnImGuiFreeRender(){// Access data in localizationManager or configManager// ---> Exceptions}
To Reproduce
Make a plugin with FileSystemWatcher or with Thread.Run() containing repeating console output;
Launch the game;
Hot-reload the plugin;
Observe.
Expected Behavior
If it is a bug with SPL, it should be fixed. Otherwise, maybe there should be IPlugin.OnUnload() event where plugins can dispose of resources and threads, and finalize gracefully.
Priority
Suggested P3 Priority. The issue affects the development of plugins.
PC Specs
Show/Hide
Motherboard: Asus ROG Strix Z390-H Gaming
CPU: Intel Core i9-9900k
RAM: 32 GB 3200MHz
GPU: Nvidia GeForce RTX 3090 Ti
System and Game SSD: Samsung SSD 970 EVO Plus NVMe M.2 1TB
Plugin Repo SSD: Western Digital Blue SATA M.2 2280 2TB
Environment
Show/Hide
OS: Window 10 Enterprise Version 22H2 (OS Build 19045.3996)
Good point. I never even thought about that. There is an existing system that goes over all fields in a plugin, and for any that implement IDisposable it calls Dispose on it. So for Task.Run, storing the resulting task as a field in your plugin should result in it being cleaned up. However this does not work for System.Thread.
So yes, perhaps having an OnUnload event like you suggested would be beneficial.
Regarding events being fired pre-OnLoad. Thanks for reporting that. I will change that so no events are called before OnLoad completes. (With the exception of OnPreMain and OnWinMain)
Describe The Bug
I don't know if SPL is supposed to do anything with additional threads, but the way it works right now is that if a plugin spawns a new thread, the thread will persist after reloading. New plugin instance will spawn it's own thread too, so as a result there will be 2 threads existing at the same time.
This happens with
Task.Run()
:After 2 reloads:
New threads can spawn implicitly.
FileSystemWatcher
fires it's events in a separate thread, and it persists after a reload too.The result is this mess:
Screenshot
PS. Also it seems that SPL fires events for reloaded plugins before
OnLoad()
. This does not happen without reloading, when the game is launched from zero.To Reproduce
FileSystemWatcher
or withThread.Run()
containing repeating console output;Expected Behavior
If it is a bug with SPL, it should be fixed. Otherwise, maybe there should be
IPlugin.OnUnload()
event where plugins can dispose of resources and threads, and finalize gracefully.Priority
Suggested P3 Priority. The issue affects the development of plugins.
PC Specs
Show/Hide
Motherboard
: Asus ROG Strix Z390-H GamingCPU
: Intel Core i9-9900kRAM
: 32 GB 3200MHzGPU
: Nvidia GeForce RTX 3090 TiSystem and Game SSD
: Samsung SSD 970 EVO Plus NVMe M.2 1TBPlugin Repo SSD
: Western Digital Blue SATA M.2 2280 2TBEnvironment
Show/Hide
OS
: Window 10 Enterprise Version 22H2 (OS Build 19045.3996)Monster Hunter: World
: v15.21.00SharpPluginLoader
: pre-v0.0.4.0 (a66b29a)Nvidia Drivers
: v551.52Game Display Settings
Show/Hide
DirectX 12 API
: OnScreen Mode
: Borderless WindowResolution Settings
: 2880x1620 (Supersampled down to 1920x1080)Aspect Ratio
: Wide (16:9)Nvidia DLSS
: OffFidelityFX CAS + Upscaling
: OffFrame Rate
: No LimitV-Sync
: OnGame Advanced Graphics Settings
Show/Hide
Image Quality
: HighTexture Quality
: High Resolution Texture PackAmbient Occlusion
: HighVolume Rendering Quality
: HighestShadow Quality
: HighCapsule AO
: OnContact Shadows
: OnAnti-Aliasing
: OffLOD Bias
: HighMax LOD Level
: No LimitFoliage Sway
: OnSubsurface Scattering
: OnScreen Space Reflection
: OnAnisotropic Filtering
: HighestWater Reflection
: OnSnow Quality
: HighSH Diffuse Quality
: HighDynamic Range
: 64-bitMotion Blur
: OnDOF (Depth of Field)
: OnVignette Effects
: NormalZ-Prepass
: OnMods and External Tools:
Show/Hide
Additional Context
Plugin Repo
The text was updated successfully, but these errors were encountered: