mirror of
https://github.com/PrismLauncher/PrismLauncher.git
synced 2025-06-12 05:07:46 +02:00
perf: print api servers asynchronously on instance launch
Doing this on the main thread can cause the launcher to freeze for up to 5 seconds when launching an instance on my system so i moved it to a launch step where it gets all the servers info asynchronously to print Signed-off-by: leia uwu <leia@tutamail.com>
This commit is contained in:
@ -36,6 +36,7 @@
|
||||
|
||||
#include "LaunchController.h"
|
||||
#include "Application.h"
|
||||
#include "launch/steps/PrintServers.h"
|
||||
#include "minecraft/auth/AccountData.h"
|
||||
#include "minecraft/auth/AccountList.h"
|
||||
|
||||
@ -345,25 +346,8 @@ void LaunchController::launchInstance()
|
||||
|
||||
// Prepend Server Status
|
||||
QStringList servers = { "login.microsoftonline.com", "session.minecraft.net", "textures.minecraft.net", "api.mojang.com" };
|
||||
QString resolved_servers = "";
|
||||
QHostInfo host_info;
|
||||
|
||||
for (QString server : servers) {
|
||||
host_info = QHostInfo::fromName(server);
|
||||
resolved_servers = resolved_servers + server + " resolves to:\n [";
|
||||
if (!host_info.addresses().isEmpty()) {
|
||||
for (QHostAddress address : host_info.addresses()) {
|
||||
resolved_servers = resolved_servers + address.toString();
|
||||
if (!host_info.addresses().endsWith(address)) {
|
||||
resolved_servers = resolved_servers + ", ";
|
||||
}
|
||||
}
|
||||
} else {
|
||||
resolved_servers = resolved_servers + "N/A";
|
||||
}
|
||||
resolved_servers = resolved_servers + "]\n\n";
|
||||
}
|
||||
m_launcher->prependStep(makeShared<TextPrint>(m_launcher.get(), resolved_servers, MessageLevel::Launcher));
|
||||
m_launcher->prependStep(makeShared<PrintServers>(m_launcher.get(), servers));
|
||||
} else {
|
||||
online_mode = m_demo ? "demo" : "offline";
|
||||
}
|
||||
|
Reference in New Issue
Block a user