forked from Boria138/PortProtonQt
fix(startup): prevent main thread hangs and optimize resource loading
- run start_sh initialization via QTimer.singleShot with timeout - add timeout protection to load_theme_fonts() - load Steam/EGS/PortProton games in parallel instead of sequential - delay game loading until UI is fully initialized - fix callback chaining to avoid blocking operations - add proper timeout + error handling for all Steam/EGS network requests - add timeouts for flatpak subprocess calls - improve file I/O error handling to avoid UI freeze - optimize theme font loading: - delay font loading via QTimer.singleShot - load fonts in batches of 10 - reduce font load timeout to 3s - remove fonts only when switching themes Signed-off-by: Boris Yumankulov <boria138@altlinux.org>
This commit is contained in:
@@ -34,13 +34,12 @@ def main():
|
||||
os.environ["PROCESS_LOG"] = "1"
|
||||
os.environ["START_FROM_STEAM"] = "1"
|
||||
|
||||
# Get the PortProton start command
|
||||
start_sh = get_portproton_start_command()
|
||||
|
||||
if start_sh is None:
|
||||
return
|
||||
|
||||
subprocess.run(start_sh + ["cli", "--initial"])
|
||||
|
||||
app = QApplication(sys.argv)
|
||||
app.setWindowIcon(QIcon.fromTheme(__app_id__))
|
||||
app.setDesktopFileName(__app_id__)
|
||||
@@ -144,6 +143,22 @@ def main():
|
||||
save_fullscreen_config(False)
|
||||
window.showNormal()
|
||||
|
||||
# Execute the initial PortProton command after the UI is set up
|
||||
def run_initial_command():
|
||||
nonlocal start_sh
|
||||
if start_sh:
|
||||
try:
|
||||
subprocess.run(start_sh + ["cli", "--initial"], timeout=10)
|
||||
except subprocess.TimeoutExpired:
|
||||
logger.warning("Initial PortProton command timed out")
|
||||
except Exception as e:
|
||||
logger.error(f"Error running initial PortProton command: {e}")
|
||||
else:
|
||||
logger.warning("PortProton start command not available, skipping initial command")
|
||||
|
||||
# Run the initial command after the UI is displayed
|
||||
QTimer.singleShot(100, run_initial_command)
|
||||
|
||||
# --- Cleanup ---
|
||||
def cleanup_on_exit():
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user