Load sounds on demand (saves ~200mb RAM on startup)

This commit is contained in:
Anuken
2026-06-14 14:38:12 -04:00
parent 22444e2d8e
commit 4d3cb54f7e
5 changed files with 6 additions and 15 deletions
+2 -10
View File
@@ -105,20 +105,12 @@ public abstract class ClientLauncher extends ApplicationCore implements Platform
@Override
public Sound loadSync(AssetManager manager, String fileName, Fi file, SoundParameter parameter){
if(parameter != null && parameter.sound != null){
mainExecutor.submit(() -> parameter.sound.load(file));
parameter.sound.loadLazy(file);
return parameter.sound;
}else{
Sound sound = new Sound();
mainExecutor.submit(() -> {
try{
sound.load(file);
}catch(Throwable t){
Log.err("Error loading sound: " + file, t);
}
});
sound.loadLazy(file);
return sound;
}
}
+1 -1
View File
@@ -265,7 +265,7 @@ public class Vars implements Loadable{
public static Locale[] locales;
//the main executor will only have at most [cores] number of threads active
public static ExecutorService mainExecutor = Threads.executor("Main Executor", OS.cores);
public static ExecutorService mainExecutor = Core.executor;
public static FileTree tree = new FileTree();
public static Net net;
+1 -1
View File
@@ -78,7 +78,7 @@ public class SoundPriority{
sameGroup(shootArc, shootPulsar);
for(var sound : Core.assets.getAll(Sound.class, new Seq<>())){
sound.setMinConcurrentInterrupt(Math.min(0.25f, sound.getLength() * 0.5f));
sound.setMinConcurrentInterruptFraction(0.25f, 0.5f);
}
mechStepSmall.setMinConcurrentInterrupt(0.5f);
+1 -2
View File
@@ -579,9 +579,8 @@ public class Renderer implements ApplicationListener{
ui.showInfo("@screenshot.invalid");
return;
}
try{
FrameBuffer buffer = new FrameBuffer(w, h);
drawWeather = false;
+1 -1
View File
@@ -26,4 +26,4 @@ org.gradle.caching=true
org.gradle.internal.http.socketTimeout=100000
org.gradle.internal.http.connectionTimeout=100000
android.enableR8.fullMode=false
archash=6ea6355ee3
archash=6e3c0bbc30