Adjust FPS on iPad

This commit is contained in:
Isaac 2023-12-21 18:13:54 +04:00
parent 14fe674dfe
commit 2e666c5c2b
4 changed files with 47 additions and 16 deletions

View File

@ -71,7 +71,7 @@ private enum DebugControllerEntry: ItemListNodeEntry {
case redactSensitiveData(PresentationTheme, Bool)
case keepChatNavigationStack(PresentationTheme, Bool)
case skipReadHistory(PresentationTheme, Bool)
case unidirectionalSwipeToReply(Bool)
case dustEffect(Bool)
case callV2(Bool)
case alternativeStoryMedia(Bool)
case crashOnSlowQueries(PresentationTheme, Bool)
@ -125,7 +125,7 @@ private enum DebugControllerEntry: ItemListNodeEntry {
return DebugControllerSection.logging.rawValue
case .webViewInspection, .resetWebViewCache:
return DebugControllerSection.web.rawValue
case .keepChatNavigationStack, .skipReadHistory, .unidirectionalSwipeToReply, .callV2, .alternativeStoryMedia, .crashOnSlowQueries, .crashOnMemoryPressure:
case .keepChatNavigationStack, .skipReadHistory, .dustEffect, .callV2, .alternativeStoryMedia, .crashOnSlowQueries, .crashOnMemoryPressure:
return DebugControllerSection.experiments.rawValue
case .clearTips, .resetNotifications, .crash, .resetData, .resetDatabase, .resetDatabaseAndCache, .resetHoles, .reindexUnread, .resetCacheIndex, .reindexCache, .resetBiometricsData, .optimizeDatabase, .photoPreview, .knockoutWallpaper, .storiesExperiment, .storiesJpegExperiment, .playlistPlayback, .enableQuickReactionSwitch, .voiceConference, .experimentalCompatibility, .enableDebugDataDisplay, .acceleratedStickers, .inlineForums, .localTranscription, .enableReactionOverrides, .restorePurchases:
return DebugControllerSection.experiments.rawValue
@ -176,7 +176,7 @@ private enum DebugControllerEntry: ItemListNodeEntry {
return 15
case .skipReadHistory:
return 16
case .unidirectionalSwipeToReply:
case .dustEffect:
return 17
case .callV2:
return 18
@ -943,11 +943,11 @@ private enum DebugControllerEntry: ItemListNodeEntry {
return settings
}).start()
})
case let .unidirectionalSwipeToReply(value):
return ItemListSwitchItem(presentationData: presentationData, title: "Legacy swipe to reply", value: value, sectionId: self.section, style: .blocks, updated: { value in
case let .dustEffect(value):
return ItemListSwitchItem(presentationData: presentationData, title: "Dust Debug", value: value, sectionId: self.section, style: .blocks, updated: { value in
let _ = updateExperimentalUISettingsInteractively(accountManager: arguments.sharedContext.accountManager, { settings in
var settings = settings
settings.unidirectionalSwipeToReply = value
settings.dustEffect = value
return settings
}).start()
})
@ -1425,7 +1425,7 @@ private func debugControllerEntries(sharedContext: SharedAccountContext, present
#if DEBUG
entries.append(.skipReadHistory(presentationData.theme, experimentalSettings.skipReadHistory))
#endif
entries.append(.unidirectionalSwipeToReply(experimentalSettings.unidirectionalSwipeToReply))
entries.append(.dustEffect(experimentalSettings.dustEffect))
entries.append(.callV2(experimentalSettings.callV2))
entries.append(.alternativeStoryMedia(experimentalSettings.alternativeStoryMedia))
}

View File

@ -1,5 +1,6 @@
import Foundation
import UIKit
import Darwin
public protocol SharedDisplayLinkDriverLink: AnyObject {
var isPaused: Bool { get set }
@ -7,6 +8,24 @@ public protocol SharedDisplayLinkDriverLink: AnyObject {
func invalidate()
}
private let isIpad: Bool = {
var systemInfo = utsname()
uname(&systemInfo)
let modelCode = withUnsafePointer(to: &systemInfo.machine) {
$0.withMemoryRebound(to: CChar.self, capacity: 1) {
ptr in String.init(validatingUTF8: ptr)
}
}
if let modelCode {
if modelCode.lowercased().hasPrefix("ipad") {
return true
}
}
return false
}()
public final class SharedDisplayLinkDriver {
public enum FramesPerSecond: Comparable {
case fps(Int)
@ -146,7 +165,7 @@ public final class SharedDisplayLinkDriver {
if #available(iOS 15.0, *) {
let maxFps = Float(UIScreen.main.maximumFramesPerSecond)
if maxFps > 61.0 {
let frameRateRange: CAFrameRateRange
var frameRateRange: CAFrameRateRange
switch maxFramesPerSecond {
case let .fps(fps):
if fps > 60 {
@ -157,6 +176,11 @@ public final class SharedDisplayLinkDriver {
case .max:
frameRateRange = CAFrameRateRange(minimum: 30.0, maximum: 120.0, preferred: 120.0)
}
if isIpad {
frameRateRange = CAFrameRateRange(minimum: 30.0, maximum: 120.0, preferred: 120.0)
}
if displayLink.preferredFrameRateRange != frameRateRange {
displayLink.preferredFrameRateRange = frameRateRange
print("SharedDisplayLinkDriver: switch to \(frameRateRange)")

View File

@ -680,6 +680,7 @@ public final class ChatHistoryListNodeImpl: ListView, ChatHistoryNode, ChatHisto
private var toLang: String?
private var allowDustEffect: Bool = true
private var allowDustEffectForAllMessages: Bool = true
private var dustEffectLayer: DustEffectLayer?
public init(context: AccountContext, updatedPresentationData: (initial: PresentationData, signal: Signal<PresentationData, NoError>), chatLocation: ChatLocation, chatLocationContextHolder: Atomic<ChatLocationContextHolder?>, tagMask: MessageTags?, source: ChatHistoryListSource, subject: ChatControllerSubject?, controllerInteraction: ChatControllerInteraction, selectedMessages: Signal<Set<MessageId>?, NoError>, mode: ChatHistoryListMode = .bubbles, messageTransitionNode: @escaping () -> ChatMessageTransitionNodeImpl?) {
@ -706,6 +707,8 @@ public final class ChatHistoryListNodeImpl: ListView, ChatHistoryNode, ChatHisto
}
}
self.allowDustEffectForAllMessages = context.sharedContext.immediateExperimentalUISettings.dustEffect
let presentationData = updatedPresentationData.initial
self.currentPresentationData = ChatPresentationData(theme: ChatPresentationThemeData(theme: presentationData.theme, wallpaper: presentationData.chatWallpaper), fontSize: presentationData.chatFontSize, strings: presentationData.strings, dateTimeFormat: presentationData.dateTimeFormat, nameDisplayOrder: presentationData.nameDisplayOrder, disableAnimations: true, largeEmoji: presentationData.largeEmoji, chatBubbleCorners: presentationData.chatBubbleCorners, animatedEmojiScale: 1.0)
@ -3010,7 +3013,9 @@ public final class ChatHistoryListNodeImpl: ListView, ChatHistoryNode, ChatHisto
expiredMessageStableIds.insert(message.stableId)
}
} else {
//expiredMessageStableIds.insert(message.stableId)
if self.allowDustEffectForAllMessages {
expiredMessageStableIds.insert(message.stableId)
}
}
}
case let .MessageGroupEntry(_, messages, _):
@ -3028,7 +3033,9 @@ public final class ChatHistoryListNodeImpl: ListView, ChatHistoryNode, ChatHisto
expiredMessageStableIds.insert(message.stableId)
}
} else {
//expiredMessageStableIds.insert(message.stableId)
if self.allowDustEffectForAllMessages {
expiredMessageStableIds.insert(message.stableId)
}
}
}
default:

View File

@ -53,7 +53,7 @@ public struct ExperimentalUISettings: Codable, Equatable {
public var storiesExperiment: Bool
public var storiesJpegExperiment: Bool
public var crashOnMemoryPressure: Bool
public var unidirectionalSwipeToReply: Bool
public var dustEffect: Bool
public var callV2: Bool
public var alternativeStoryMedia: Bool
public var allowWebViewInspection: Bool
@ -88,7 +88,7 @@ public struct ExperimentalUISettings: Codable, Equatable {
storiesExperiment: false,
storiesJpegExperiment: false,
crashOnMemoryPressure: false,
unidirectionalSwipeToReply: false,
dustEffect: false,
callV2: false,
alternativeStoryMedia: false,
allowWebViewInspection: false
@ -124,7 +124,7 @@ public struct ExperimentalUISettings: Codable, Equatable {
storiesExperiment: Bool,
storiesJpegExperiment: Bool,
crashOnMemoryPressure: Bool,
unidirectionalSwipeToReply: Bool,
dustEffect: Bool,
callV2: Bool,
alternativeStoryMedia: Bool,
allowWebViewInspection: Bool
@ -157,7 +157,7 @@ public struct ExperimentalUISettings: Codable, Equatable {
self.storiesExperiment = storiesExperiment
self.storiesJpegExperiment = storiesJpegExperiment
self.crashOnMemoryPressure = crashOnMemoryPressure
self.unidirectionalSwipeToReply = unidirectionalSwipeToReply
self.dustEffect = dustEffect
self.callV2 = callV2
self.alternativeStoryMedia = alternativeStoryMedia
self.allowWebViewInspection = allowWebViewInspection
@ -194,7 +194,7 @@ public struct ExperimentalUISettings: Codable, Equatable {
self.storiesExperiment = try container.decodeIfPresent(Bool.self, forKey: "storiesExperiment") ?? false
self.storiesJpegExperiment = try container.decodeIfPresent(Bool.self, forKey: "storiesJpegExperiment") ?? false
self.crashOnMemoryPressure = try container.decodeIfPresent(Bool.self, forKey: "crashOnMemoryPressure") ?? false
self.unidirectionalSwipeToReply = try container.decodeIfPresent(Bool.self, forKey: "unidirectionalSwipeToReply") ?? false
self.dustEffect = try container.decodeIfPresent(Bool.self, forKey: "dustEffect") ?? false
self.callV2 = try container.decodeIfPresent(Bool.self, forKey: "callV2") ?? false
self.alternativeStoryMedia = try container.decodeIfPresent(Bool.self, forKey: "alternativeStoryMedia") ?? false
self.allowWebViewInspection = try container.decodeIfPresent(Bool.self, forKey: "allowWebViewInspection") ?? false
@ -231,7 +231,7 @@ public struct ExperimentalUISettings: Codable, Equatable {
try container.encode(self.storiesExperiment, forKey: "storiesExperiment")
try container.encode(self.storiesJpegExperiment, forKey: "storiesJpegExperiment")
try container.encode(self.crashOnMemoryPressure, forKey: "crashOnMemoryPressure")
try container.encode(self.unidirectionalSwipeToReply, forKey: "unidirectionalSwipeToReply")
try container.encode(self.dustEffect, forKey: "dustEffect")
try container.encode(self.callV2, forKey: "callV2")
try container.encode(self.alternativeStoryMedia, forKey: "alternativeStoryMedia")
try container.encode(self.allowWebViewInspection, forKey: "allowWebViewInspection")