From a5066140fdef944e0daceb59e1d557edb725cb75 Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Mon, 25 Nov 2024 20:54:35 -0500 Subject: [PATCH] Fix potential crash during gifv playback I don't know how this is possible, but it evidently is --- .../GalleryVC/Content/VideoGalleryContentViewController.swift | 4 ++-- Tusker/Views/Attachments/GifvController.swift | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Packages/GalleryVC/Sources/GalleryVC/Content/VideoGalleryContentViewController.swift b/Packages/GalleryVC/Sources/GalleryVC/Content/VideoGalleryContentViewController.swift index 09f2751d..4afa609d 100644 --- a/Packages/GalleryVC/Sources/GalleryVC/Content/VideoGalleryContentViewController.swift +++ b/Packages/GalleryVC/Sources/GalleryVC/Content/VideoGalleryContentViewController.swift @@ -208,9 +208,9 @@ private class PlayerView: UIView { playerLayer.player = player playerLayer.videoGravity = .resizeAspect - presentationSizeObservation = item.observe(\.presentationSize, changeHandler: { [unowned self] _, _ in + presentationSizeObservation = item.observe(\.presentationSize, changeHandler: { [weak self] _, _ in MainActor.assumeIsolated { - self.invalidateIntrinsicContentSize() + self?.invalidateIntrinsicContentSize() } }) } diff --git a/Tusker/Views/Attachments/GifvController.swift b/Tusker/Views/Attachments/GifvController.swift index b89bd2d5..d7992466 100644 --- a/Tusker/Views/Attachments/GifvController.swift +++ b/Tusker/Views/Attachments/GifvController.swift @@ -60,9 +60,9 @@ class GifvController { } private func updatePresentationSizeObservation() { - presentationSizeObservation = item.observe(\.presentationSize, changeHandler: { [unowned self] item, _ in + presentationSizeObservation = item.observe(\.presentationSize, changeHandler: { [weak self] item, _ in DispatchQueue.main.async { - self.presentationSizeSubject.send(item.presentationSize) + self?.presentationSizeSubject.send(item.presentationSize) } }) }