Comments (4)
FindObjectsOfType() call in ModuleKISInventory.cs:835 seems to be the cause of this. Functions like Object.FindObjectsOfType(), Resources.FindObjectsOfTypeAll() etc. are extremly slow and should be avoided whereever possible, especially in methods that are called per-frame. A single such call per frame has drastic impact on framerate.
from kis.
I've gotten this as well.
Theres also some camera wierdness going on in the VAB.SPH that might be related.
The lag is particularily bad when at a base that is already laggy
from kis.
The call to FindObjectsOfType in ModuleKISInventory can be eliminated by adding a component to the window prefab which updates a static list of open UIPartActionWindows. Example:
[KSPAddon(KSPAddon.Startup.EditorAny, true)]
public class InitPartActionWindowTracker : MonoBehaviour
{
private void Awake() { UIPartActionWindowTracker.Init(); }
}
[KSPAddon(KSPAddon.Startup.Flight, true)]
public class FlightBootstrapper : InitPartActionWindowTracker
{
}
public class UIPartActionWindowTracker
{
private class WindowTrackerComponent : MonoBehaviour
{
private void Awake() { Add(GetComponent<UIPartActionWindow>()); }
private void OnDestroy() { Remove(GetComponent<UIPartActionWindow>()); }
}
public static readonly List<UIPartActionWindow> Windows = new List<UIPartActionWindow>();
public static void Init()
{
if (UIPartActionController.Instance.windowPrefab.gameObject.GetComponent<WindowTrackerComponent>() == null)
UIPartActionController.Instance.windowPrefab.gameObject.AddComponent<WindowTrackerComponent>();
}
private static void Add(UIPartActionWindow window)
{
if (window != null && !Windows.Contains(window))
Windows.Add(window);
}
private static void Remove(UIPartActionWindow window)
{
if (window != null && Windows.Contains(window))
Windows.Remove(window);
}
}
Then this line:
foreach (var window in GameObject.FindObjectsOfType(typeof(UIPartActionWindow))
.OfType<UIPartActionWindow>().Where(p => p.Display == UIPartActionWindow.DisplayType.Selected))
could be changed to
foreach (var window in UIPartActionWindowTracker.Windows.Where(p => p.Display == UIPartActionWindow.DisplayType.Selected)
and avoid the performance penalty
from kis.
Fixed for next version (1.0.1)
from kis.
Related Issues (20)
- KIS2 Feature Request: wearable prop support HOT 1
- [ERR xx:xx:xx.xxx] ADDON BINDER: Cannot resolve assembly: KSPDev_Utils.2.* HOT 1
- [Restock] Some parts stops to stack in KIS
- Clones explosion after loading save, game crashing HOT 2
- Cannot open any container inventories HOT 1
- cannot build with larger parts without blowing up HOT 3
- Refuel tank throws error on refuel action
- Retract cable option is visible when the connector is locked HOT 1
- 500ms delay between drop part action and the actual refresh HOT 3
- KSP 1.11: The KIS dragging mode can activate when the stock construction mode is active
- Copy inventory content when an inventory part is copied HOT 1
- KIS causes SEVERE FPS drops when interacting with Mystery Goo HOT 15
- Problem with inventories interaction in 1.12.3 HOT 6
- Can't add any EVA items to Inventory with KIS and KAS installed HOT 1
- [KSP 1.12.3, Linux] ModuleManager can't find KIS\Plugins\MiniAVC-V2.dll on startup HOT 1
- Cant open inventory
- miniavc-v2.dll keeps disappearing on startup #403 HOT 2
- Bug link(plug) HOT 1
- Exceptions during part drop
- EVA canister doesn't refill resources anymore
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from kis.