From b1d6a977087a017e7655e4db28b230b308f935db Mon Sep 17 00:00:00 2001 From: Daniel Bernal Date: Wed, 10 Apr 2024 17:28:50 +0200 Subject: [PATCH] Fix lottie high Windowserver load (#2595) Task/Issue URL: https://app.asana.com/0/1177771139624306/1207024603216659/f **Description**: Force use of .mainThread to prevent high WindowServer Usage (Pending Fix with newer Lottie versions) --- DuckDuckGo/Application/AppDelegate.swift | 6 ++++++ .../View/AddressBarButtonsViewController.swift | 8 +++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/DuckDuckGo/Application/AppDelegate.swift b/DuckDuckGo/Application/AppDelegate.swift index 22cc5ea79e..53ac49ff5b 100644 --- a/DuckDuckGo/Application/AppDelegate.swift +++ b/DuckDuckGo/Application/AppDelegate.swift @@ -222,6 +222,12 @@ final class AppDelegate: NSObject, NSApplicationDelegate { PrivacyFeatures.httpsUpgrade.loadDataAsync() bookmarksManager.loadBookmarks() + + // Force use of .mainThread to prevent high WindowServer Usage + // Pending Fix with newer Lottie versions + // https://app.asana.com/0/1177771139624306/1207024603216659/f + LottieConfiguration.shared.renderingEngine = .mainThread + if case .normal = NSApp.runType { FaviconManager.shared.loadFavicons() } diff --git a/DuckDuckGo/NavigationBar/View/AddressBarButtonsViewController.swift b/DuckDuckGo/NavigationBar/View/AddressBarButtonsViewController.swift index 7afc044118..8d28152841 100644 --- a/DuckDuckGo/NavigationBar/View/AddressBarButtonsViewController.swift +++ b/DuckDuckGo/NavigationBar/View/AddressBarButtonsViewController.swift @@ -553,7 +553,13 @@ final class AddressBarButtonsViewController: NSViewController { } private func setupAnimationViews() { - func addAndLayoutAnimationViewIfNeeded(animationView: LottieAnimationView?, animationName: String, renderingEngine: Lottie.RenderingEngineOption = .automatic) -> LottieAnimationView { + + func addAndLayoutAnimationViewIfNeeded(animationView: LottieAnimationView?, + animationName: String, + // Default use of .mainThread to prevent high WindowServer Usage + // Pending Fix with newer Lottie versions + // https://app.asana.com/0/1177771139624306/1207024603216659/f + renderingEngine: Lottie.RenderingEngineOption = .mainThread) -> LottieAnimationView { if let animationView = animationView, animationView.identifier?.rawValue == animationName { return animationView }