diff --git a/Telegram/BUILD b/Telegram/BUILD index 1e41387b9b..2db05c62e9 100644 --- a/Telegram/BUILD +++ b/Telegram/BUILD @@ -1793,6 +1793,8 @@ plist_fragment( + CADisableMinimumFrameDurationOnPhone + """.format( telegram_bundle_id = telegram_bundle_id, ) diff --git a/submodules/Display/Source/ListView.swift b/submodules/Display/Source/ListView.swift index 9a4ab417cb..4c998fb9a3 100644 --- a/submodules/Display/Source/ListView.swift +++ b/submodules/Display/Source/ListView.swift @@ -2,6 +2,7 @@ import UIKit import AsyncDisplayKit import SwiftSignalKit import UIKitRuntimeUtils +import ObjCRuntimeUtils private let infiniteScrollSize: CGFloat = 10000.0 private let insertionAnimationDuration: Double = 0.4 @@ -822,11 +823,27 @@ open class ListView: ASDisplayNode, UIScrollViewAccessibilityDelegate, UIGesture } private var generalAccumulatedDeltaY: CGFloat = 0.0 + private var previousDidScrollTimestamp: Double = 0.0 private func updateScrollViewDidScroll(_ scrollView: UIScrollView, synchronous: Bool) { if self.ignoreScrollingEvents || scroller !== self.scroller { return } + + /*let timestamp = CACurrentMediaTime() + if !self.previousDidScrollTimestamp.isZero { + let delta = timestamp - self.previousDidScrollTimestamp + if delta < 0.1 { + print("Scrolling delta: \(delta)") + } + } + self.previousDidScrollTimestamp = timestamp + + if let displayLink = self.scroller.getIvarValue("_scrollHeartbeat") as? CADisplayLink { + if #available(iOS 10.0, *) { + displayLink.preferredFramesPerSecond = 120 + } + }*/ //CATransaction.begin() //CATransaction.setDisableActions(true) @@ -854,7 +871,7 @@ open class ListView: ASDisplayNode, UIScrollViewAccessibilityDelegate, UIGesture self.trackingOffset += -deltaY } - self.enqueueUpdateVisibleItems(synchronous: synchronous) + self.enqueueUpdateVisibleItems(synchronous: true) var useScrollDynamics = false diff --git a/submodules/ObjCRuntimeUtils/Source/ObjCRuntimeUtils/RuntimeUtils.h b/submodules/ObjCRuntimeUtils/Source/ObjCRuntimeUtils/RuntimeUtils.h index 3a06e3c3bf..43ada23203 100644 --- a/submodules/ObjCRuntimeUtils/Source/ObjCRuntimeUtils/RuntimeUtils.h +++ b/submodules/ObjCRuntimeUtils/Source/ObjCRuntimeUtils/RuntimeUtils.h @@ -22,6 +22,8 @@ typedef enum { - (id _Nullable)associatedObjectForKey:(void const * _Nonnull)key; - (bool)checkObjectIsKindOfClass:(Class _Nonnull)targetClass; - (void)setClass:(Class _Nonnull)newClass; ++ (NSArray * _Nonnull)getIvarList:(Class _Nonnull)classValue; +- (id _Nullable)getIvarValue:(NSString * _Nonnull)name; @end diff --git a/submodules/ObjCRuntimeUtils/Source/ObjCRuntimeUtils/RuntimeUtils.m b/submodules/ObjCRuntimeUtils/Source/ObjCRuntimeUtils/RuntimeUtils.m index 060faf64d0..60bf470fbd 100644 --- a/submodules/ObjCRuntimeUtils/Source/ObjCRuntimeUtils/RuntimeUtils.m +++ b/submodules/ObjCRuntimeUtils/Source/ObjCRuntimeUtils/RuntimeUtils.m @@ -98,27 +98,34 @@ object_setClass(self, newClass); } -static Class freedomMakeClass(Class superclass, Class subclass, SEL *copySelectors, int copySelectorsCount) -{ - if (superclass == Nil || subclass == Nil) - return nil; - - Class decoratedClass = objc_allocateClassPair(superclass, [[NSString alloc] initWithFormat:@"%@_%@", NSStringFromClass(superclass), NSStringFromClass(subclass)].UTF8String, 0); - - unsigned int count = 0; - Method *methodList = class_copyMethodList(subclass, &count); - if (methodList != NULL) { - for (unsigned int i = 0; i < count; i++) { - SEL methodName = method_getName(methodList[i]); - class_addMethod(decoratedClass, methodName, method_getImplementation(methodList[i]), method_getTypeEncoding(methodList[i])); - } - - free(methodList); ++ (NSArray * _Nonnull)getIvarList:(Class _Nonnull)classValue { + NSMutableArray *result = [[NSMutableArray alloc] init]; + + unsigned int varCount; + + Ivar *vars = class_copyIvarList(classValue, &varCount); + + for (int i = 0; i < varCount; i++) { + Ivar var = vars[i]; + + const char* name = ivar_getName(var); + const char* typeEncoding = ivar_getTypeEncoding(var); + + [result addObject:[NSString stringWithFormat:@"%s: %s", name, typeEncoding]]; } - - objc_registerClassPair(decoratedClass); - - return decoratedClass; + + free(vars); + + return result; +} + +- (id _Nullable)getIvarValue:(NSString * _Nonnull)name { + Ivar ivar = class_getInstanceVariable([self class], [name UTF8String]); + if (!ivar){ + return nil; + } + id value = object_getIvar(self, ivar); + return value; } @end diff --git a/submodules/TelegramCore/Sources/TelegramEngine/Themes/ChatThemes.swift b/submodules/TelegramCore/Sources/TelegramEngine/Themes/ChatThemes.swift index 2fa2be703e..8e99297288 100644 --- a/submodules/TelegramCore/Sources/TelegramEngine/Themes/ChatThemes.swift +++ b/submodules/TelegramCore/Sources/TelegramEngine/Themes/ChatThemes.swift @@ -20,8 +20,8 @@ public struct ChatTheme: PostboxCoding, Equatable { public init(decoder: PostboxDecoder) { self.emoji = decoder.decodeStringForKey("e", orElse: "") - self.theme = decoder.decodeObjectForKey("t") as! TelegramTheme - self.darkTheme = decoder.decodeObjectForKey("dt") as! TelegramTheme + self.theme = decoder.decodeObjectForKey("t", decoder: { TelegramTheme(decoder: $0) }) as! TelegramTheme + self.darkTheme = decoder.decodeObjectForKey("dt", decoder: { TelegramTheme(decoder: $0) }) as! TelegramTheme } public func encode(_ encoder: PostboxEncoder) { diff --git a/submodules/TelegramUI/Sources/PeerInfo/Panes/PeerInfoVisualMediaPaneNode.swift b/submodules/TelegramUI/Sources/PeerInfo/Panes/PeerInfoVisualMediaPaneNode.swift index 9a5af497b4..a66f2a017f 100644 --- a/submodules/TelegramUI/Sources/PeerInfo/Panes/PeerInfoVisualMediaPaneNode.swift +++ b/submodules/TelegramUI/Sources/PeerInfo/Panes/PeerInfoVisualMediaPaneNode.swift @@ -1066,8 +1066,10 @@ final class PeerInfoVisualMediaPaneNode: ASDisplayNode, PeerInfoPaneNode, UIScro self.updateHeaderFlashing(animated: true) } + + private var previousDidScrollTimestamp: Double = 0.0 - func scrollViewDidScroll(_ scrollView: UIScrollView) { + func scrollViewDidScroll(_ scrollView: UIScrollView) { if let (size, sideInset, bottomInset, visibleHeight, _, _, presentationData) = self.currentParams { self.updateVisibleItems(size: size, sideInset: sideInset, bottomInset: bottomInset, visibleHeight: visibleHeight, theme: presentationData.theme, strings: presentationData.strings, synchronousLoad: false)