From 6bc5adccb1073ddf8f88466f572d2c39fe66ce10 Mon Sep 17 00:00:00 2001 From: Simon McLoughlin Date: Mon, 4 Dec 2023 12:15:51 +0000 Subject: [PATCH 1/3] - update CustomAVPlayerController to use better KVO - remove references to it for now as its currently not used --- .../CustomAVPlayerViewController.swift | 21 ++++++++++--------- .../Detail/CollectibleDetailAVCell.swift | 4 ++-- .../CollectiblesDetailsViewModel.swift | 4 ++-- 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/Kukai Mobile/Controls/CustomAVPlayerViewController.swift b/Kukai Mobile/Controls/CustomAVPlayerViewController.swift index 4b527907..70ad28a9 100644 --- a/Kukai Mobile/Controls/CustomAVPlayerViewController.swift +++ b/Kukai Mobile/Controls/CustomAVPlayerViewController.swift @@ -16,6 +16,7 @@ class CustomAVPlayerViewController: AVPlayerViewController { private var viewToMonitor: UIView? = nil private var previousValue = true + private var hiddenObserver: NSKeyValueObservation? = nil public weak var customDelegate: CustomAVPlayerViewControllerDelegate? = nil @@ -27,18 +28,18 @@ class CustomAVPlayerViewController: AVPlayerViewController { previousValue = viewToMonitor?.isHidden ?? true viewToMonitor?.addObserver(self, forKeyPath: "hidden", context: nil) + + self.hiddenObserver = viewToMonitor?.observe(\.isHidden, changeHandler: { [weak self] view, change in + if self?.previousValue != view.isHidden { + self?.previousValue = view.isHidden + self?.customDelegate?.playbackControlsChanged(visible: !view.isHidden) + } + }) + } deinit { - viewToMonitor?.removeObserver(self, forKeyPath: "hidden") - } - - override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) { - - // Check if its the correct element and avoid double trigger - if keyPath == "hidden", let v = viewToMonitor, previousValue != v.isHidden { - previousValue = v.isHidden - customDelegate?.playbackControlsChanged(visible: !v.isHidden) - } + hiddenObserver?.invalidate() + hiddenObserver = nil } } diff --git a/Kukai Mobile/Modules/Collectibles/Cells/Detail/CollectibleDetailAVCell.swift b/Kukai Mobile/Modules/Collectibles/Cells/Detail/CollectibleDetailAVCell.swift index 71688d34..f90001b3 100644 --- a/Kukai Mobile/Modules/Collectibles/Cells/Detail/CollectibleDetailAVCell.swift +++ b/Kukai Mobile/Modules/Collectibles/Cells/Detail/CollectibleDetailAVCell.swift @@ -21,7 +21,7 @@ class CollectibleDetailAVCell: UICollectionViewCell { private var isPlaybackReady = false private var isPlaying = false private var imageView: UIImageView? = nil - private weak var playerController: CustomAVPlayerViewController? = nil + private weak var playerController: AVPlayerViewController? = nil private var airPlayName: String = "" private var airPlayArtist: String = "" @@ -38,7 +38,7 @@ class CollectibleDetailAVCell: UICollectionViewCell { public var setup = false public var timer: Timer? = nil - func setup(mediaContent: MediaContent, airPlayName: String, airPlayArtist: String, airPlayAlbum: String, avplayerController: CustomAVPlayerViewController, layoutOnly: Bool) { + func setup(mediaContent: MediaContent, airPlayName: String, airPlayArtist: String, airPlayAlbum: String, avplayerController: AVPlayerViewController, layoutOnly: Bool) { if mediaContent.width > mediaContent.height { self.aspectRatioConstraint.isActive = false placeholderView.widthAnchor.constraint(equalTo: placeholderView.heightAnchor, multiplier: mediaContent.width/mediaContent.height).isActive = true diff --git a/Kukai Mobile/Modules/Collectibles/CollectiblesDetailsViewModel.swift b/Kukai Mobile/Modules/Collectibles/CollectiblesDetailsViewModel.swift index 2c9a9b4b..6d1194cc 100644 --- a/Kukai Mobile/Modules/Collectibles/CollectiblesDetailsViewModel.swift +++ b/Kukai Mobile/Modules/Collectibles/CollectiblesDetailsViewModel.swift @@ -78,7 +78,7 @@ class CollectiblesDetailsViewModel: ViewModel, UICollectionViewDiffableDataSourc private var currentSnapshot = NSDiffableDataSourceSnapshot() private let mediaService = MediaProxyService() - private var playerController: CustomAVPlayerViewController? = nil + private var playerController: AVPlayerViewController? = nil private var playerLooper: AVPlayerLooper? = nil private var sendData = SendContent(enabled: true) @@ -540,7 +540,7 @@ class CollectiblesDetailsViewModel: ViewModel, UICollectionViewDiffableDataSourc // Make sure we only register the player controller once if self.playerController == nil { - self.playerController = CustomAVPlayerViewController() + self.playerController = AVPlayerViewController() Logger.app.info("Loading video url: \(url.absoluteString)") From 7e2bf3a6e16ad0fa8a9e6d955d3f5f78084d629b Mon Sep 17 00:00:00 2001 From: Simon McLoughlin Date: Tue, 5 Dec 2023 11:13:09 +0000 Subject: [PATCH 2/3] - update to Xcode 15 - remove asset symbol generation, as currently an apple bug that strips of "color" form the end of the asset name causing duplicates - add linker command to remove duplicate warnings. Many complaints online that apple have made a change here and its causing issues with anything that uses a c++ based library --- Kukai Mobile.xcodeproj/project.pbxproj | 13 +++++++++++-- .../xcshareddata/swiftpm/Package.resolved | 2 +- .../xcschemes/Kukai Mobile Beta.xcscheme | 2 +- .../xcschemes/Kukai Mobile Debug.xcscheme | 2 +- .../xcschemes/Kukai Mobile Release.xcscheme | 2 +- 5 files changed, 15 insertions(+), 6 deletions(-) diff --git a/Kukai Mobile.xcodeproj/project.pbxproj b/Kukai Mobile.xcodeproj/project.pbxproj index 32ab5b9a..ccb0a1bd 100644 --- a/Kukai Mobile.xcodeproj/project.pbxproj +++ b/Kukai Mobile.xcodeproj/project.pbxproj @@ -3,7 +3,7 @@ archiveVersion = 1; classes = { }; - objectVersion = 53; + objectVersion = 54; objects = { /* Begin PBXBuildFile section */ @@ -1664,7 +1664,7 @@ attributes = { BuildIndependentTargetsInParallel = YES; LastSwiftUpdateCheck = 1250; - LastUpgradeCheck = 1430; + LastUpgradeCheck = 1500; TargetAttributes = { C0B0363E269EE2070071ACD0 = { CreatedOnToolsVersion = 12.5; @@ -2206,6 +2206,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + ASSETCATALOG_COMPILER_GENERATE_ASSET_SYMBOLS = NO; CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; CLANG_ANALYZER_NONNULL = YES; CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; @@ -2241,6 +2242,7 @@ DEBUG_INFORMATION_FORMAT = dwarf; ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_TESTABILITY = YES; + ENABLE_USER_SCRIPT_SANDBOXING = YES; GCC_C_LANGUAGE_STANDARD = gnu11; GCC_DYNAMIC_NO_PIC = NO; GCC_NO_COMMON_BLOCKS = YES; @@ -2259,6 +2261,7 @@ MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_FAST_MATH = YES; ONLY_ACTIVE_ARCH = YES; + OTHER_LDFLAGS = "\"-Wl,-no_warn_duplicate_libraries\""; PRODUCT_NAME = Kuaki; SDKROOT = iphoneos; SUPPORTED_PLATFORMS = "iphonesimulator iphoneos"; @@ -2272,6 +2275,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + ASSETCATALOG_COMPILER_GENERATE_ASSET_SYMBOLS = NO; CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; CLANG_ANALYZER_NONNULL = YES; CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; @@ -2307,6 +2311,7 @@ DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; ENABLE_NS_ASSERTIONS = NO; ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_USER_SCRIPT_SANDBOXING = YES; GCC_C_LANGUAGE_STANDARD = gnu11; GCC_NO_COMMON_BLOCKS = YES; GCC_WARN_64_TO_32_BIT_CONVERSION = YES; @@ -2318,6 +2323,7 @@ IPHONEOS_DEPLOYMENT_TARGET = 16.1; MTL_ENABLE_DEBUG_INFO = NO; MTL_FAST_MATH = YES; + OTHER_LDFLAGS = "\"-Wl,-no_warn_duplicate_libraries\""; PRODUCT_NAME = Kukai; SDKROOT = iphoneos; SWIFT_COMPILATION_MODE = wholemodule; @@ -2494,6 +2500,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + ASSETCATALOG_COMPILER_GENERATE_ASSET_SYMBOLS = NO; CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; CLANG_ANALYZER_NONNULL = YES; CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; @@ -2529,6 +2536,7 @@ DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; ENABLE_NS_ASSERTIONS = NO; ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_USER_SCRIPT_SANDBOXING = YES; GCC_C_LANGUAGE_STANDARD = gnu11; GCC_NO_COMMON_BLOCKS = YES; GCC_WARN_64_TO_32_BIT_CONVERSION = YES; @@ -2540,6 +2548,7 @@ IPHONEOS_DEPLOYMENT_TARGET = 16.1; MTL_ENABLE_DEBUG_INFO = NO; MTL_FAST_MATH = YES; + OTHER_LDFLAGS = "\"-Wl,-no_warn_duplicate_libraries\""; PRODUCT_NAME = "Kukai Beta"; SDKROOT = iphoneos; SWIFT_COMPILATION_MODE = wholemodule; diff --git a/Kukai Mobile.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/Kukai Mobile.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index fe64750e..85ecf24f 100644 --- a/Kukai Mobile.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/Kukai Mobile.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -78,7 +78,7 @@ "location" : "https://github.com/kukai-wallet/kukai-core-swift", "state" : { "branch" : "develop", - "revision" : "75cee6f7c83eea9debf265bff5891e7197065de1" + "revision" : "469398a5dd7f7c535002a26654388d466367569a" } }, { diff --git a/Kukai Mobile.xcodeproj/xcshareddata/xcschemes/Kukai Mobile Beta.xcscheme b/Kukai Mobile.xcodeproj/xcshareddata/xcschemes/Kukai Mobile Beta.xcscheme index 2a8f2cb9..3590f391 100644 --- a/Kukai Mobile.xcodeproj/xcshareddata/xcschemes/Kukai Mobile Beta.xcscheme +++ b/Kukai Mobile.xcodeproj/xcshareddata/xcschemes/Kukai Mobile Beta.xcscheme @@ -1,6 +1,6 @@ Date: Tue, 5 Dec 2023 12:31:20 +0000 Subject: [PATCH 3/3] - bug fix: hideLoading completion not being triggered, causing queues to get stuck --- Kukai Mobile/Extensions/UIViewController+extensions.swift | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Kukai Mobile/Extensions/UIViewController+extensions.swift b/Kukai Mobile/Extensions/UIViewController+extensions.swift index 94414c97..9593ac47 100644 --- a/Kukai Mobile/Extensions/UIViewController+extensions.swift +++ b/Kukai Mobile/Extensions/UIViewController+extensions.swift @@ -67,6 +67,9 @@ extension UIViewController { func hideLoadingView(completion: (() -> Void)? = nil) { UIViewController.activityViewActivityIndicator.stopAnimating() UIViewController.activityView.removeFromSuperview() + if let comp = completion { + comp() + } } static func createLoadingModal() -> UIViewController {