Merge pull request #1163 from goneng/fix_high_cpu

GUI: Reduce CPU usage II - have smoother UX with faster refresh rate
This commit is contained in:
Mykola Grymalyuk
2025-04-12 18:30:30 -06:00
committed by GitHub
3 changed files with 4 additions and 6 deletions
+2 -3
View File
@@ -13,7 +13,7 @@ from .detections import device_probe
class Constants: class Constants:
def __init__(self) -> None: def __init__(self) -> None:
# Patcher Versioning # Patcher Versioning
self.patcher_version: str = "2.3.2" # OpenCore-Legacy-Patcher self.patcher_version: str = "2.4.0" # OpenCore-Legacy-Patcher
self.patcher_support_pkg_version: str = "1.9.3" # PatcherSupportPkg self.patcher_support_pkg_version: str = "1.9.3" # PatcherSupportPkg
self.copyright_date: str = "Copyright © 2020-2025 Dortania" self.copyright_date: str = "Copyright © 2020-2025 Dortania"
self.patcher_name: str = "OpenCore Legacy Patcher" self.patcher_name: str = "OpenCore Legacy Patcher"
@@ -155,8 +155,7 @@ class Constants:
self.unpack_thread = None # Determine if unpack thread finished (threading.Thread) self.unpack_thread = None # Determine if unpack thread finished (threading.Thread)
self.update_stage: int = 0 # Determine update stage (see gui_support.py) self.update_stage: int = 0 # Determine update stage (see gui_support.py)
self.log_filepath: Path = None # Path to log file self.log_filepath: Path = None # Path to log file
self.thread_sleep_interval: float = 0.1 # Sleep interval between UI updates (seconds) - reduce refresh-rate to reduce CPU-usage self.thread_sleep_interval: float = 0.01 # Sleep interval between UI updates (seconds) - balance between UI responsiveness and CPU usage
self.thread_nap_interval: float = 0.01 # Short Sleep interval between UI updates (seconds) - for faster UI updates of the progress bar
self.commit_info: tuple = (None, None, None) # Commit info (Branch, Commit Date, Commit URL) self.commit_info: tuple = (None, None, None) # Commit info (Branch, Commit Date, Commit URL)
@@ -3,7 +3,6 @@ gui_macos_installer_flash.py: macOS Installer Flash Frame
""" """
import wx import wx
import time
import logging import logging
import plistlib import plistlib
import tempfile import tempfile
@@ -317,7 +316,7 @@ class macOSInstallerFlashFrame(wx.Frame):
wx.CallAfter(progress_bar.SetValue, bytes_written) wx.CallAfter(progress_bar.SetValue, bytes_written)
wx.Yield() wx.Yield()
time.sleep(self.constants.thread_sleep_interval) thread.join(timeout=self.constants.thread_sleep_interval)
if self.result is False: if self.result is False:
logging.error("Failed to flash installer, cannot continue.") logging.error("Failed to flash installer, cannot continue.")
@@ -273,7 +273,7 @@ def wait_for_thread(thread: threading.Thread, sleep_interval=None):
while thread.is_alive(): while thread.is_alive():
wx.Yield() wx.Yield()
time.sleep(interval) thread.join(timeout=interval)
class RestartHost: class RestartHost: