From ab7dffdf3ac902e645253d0ac213c7b554d5295b Mon Sep 17 00:00:00 2001 From: Serhiy Mytrovtsiy Date: Thu, 25 Dec 2025 19:26:04 +0100 Subject: [PATCH] fix: moved WKWebView initialization to the moment when it should be displayed, which prevents the initialization of the web view on app start and silences some system logs --- Kit/helpers.swift | 17 +++++++++++------ .../xcshareddata/xcschemes/SMC.xcscheme | 2 +- .../xcshareddata/xcschemes/Stats.xcscheme | 2 +- .../xcschemes/WidgetsExtension.xcscheme | 2 +- 4 files changed, 14 insertions(+), 9 deletions(-) diff --git a/Kit/helpers.swift b/Kit/helpers.swift index 58da2f47..7fe5695e 100644 --- a/Kit/helpers.swift +++ b/Kit/helpers.swift @@ -1603,24 +1603,29 @@ public class PreferencesSwitch: NSStackView { } public class HelpHUD: NSPanel { + private let text: String + public init(_ text: String, origin: CGPoint = CGPoint(x: 0, y: 0), size: CGSize = CGSize(width: 420, height: 300)) { + self.text = text super.init( contentRect: NSRect(origin: origin, size: size), - styleMask: [.hudWindow, .titled, .closable], + styleMask: [.hudWindow, .utilityWindow, .titled, .closable], backing: .buffered, defer: false ) self.isFloatingPanel = true self.isMovableByWindowBackground = true self.level = .floating self.title = "Help" - - let webView = WKWebView() - webView.setValue(false, forKey: "drawsBackground") - webView.loadHTMLString("\(text)", baseURL: nil) - self.contentView = webView } public func show() { + if self.contentView as? WKWebView == nil { + let webView = WKWebView() + webView.setValue(false, forKey: "drawsBackground") + webView.loadHTMLString("\(self.text)", baseURL: nil) + self.contentView = webView + } + self.makeKeyAndOrderFront(self) self.center() } diff --git a/Stats.xcodeproj/xcshareddata/xcschemes/SMC.xcscheme b/Stats.xcodeproj/xcshareddata/xcschemes/SMC.xcscheme index 5abdc944..9bf53d07 100644 --- a/Stats.xcodeproj/xcshareddata/xcschemes/SMC.xcscheme +++ b/Stats.xcodeproj/xcshareddata/xcschemes/SMC.xcscheme @@ -1,6 +1,6 @@