Skip to content

Commit 71b2ff9

Browse files
author
Isaac
committed
Fix
1 parent ad30eb2 commit 71b2ff9

File tree

4 files changed

+77
-6
lines changed

4 files changed

+77
-6
lines changed

‎submodules/TelegramUI/Components/ContextControllerImpl/Sources/ContextControllerActionsStackNode.swift‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1839,6 +1839,13 @@ public final class ContextControllerActionsStackNodeImpl: ASDisplayNode, Context
18391839
selectionPanGesture.isEnabled = false
18401840
}
18411841

1842+
override public func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? {
1843+
guard let result = super.hitTest(point, with: event) else {
1844+
return nil
1845+
}
1846+
return result
1847+
}
1848+
18421849
@objc private func panGesture(_ recognizer: UIPanGestureRecognizer) {
18431850
switch recognizer.state {
18441851
case .began, .changed:

‎submodules/TelegramUI/Components/LensTransition/Sources/LensTransitionContainer.swift‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,24 @@ public final class LensTransitionContainer: UIView {
143143
fatalError("init(coder:) has not been implemented")
144144
}
145145

146+
override public func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? {
147+
if self.alpha.isZero {
148+
return nil
149+
}
150+
for view in self.contentsView.subviews.reversed() {
151+
if let result = view.hitTest(self.convert(point, to: view), with: event), result.isUserInteractionEnabled {
152+
return result
153+
}
154+
}
155+
156+
let result = self.contentsView.hitTest(point, with: event)
157+
if result != self.contentsView {
158+
return result
159+
} else {
160+
return nil
161+
}
162+
}
163+
146164
private func setIsFilterActive(isFilterActive: Bool) {
147165
if isFilterActive {
148166
if self.contentsView.layer.filters == nil {

‎submodules/TelegramUI/Components/MediaEditor/Sources/MediaEditorVideoExport.swift‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -279,26 +279,26 @@ public final class MediaEditorVideoExport {
279279
guard let self else {
280280
return
281281
}
282-
if case let .video(_, isStory) = subject, isStory {
282+
/*if case let .video(_, isStory) = subject, isStory {
283283
if #available(iOS 26.0, *) {
284284
if BGTaskScheduler.supportedResources.contains(.gpu) {
285285
return
286286
}
287287
}
288-
}
288+
}*/
289289
self.resume()
290290
})
291291
let _ = NotificationCenter.default.addObserver(forName: UIApplication.didEnterBackgroundNotification, object: nil, queue: nil, using: { [weak self] _ in
292292
guard let self else {
293293
return
294294
}
295-
if case let .video(_, isStory) = subject, isStory {
295+
/*if case let .video(_, isStory) = subject, isStory {
296296
if #available(iOS 26.0, *) {
297297
if BGTaskScheduler.supportedResources.contains(.gpu) {
298298
return
299299
}
300300
}
301-
}
301+
}*/
302302
self.pause()
303303
})
304304
}

‎submodules/TelegramUI/Sources/SharedWakeupManager.swift‎

Lines changed: 48 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ public final class SharedWakeupManager {
6565
private let backgroundTimeRemaining: () -> Double
6666
private let acquireIdleExtension: () -> Disposable?
6767

68+
private var enableBackgroundTasks: Bool = false
69+
6870
private var inForeground: Bool = false
6971
private var hasActiveAudioSession: Bool = false
7072
private var activeExplicitExtensionTimer: SwiftSignalKit.Timer?
@@ -73,6 +75,7 @@ public final class SharedWakeupManager {
7375
private var allowBackgroundTimeExtensionDeadlineTimer: SwiftSignalKit.Timer?
7476
private var isInBackgroundExtension: Bool = false
7577

78+
private var accountSettingsDisposable: Disposable?
7679
private var inForegroundDisposable: Disposable?
7780
private var hasActiveAudioSessionDisposable: Disposable?
7881
private var tasksDisposable: Disposable?
@@ -111,6 +114,29 @@ public final class SharedWakeupManager {
111114
self.backgroundTimeRemaining = backgroundTimeRemaining
112115
self.acquireIdleExtension = acquireIdleExtension
113116

117+
self.accountSettingsDisposable = (activeAccounts
118+
|> mapToSignal { activeAccounts -> Signal<Bool, NoError> in
119+
guard let account = activeAccounts.primary else {
120+
return .single(false)
121+
}
122+
return account.postbox.transaction { transaction -> Bool in
123+
guard let data = currentAppConfiguration(transaction: transaction).data else {
124+
return false
125+
}
126+
if data["ios_killswitch_disable_bgtasks"] != nil {
127+
return false
128+
}
129+
return true
130+
}
131+
}
132+
|> deliverOnMainQueue
133+
|> distinctUntilChanged).startStrict(next: { [weak self] isEnabled in
134+
guard let self else {
135+
return
136+
}
137+
self.enableBackgroundTasks = isEnabled
138+
})
139+
114140
self.inForegroundDisposable = (inForeground
115141
|> deliverOnMainQueue).startStrict(next: { [weak self] value in
116142
guard let strongSelf = self else {
@@ -319,6 +345,7 @@ public final class SharedWakeupManager {
319345
}
320346

321347
deinit {
348+
self.accountSettingsDisposable?.dispose()
322349
self.inForegroundDisposable?.dispose()
323350
self.hasActiveAudioSessionDisposable?.dispose()
324351
self.tasksDisposable?.dispose()
@@ -333,6 +360,10 @@ public final class SharedWakeupManager {
333360
}
334361

335362
private func updateBackgroundProcessingTaskStateFromPendingMediaUploads() {
363+
if !self.enableBackgroundTasks {
364+
return
365+
}
366+
336367
let shouldHaveTask = !self.pendingMediaUploadsByKey.isEmpty && !self.inForeground
337368
let hadTask = self.backgroundProcessingTaskId != nil
338369

@@ -359,6 +390,10 @@ public final class SharedWakeupManager {
359390
}
360391

361392
private func updateBackgroundProcessingTaskStateFromPendingStoryUploads() {
393+
if !self.enableBackgroundTasks {
394+
return
395+
}
396+
362397
let shouldHaveTask = !self.pendingStoryUploadStatusesByKey.isEmpty && !self.inForeground
363398
let hadTask = self.backgroundStoryProcessingTaskId != nil
364399

@@ -510,6 +545,11 @@ public final class SharedWakeupManager {
510545
self.backgroundProcessingTaskLaunched = false
511546
self.checkTasks()
512547
self.updateBackgroundProcessingTaskStateFromPendingMediaUploads()
548+
} else if !self.backgroundProcessingTaskCancellationRequestedByApp {
549+
Logger.shared.log("Wakeup", "Non-current BG task expired externally, will delete uploading messages: \(task.identifier)")
550+
self.cancelUploadingMessagesForCurrentTask()
551+
self.checkTasks()
552+
self.updateBackgroundProcessingTaskStateFromPendingMediaUploads()
513553
}
514554
}
515555
}
@@ -688,6 +728,11 @@ public final class SharedWakeupManager {
688728
self.backgroundStoryProcessingTaskLaunched = false
689729
self.checkTasks()
690730
self.updateBackgroundProcessingTaskStateFromPendingStoryUploads()
731+
} else if !self.backgroundStoryProcessingTaskCancellationRequestedByApp {
732+
Logger.shared.log("Wakeup", "Non-current story BG task expired externally, will cancel uploading stories: \(task.identifier)")
733+
self.cancelUploadingStoriesForCurrentTask()
734+
self.checkTasks()
735+
self.updateBackgroundProcessingTaskStateFromPendingStoryUploads()
691736
}
692737
}
693738
}
@@ -769,6 +814,7 @@ public final class SharedWakeupManager {
769814
task.progress.totalUnitCount = totalUnitCount
770815
task.progress.completedUnitCount = completedUnitCount
771816

817+
//TODO:localize
772818
let title: String
773819
if self.pendingStoryUploadsByKey.count == 1 {
774820
title = "Uploading 1 Story"
@@ -811,9 +857,9 @@ public final class SharedWakeupManager {
811857
subtitle: subtitle
812858
)
813859
request.strategy = .fail
814-
if BGTaskScheduler.supportedResources.contains(.gpu) {
860+
/*if BGTaskScheduler.supportedResources.contains(.gpu) {
815861
request.requiredResources = .gpu
816-
}
862+
}*/
817863

818864
do {
819865
try BGTaskScheduler.shared.submit(request)

0 commit comments

Comments
 (0)