mirror of
https://github.com/dortania/OpenCore-Legacy-Patcher.git
synced 2026-04-11 16:27:19 +10:00
GUI: Reduce CPU usage II - have smoother UX with faster refresh rate
* Set thread_sleep_interval to 0.01s for better UI responsiveness * Improve thread waiting with thread.join() where applicable (thanks to @sbytnar)
This commit is contained in:
@@ -13,7 +13,7 @@ from .detections import device_probe
|
||||
class Constants:
|
||||
def __init__(self) -> None:
|
||||
# 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.copyright_date: str = "Copyright © 2020-2025 Dortania"
|
||||
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.update_stage: int = 0 # Determine update stage (see gui_support.py)
|
||||
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_nap_interval: float = 0.01 # Short Sleep interval between UI updates (seconds) - for faster UI updates of the progress bar
|
||||
self.thread_sleep_interval: float = 0.01 # Sleep interval between UI updates (seconds) - balance between UI responsiveness and CPU usage
|
||||
|
||||
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 time
|
||||
import logging
|
||||
import plistlib
|
||||
import tempfile
|
||||
@@ -317,7 +316,7 @@ class macOSInstallerFlashFrame(wx.Frame):
|
||||
wx.CallAfter(progress_bar.SetValue, bytes_written)
|
||||
|
||||
wx.Yield()
|
||||
time.sleep(self.constants.thread_sleep_interval)
|
||||
thread.join(timeout=self.constants.thread_sleep_interval)
|
||||
|
||||
if self.result is False:
|
||||
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():
|
||||
wx.Yield()
|
||||
time.sleep(interval)
|
||||
thread.join(timeout=interval)
|
||||
|
||||
|
||||
class RestartHost:
|
||||
|
||||
Reference in New Issue
Block a user