mirror of
https://github.com/PrismLauncher/PrismLauncher.git
synced 2026-06-29 01:54:20 +03: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:
parent
8014283bf4
commit
c1d0560524
4 changed files with 106 additions and 18 deletions
|
|
@ -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";
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue