Skip to content

Commit 1e8d4aa

Browse files
perf: Load asset bundles asynchronously during texture load (#344)
* perf: Load asset bundles async during texture load On my dev install KSP spends 4.5s on the initial asset bundle load step. It is possible to load these asynchronously while we are doing other work. This commit: - Starts the async bundle loads before FastLoader loads audio resources, models, or textures. - Replaces AssetLoader.LoadAssetDefinitions with a version that uses the preloaded asset bundle requests, if available. - Optimizes the directory walk in (now) PreloadAssetDefinitions to use plinq, and removes some unnecessary work. - Does a few extra tweaks to attempt to asynchronously load asset bundles even if they have the same name as an existing bundle. After this change the final time spent on loading asset bundles is ~0.4s. I have attempted to match the previous behaviour as closely as possible. There is a bug in the KSP version of this code where it tries to put asset bundles in the `SquadExpansions` folder at the start of the list, but due to what looks like a typo it just walks the `Squad` folder again. This hasn't seemed to cause a problem since it was addeed, so I have just left it in. There is one behaviour change, though, new bundle dependencies are now added to the end of the list instead of the next position in the list, this gives them more time to load in the background. * Update CHANGELOG --------- Co-authored-by: JonnyOThan <jonnyothan@gmail.com>
1 parent f225ae7 commit 1e8d4aa

3 files changed

Lines changed: 287 additions & 31 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
##### Unreleased
44
**New/improved patches**
55
- New performance patch: [**ExpansionBundlePreload**](https://github.com/KSPModdingLibs/KSPCommunityFixes/pull/345) : Loads DLC assetbundles asynchronously, saving several seconds during loading if DLC is installed. Thanks @Phantomical!
6+
- **FastLoader** : Added a [patch to start loading the stock asset bundles asynchronously](https://github.com/KSPModdingLibs/KSPCommunityFixes/pull/344), improving load time by ~4 seconds. Thanks @Phantomical!
67
- **MinorPerfTweaks** [now includes a patch to make PQS loading faster](https://github.com/KSPModdingLibs/KSPCommunityFixes/pull/343) on scene switches, saving ~1 second when switching from KSC to a vessel. Thanks @Phantomical!
78
- **MinorPerfTweaks** [now includes a patch to optimize refreshing part context windows](https://github.com/KSPModdingLibs/KSPCommunityFixes/pull/338). Thanks @Phantomical!
89

KSPCommunityFixes/KSPCommunityFixes.csproj

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,10 @@
8080
<Name>Assembly-CSharp-firstpass</Name>
8181
<Private>False</Private>
8282
</Reference>
83+
<Reference Include="$(ManagedPath)\KSPAssets.dll">
84+
<Name>KSPAssets</Name>
85+
<Private>False</Private>
86+
</Reference>
8387
<Reference Include="$(ProjectDir)\lib\0Harmony.dll">
8488
<Name>Harmony</Name>
8589
<Private>False</Private>
@@ -93,6 +97,7 @@
9397
<ItemGroup>
9498
<Publicize Include="Assembly-CSharp" />
9599
<Publicize Include="Assembly-CSharp-firstpass" />
100+
<Publicize Include="KSPAssets" />
96101
<DoNotPublicize Include="Assembly-CSharp:BaseField`1.OnValueModified" />
97102
<DoNotPublicize Include="Assembly-CSharp:SaveUpgradePipeline.SaveUpgradePipeline.OnSetCfgNodeVersion" />
98103
<Publicize Include="UnityEngine.CoreModule:UnityEngine.Object.m_CachedPtr" />

0 commit comments

Comments
 (0)