From 1b3cfcb124f43c9f5754a555c4ad2a6e6ed1f7eb Mon Sep 17 00:00:00 2001 From: Ali <> Date: Tue, 26 Sep 2023 18:42:50 +0400 Subject: [PATCH 1/6] Some MTSignal fixes --- .../PublicHeaders/MtProtoKit/MTSignal.h | 5 + submodules/MtProtoKit/Sources/MTContext.m | 18 +- submodules/MtProtoKit/Sources/MTDNS.m | 4 +- submodules/MtProtoKit/Sources/MTDisposable.m | 241 +++++++++--------- submodules/MtProtoKit/Sources/MTProto.m | 4 +- submodules/MtProtoKit/Sources/MTSignal.m | 163 +++++++++--- submodules/MtProtoKit/Sources/MTSubscriber.m | 30 ++- .../MtProtoKit/Sources/MTTcpConnection.m | 4 +- submodules/SSignalKit/SSignalKit/BUILD | 1 - 9 files changed, 300 insertions(+), 170 deletions(-) diff --git a/submodules/MtProtoKit/PublicHeaders/MtProtoKit/MTSignal.h b/submodules/MtProtoKit/PublicHeaders/MtProtoKit/MTSignal.h index c7e852057d..d00926cfd4 100644 --- a/submodules/MtProtoKit/PublicHeaders/MtProtoKit/MTSignal.h +++ b/submodules/MtProtoKit/PublicHeaders/MtProtoKit/MTSignal.h @@ -13,8 +13,13 @@ - (instancetype)initWithGenerator:(id (^)(MTSubscriber *))generator; - (id)startWithNext:(void (^)(id next))next error:(void (^)(id error))error completed:(void (^)())completed; +- (id)startWithNextStrict:(void (^)(id next))next error:(void (^)(id error))error completed:(void (^)())completed file:(const char *)file line:(int)line; + - (id)startWithNext:(void (^)(id next))next; +- (id)startWithNextStrict:(void (^)(id next))next file:(const char *)file line:(int)line; + - (id)startWithNext:(void (^)(id next))next completed:(void (^)())completed; +- (id)startWithNextStrict:(void (^)(id next))next completed:(void (^)())completed file:(const char *)file line:(int)line; + (MTSignal *)single:(id)next; + (MTSignal *)fail:(id)error; diff --git a/submodules/MtProtoKit/Sources/MTContext.m b/submodules/MtProtoKit/Sources/MTContext.m index 7b425dc085..dba8f3f394 100644 --- a/submodules/MtProtoKit/Sources/MTContext.m +++ b/submodules/MtProtoKit/Sources/MTContext.m @@ -1030,15 +1030,17 @@ static void copyKeychainDictionaryKey(NSString * _Nonnull group, NSString * _Non __weak MTContext *weakSelf = self; MTMetaDisposable *disposable = [[MTMetaDisposable alloc] init]; _fetchPublicKeysActions[@(datacenterId)] = disposable; - [disposable setDisposable:[signal startWithNext:^(NSArray *next) { + [disposable setDisposable:[signal startWithNextStrict:^(NSArray *next) { [[MTContext contextQueue] dispatchOnQueue:^{ __strong MTContext *strongSelf = weakSelf; if (strongSelf != nil) { + id disposable = strongSelf->_fetchPublicKeysActions[@(datacenterId)]; [strongSelf->_fetchPublicKeysActions removeObjectForKey:@(datacenterId)]; + [disposable dispose]; [strongSelf updatePublicKeysForDatacenterWithId:datacenterId publicKeys:next]; } } synchronous:false]; - }]]; + } file:__FILE_NAME__ line:__LINE__]]; break; } } @@ -1157,10 +1159,12 @@ static void copyKeychainDictionaryKey(NSString * _Nonnull group, NSString * _Non { [[MTContext contextQueue] dispatchOnQueue:^ { + id disposable = strongSelf->_transportSchemeDisposableByDatacenterId[@(datacenterId)]; [strongSelf->_transportSchemeDisposableByDatacenterId removeObjectForKey:@(datacenterId)]; + [disposable dispose]; }]; } - }] startWithNext:^(MTTransportScheme *next) + }] startWithNextStrict:^(MTTransportScheme *next) { if (MTLogEnabled()) { MTLog(@"scheme: %@", next); @@ -1176,7 +1180,7 @@ static void copyKeychainDictionaryKey(NSString * _Nonnull group, NSString * _Non } completed:^ { - }]; + } file:__FILE_NAME__ line:__LINE__]; } }]; } @@ -1293,7 +1297,7 @@ static void copyKeychainDictionaryKey(NSString * _Nonnull group, NSString * _Non [strongSelf->_backupAddressListDisposable dispose]; strongSelf->_backupAddressListDisposable = nil; } - }] startWithNext:nil]; + }] startWithNextStrict:nil file:__FILE_NAME__ line:__LINE__]; } } @@ -1491,7 +1495,7 @@ static void copyKeychainDictionaryKey(NSString * _Nonnull group, NSString * _Non _datacenterCheckKeyRemovedActionTimestamps[@(datacenterId)] = currentTimestamp; [_datacenterCheckKeyRemovedActions[@(datacenterId)] dispose]; __weak MTContext *weakSelf = self; - _datacenterCheckKeyRemovedActions[@(datacenterId)] = [[MTDiscoverConnectionSignals checkIfAuthKeyRemovedWithContext:self datacenterId:datacenterId authKey:[[MTDatacenterAuthKey alloc] initWithAuthKey:authInfo.authKey authKeyId:authInfo.authKeyId validUntilTimestamp:authInfo.validUntilTimestamp notBound:false]] startWithNext:^(NSNumber* isRemoved) { + _datacenterCheckKeyRemovedActions[@(datacenterId)] = [[MTDiscoverConnectionSignals checkIfAuthKeyRemovedWithContext:self datacenterId:datacenterId authKey:[[MTDatacenterAuthKey alloc] initWithAuthKey:authInfo.authKey authKeyId:authInfo.authKeyId validUntilTimestamp:authInfo.validUntilTimestamp notBound:false]] startWithNextStrict:^(NSNumber* isRemoved) { [[MTContext contextQueue] dispatchOnQueue:^{ __strong MTContext *strongSelf = weakSelf; if (strongSelf == nil) { @@ -1506,7 +1510,7 @@ static void copyKeychainDictionaryKey(NSString * _Nonnull group, NSString * _Non } } }]; - }]; + } file:__FILE_NAME__ line:__LINE__]; } }]; } diff --git a/submodules/MtProtoKit/Sources/MTDNS.m b/submodules/MtProtoKit/Sources/MTDNS.m index 0b99d81516..3448e7f239 100644 --- a/submodules/MtProtoKit/Sources/MTDNS.m +++ b/submodules/MtProtoKit/Sources/MTDNS.m @@ -125,7 +125,7 @@ if (disposable != nil) { __weak MTDNSContext *weakSelf = self; - [disposable setDisposable:[[[self performLookup:host port:port] deliverOn:[MTDNSContext sharedQueue]] startWithNext:^(NSString *result) { + [disposable setDisposable:[[[self performLookup:host port:port] deliverOn:[MTDNSContext sharedQueue]] startWithNextStrict:^(NSString *result) { __strong MTDNSContext *strongSelf = weakSelf; if (strongSelf == nil) { return; @@ -134,7 +134,7 @@ [strongSelf->_contexts[key] complete:result]; [strongSelf->_contexts removeObjectForKey:key]; } - }]]; + } file:__FILE_NAME__ line:__LINE__]]; } __weak MTDNSContext *weakSelf = self; diff --git a/submodules/MtProtoKit/Sources/MTDisposable.m b/submodules/MtProtoKit/Sources/MTDisposable.m index cb673e0b68..949f1d4e88 100644 --- a/submodules/MtProtoKit/Sources/MTDisposable.m +++ b/submodules/MtProtoKit/Sources/MTDisposable.m @@ -1,13 +1,11 @@ #import -#import -#import -#import +#import #import -@interface MTBlockDisposable () -{ - void *_block; +@interface MTBlockDisposable () { + void (^_action)(); + pthread_mutex_t _lock; } @end @@ -19,47 +17,35 @@ self = [super init]; if (self != nil) { - _block = (__bridge_retained void *)[block copy]; + _action = [block copy]; + pthread_mutex_init(&_lock, nil); } return self; } -- (void)dealloc -{ - void *block = _block; - if (block != NULL) - { -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated-declarations" - if (OSAtomicCompareAndSwapPtr(block, 0, &_block)) - { - if (block != nil) - { - __unused __strong id strongBlock = (__bridge_transfer id)block; - strongBlock = nil; - } - } -#pragma clang diagnostic pop +- (void)dealloc { + void (^freeAction)() = nil; + pthread_mutex_lock(&_lock); + freeAction = _action; + _action = nil; + pthread_mutex_unlock(&_lock); + + if (freeAction) { } + + pthread_mutex_destroy(&_lock); } -- (void)dispose -{ - void *block = _block; - if (block != NULL) - { -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated-declarations" - if (OSAtomicCompareAndSwapPtr(block, 0, &_block)) - { - if (block != nil) - { - __strong id strongBlock = (__bridge_transfer id)block; - ((dispatch_block_t)strongBlock)(); - strongBlock = nil; - } - } -#pragma clang diagnostic pop +- (void)dispose { + void (^disposeAction)() = nil; + + pthread_mutex_lock(&_lock); + disposeAction = _action; + _action = nil; + pthread_mutex_unlock(&_lock); + + if (disposeAction) { + disposeAction(); } } @@ -67,7 +53,7 @@ @interface MTMetaDisposable () { - os_unfair_lock _lock; + pthread_mutex_t _lock; bool _disposed; id _disposable; } @@ -76,128 +62,139 @@ @implementation MTMetaDisposable -- (void)setDisposable:(id)disposable -{ - id previousDisposable = nil; - bool dispose = false; +- (instancetype)init { + self = [super init]; + if (self != nil) { + pthread_mutex_init(&_lock, nil); + } + return self; +} + +- (void)dealloc { + id freeDisposable = nil; + pthread_mutex_lock(&_lock); + if (_disposable) { + freeDisposable = _disposable; + _disposable = nil; + } + pthread_mutex_unlock(&_lock); - os_unfair_lock_lock(&_lock); - dispose = _disposed; - if (!dispose) - { + if (freeDisposable) { + } + + pthread_mutex_destroy(&_lock); +} + +- (void)setDisposable:(id)disposable { + id previousDisposable = nil; + bool disposeImmediately = false; + + pthread_mutex_lock(&_lock); + disposeImmediately = _disposed; + if (!disposeImmediately) { previousDisposable = _disposable; _disposable = disposable; } - os_unfair_lock_unlock(&_lock); + pthread_mutex_unlock(&_lock); - if (previousDisposable != nil) + if (previousDisposable) { [previousDisposable dispose]; + } - if (dispose) + if (disposeImmediately) { [disposable dispose]; + } } -- (void)dispose -{ +- (void)dispose { id disposable = nil; - os_unfair_lock_lock(&_lock); - if (!_disposed) - { - disposable = _disposable; + pthread_mutex_lock(&_lock); + if (!_disposed) { _disposed = true; + disposable = _disposable; + _disposable = nil; } - os_unfair_lock_unlock(&_lock); + pthread_mutex_unlock(&_lock); - if (disposable != nil) + if (disposable) { [disposable dispose]; + } } @end @interface MTDisposableSet () { - os_unfair_lock _lock; + pthread_mutex_t _lock; bool _disposed; - id _singleDisposable; - NSArray *_multipleDisposables; + NSMutableArray> *_disposables; } @end @implementation MTDisposableSet -- (void)add:(id)disposable -{ - if (disposable == nil) - return; - - bool dispose = false; - - os_unfair_lock_lock(&_lock); - dispose = _disposed; - if (!dispose) - { - if (_multipleDisposables != nil) - { - NSMutableArray *multipleDisposables = [[NSMutableArray alloc] initWithArray:_multipleDisposables]; - [multipleDisposables addObject:disposable]; - _multipleDisposables = multipleDisposables; - } - else if (_singleDisposable != nil) - { - NSMutableArray *multipleDisposables = [[NSMutableArray alloc] initWithObjects:_singleDisposable, disposable, nil]; - _multipleDisposables = multipleDisposables; - _singleDisposable = nil; - } - else - { - _singleDisposable = disposable; - } +- (instancetype)init { + self = [super init]; + if (self != nil) { + pthread_mutex_init(&_lock, nil); + _disposables = [[NSMutableArray alloc] init]; } - os_unfair_lock_unlock(&_lock); + return self; +} + +- (void)dealloc { + NSArray> *disposables = nil; + pthread_mutex_lock(&_lock); + disposables = _disposables; + _disposables = nil; + pthread_mutex_unlock(&_lock); - if (dispose) + if (disposables) { + } + pthread_mutex_destroy(&_lock); +} + +- (void)add:(id)disposable { + bool disposeImmediately = false; + + pthread_mutex_lock(&_lock); + if (_disposed) { + disposeImmediately = true; + } else { + [_disposables addObject:disposable]; + } + pthread_mutex_unlock(&_lock); + + if (disposeImmediately) { [disposable dispose]; + } } - (void)remove:(id)disposable { - os_unfair_lock_lock(&_lock); - if (_multipleDisposables != nil) - { - NSMutableArray *multipleDisposables = [[NSMutableArray alloc] initWithArray:_multipleDisposables]; - [multipleDisposables removeObject:disposable]; - _multipleDisposables = multipleDisposables; + pthread_mutex_lock(&_lock); + for (NSInteger i = 0; i < _disposables.count; i++) { + if (_disposables[i] == disposable) { + [_disposables removeObjectAtIndex:i]; + break; + } } - else if (_singleDisposable == disposable) - { - _singleDisposable = nil; - } - os_unfair_lock_unlock(&_lock); + pthread_mutex_unlock(&_lock); } -- (void)dispose -{ - id singleDisposable = nil; - NSArray *multipleDisposables = nil; - - os_unfair_lock_lock(&_lock); - if (!_disposed) - { +- (void)dispose { + NSArray> *disposables = nil; + pthread_mutex_lock(&_lock); + if (!_disposed) { _disposed = true; - singleDisposable = _singleDisposable; - multipleDisposables = _multipleDisposables; - _singleDisposable = nil; - _multipleDisposables = nil; + disposables = _disposables; + _disposables = nil; } - os_unfair_lock_unlock(&_lock); + pthread_mutex_unlock(&_lock); - if (singleDisposable != nil) - [singleDisposable dispose]; - if (multipleDisposables != nil) - { - for (id disposable in multipleDisposables) - { + if (disposables) { + for (id disposable in disposables) { [disposable dispose]; } } diff --git a/submodules/MtProtoKit/Sources/MTProto.m b/submodules/MtProtoKit/Sources/MTProto.m index 725a95e696..91a79f97c2 100644 --- a/submodules/MtProtoKit/Sources/MTProto.m +++ b/submodules/MtProtoKit/Sources/MTProto.m @@ -838,7 +838,7 @@ static const NSUInteger MTMaxUnacknowledgedMessageCount = 64; __weak MTProto *weakSelf = self; MTSignal *checkSignal = [[MTConnectionProbing probeProxyWithContext:_context datacenterId:_datacenterId settings:transport.proxySettings] delay:5.0 onQueue:[MTQueue concurrentDefaultQueue]]; checkSignal = [[checkSignal then:[[MTSignal complete] delay:20.0 onQueue:[MTQueue concurrentDefaultQueue]]] restart]; - [_probingDisposable setDisposable:[checkSignal startWithNext:^(NSNumber *next) { + [_probingDisposable setDisposable:[checkSignal startWithNextStrict:^(NSNumber *next) { [[MTProto managerQueue] dispatchOnQueue:^{ __strong MTProto *strongSelf = weakSelf; if (strongSelf == nil) { @@ -849,7 +849,7 @@ static const NSUInteger MTMaxUnacknowledgedMessageCount = 64; [strongSelf _updateConnectionIssuesStatus:[strongSelf->_probingStatus boolValue]]; } }]; - }]]; + } file:__FILE_NAME__ line:__LINE__]]; } } }]; diff --git a/submodules/MtProtoKit/Sources/MTSignal.m b/submodules/MtProtoKit/Sources/MTSignal.m index f1c06c919b..f1065bce71 100644 --- a/submodules/MtProtoKit/Sources/MTSignal.m +++ b/submodules/MtProtoKit/Sources/MTSignal.m @@ -1,6 +1,6 @@ #import -#import +#import #import #import #import @@ -8,28 +8,97 @@ @interface MTSubscriberDisposable : NSObject { - MTSubscriber *_subscriber; + __weak MTSubscriber *_subscriber; id _disposable; + pthread_mutex_t _lock; } @end @implementation MTSubscriberDisposable -- (instancetype)initWithSubscriber:(MTSubscriber *)subscriber disposable:(id)disposable -{ +- (instancetype)initWithSubscriber:(MTSubscriber *)subscriber disposable:(id)disposable { self = [super init]; - if (self != nil) - { + if (self != nil) { _subscriber = subscriber; _disposable = disposable; + pthread_mutex_init(&_lock, nil); } return self; } -- (void)dispose -{ - [_subscriber _markTerminatedWithoutDisposal]; +- (void)dealloc { + pthread_mutex_destroy(&_lock); +} + +- (void)dispose { + MTSubscriber *subscriber = nil; + id disposeItem = nil; + pthread_mutex_lock(&_lock); + disposeItem = _disposable; + _disposable = nil; + subscriber = _subscriber; + _subscriber = nil; + pthread_mutex_unlock(&_lock); + + [disposeItem dispose]; + [subscriber _markTerminatedWithoutDisposal]; +} + +@end + +@interface MTStrictDisposable : NSObject { + id _disposable; + const char *_file; + int _line; + +#if DEBUG + pthread_mutex_t _lock; + bool _isDisposed; +#endif +} + +- (instancetype)initWithDisposable:(id)disposable file:(const char *)file line:(int)line; +- (void)dispose; + +@end + +@implementation MTStrictDisposable + +- (instancetype)initWithDisposable:(id)disposable file:(const char *)file line:(int)line { + self = [super init]; + if (self != nil) { + _disposable = disposable; + _file = file; + _line = line; + +#if DEBUG + pthread_mutex_init(&_lock, nil); +#endif + } + return self; +} + +- (void)dealloc { +#if DEBUG + pthread_mutex_lock(&_lock); + if (!_isDisposed) { + NSLog(@"Leaked disposable from %s:%d", _file, _line); + assert(false); + } + pthread_mutex_unlock(&_lock); + + pthread_mutex_destroy(&_lock); +#endif +} + +- (void)dispose { +#if DEBUG + pthread_mutex_lock(&_lock); + _isDisposed = true; + pthread_mutex_unlock(&_lock); +#endif + [_disposable dispose]; } @@ -55,7 +124,7 @@ @interface MTSignalQueueState : NSObject { - os_unfair_lock _lock; + pthread_mutex_t _lock; bool _executingSignal; bool _terminated; @@ -76,6 +145,8 @@ self = [super init]; if (self != nil) { + pthread_mutex_init(&_lock, nil); + _subscriber = subscriber; _currentDisposable = [[MTMetaDisposable alloc] init]; _queuedSignals = queueMode ? [[NSMutableArray alloc] init] : nil; @@ -84,6 +155,10 @@ return self; } +- (void)dealloc { + pthread_mutex_destroy(&_lock); +} + - (void)beginWithDisposable:(id)disposable { _disposable = disposable; @@ -92,7 +167,7 @@ - (void)enqueueSignal:(MTSignal *)signal { bool startSignal = false; - os_unfair_lock_lock(&_lock); + pthread_mutex_lock(&_lock); if (_queueMode && _executingSignal) { [_queuedSignals addObject:signal]; @@ -102,7 +177,7 @@ _executingSignal = true; startSignal = true; } - os_unfair_lock_unlock(&_lock); + pthread_mutex_unlock(&_lock); if (startSignal) { @@ -130,7 +205,7 @@ MTSignal *nextSignal = nil; bool terminated = false; - os_unfair_lock_lock(&_lock); + pthread_mutex_lock(&_lock); _executingSignal = false; if (_queueMode) @@ -146,7 +221,7 @@ } else terminated = _terminated; - os_unfair_lock_unlock(&_lock); + pthread_mutex_unlock(&_lock); if (terminated) [_subscriber putCompletion]; @@ -174,10 +249,10 @@ - (void)beginCompletion { bool executingSignal = false; - os_unfair_lock_lock(&_lock); + pthread_mutex_lock(&_lock); executingSignal = _executingSignal; _terminated = true; - os_unfair_lock_unlock(&_lock); + pthread_mutex_unlock(&_lock); if (!executingSignal) [_subscriber putCompletion]; @@ -235,6 +310,14 @@ return [[MTSubscriberDisposable alloc] initWithSubscriber:subscriber disposable:disposable]; } +- (id)startWithNextStrict:(void (^)(id next))next error:(void (^)(id error))error completed:(void (^)())completed file:(const char *)file line:(int)line +{ + MTSubscriber *subscriber = [[MTSubscriber alloc] initWithNext:next error:error completed:completed]; + id disposable = _generator(subscriber); + [subscriber _assignDisposable:disposable]; + return [[MTStrictDisposable alloc] initWithDisposable:[[MTSubscriberDisposable alloc] initWithSubscriber:subscriber disposable:disposable] file:file line:line]; +} + - (id)startWithNext:(void (^)(id next))next { MTSubscriber *subscriber = [[MTSubscriber alloc] initWithNext:next error:nil completed:nil]; @@ -243,6 +326,14 @@ return [[MTSubscriberDisposable alloc] initWithSubscriber:subscriber disposable:disposable]; } +- (id)startWithNextStrict:(void (^)(id next))next file:(const char *)file line:(int)line +{ + MTSubscriber *subscriber = [[MTSubscriber alloc] initWithNext:next error:nil completed:nil]; + id disposable = _generator(subscriber); + [subscriber _assignDisposable:disposable]; + return [[MTStrictDisposable alloc] initWithDisposable:[[MTSubscriberDisposable alloc] initWithSubscriber:subscriber disposable:disposable] file:file line:line]; +} + - (id)startWithNext:(void (^)(id next))next completed:(void (^)())completed { MTSubscriber *subscriber = [[MTSubscriber alloc] initWithNext:next error:nil completed:completed]; @@ -251,6 +342,14 @@ return [[MTSubscriberDisposable alloc] initWithSubscriber:subscriber disposable:disposable]; } +- (id)startWithNextStrict:(void (^)(id next))next completed:(void (^)())completed file:(const char *)file line:(int)line +{ + MTSubscriber *subscriber = [[MTSubscriber alloc] initWithNext:next error:nil completed:completed]; + id disposable = _generator(subscriber); + [subscriber _assignDisposable:disposable]; + return [[MTStrictDisposable alloc] initWithDisposable:[[MTSubscriberDisposable alloc] initWithSubscriber:subscriber disposable:disposable] file:file line:line]; +} + + (MTSignal *)single:(id)next { return [[MTSignal alloc] initWithGenerator:^id (MTSubscriber *subscriber) @@ -324,11 +423,11 @@ { return [[MTSignal alloc] initWithGenerator:^id (MTSubscriber *subscriber) { - MTMetaDisposable *disposable = [[MTMetaDisposable alloc] init]; + MTMetaDisposable *startDisposable = [[MTMetaDisposable alloc] init]; + MTMetaDisposable *timerDisposable = [[MTMetaDisposable alloc] init]; - MTTimer *timer = [[MTTimer alloc] initWithTimeout:seconds repeat:false completion:^ - { - [disposable setDisposable:[self startWithNext:^(id next) + MTTimer *timer = [[MTTimer alloc] initWithTimeout:seconds repeat:false completion:^{ + [startDisposable setDisposable:[self startWithNext:^(id next) { [subscriber putNext:next]; } error:^(id error) @@ -342,12 +441,15 @@ [timer start]; - [disposable setDisposable:[[MTBlockDisposable alloc] initWithBlock:^ + [timerDisposable setDisposable:[[MTBlockDisposable alloc] initWithBlock:^ { [timer invalidate]; }]]; - return disposable; + return [[MTBlockDisposable alloc] initWithBlock:^{ + [startDisposable dispose]; + [timerDisposable dispose]; + }]; }]; } @@ -355,11 +457,11 @@ { return [[MTSignal alloc] initWithGenerator:^id (MTSubscriber *subscriber) { - MTMetaDisposable *disposable = [[MTMetaDisposable alloc] init]; - - MTTimer *timer = [[MTTimer alloc] initWithTimeout:seconds repeat:false completion:^ - { - [disposable setDisposable:[signal startWithNext:^(id next) + MTMetaDisposable *startDisposable = [[MTMetaDisposable alloc] init]; + MTMetaDisposable *timerDisposable = [[MTMetaDisposable alloc] init]; + + MTTimer *timer = [[MTTimer alloc] initWithTimeout:seconds repeat:false completion:^{ + [startDisposable setDisposable:[signal startWithNext:^(id next) { [subscriber putNext:next]; } error:^(id error) @@ -372,7 +474,7 @@ } queue:queue.nativeQueue]; [timer start]; - [disposable setDisposable:[self startWithNext:^(id next) + [timerDisposable setDisposable:[self startWithNext:^(id next) { [timer invalidate]; [subscriber putNext:next]; @@ -386,7 +488,10 @@ [subscriber putCompletion]; }]]; - return disposable; + return [[MTBlockDisposable alloc] initWithBlock:^{ + [startDisposable dispose]; + [timerDisposable dispose]; + }]; }]; } diff --git a/submodules/MtProtoKit/Sources/MTSubscriber.m b/submodules/MtProtoKit/Sources/MTSubscriber.m index da600346c9..db324ed7d0 100644 --- a/submodules/MtProtoKit/Sources/MTSubscriber.m +++ b/submodules/MtProtoKit/Sources/MTSubscriber.m @@ -68,6 +68,7 @@ { os_unfair_lock_lock(&_lock); MTSubscriberBlocks *blocks = nil; + id disposable = _disposable; if (!_terminated) { blocks = _blocks; @@ -80,6 +81,8 @@ if (blocks) { blocks = nil; } + if (disposable) { + } } - (void)putNext:(id)next @@ -100,6 +103,7 @@ - (void)putError:(id)error { bool shouldDispose = false; + id disposable = nil; MTSubscriberBlocks *blocks = nil; os_unfair_lock_lock(&_lock); @@ -111,19 +115,23 @@ shouldDispose = true; _terminated = true; } + disposable = _disposable; + _disposable = nil; os_unfair_lock_unlock(&_lock); if (blocks && blocks->_error) { blocks->_error(error); } - if (shouldDispose) - [self->_disposable dispose]; + if (shouldDispose) { + [disposable dispose]; + } } - (void)putCompletion { bool shouldDispose = false; + id disposable = nil; MTSubscriberBlocks *blocks = nil; os_unfair_lock_lock(&_lock); @@ -135,18 +143,30 @@ shouldDispose = true; _terminated = true; } + disposable = _disposable; + _disposable = nil; os_unfair_lock_unlock(&_lock); if (blocks && blocks->_completed) blocks->_completed(); - if (shouldDispose) - [self->_disposable dispose]; + if (shouldDispose) { + [disposable dispose]; + } } - (void)dispose { - [self->_disposable dispose]; + id disposable = nil; + + os_unfair_lock_lock(&_lock); + disposable = _disposable; + _disposable = nil; + os_unfair_lock_unlock(&_lock); + + if (disposable) { + [disposable dispose]; + } } @end diff --git a/submodules/MtProtoKit/Sources/MTTcpConnection.m b/submodules/MtProtoKit/Sources/MTTcpConnection.m index dd2755e68d..e8cf239881 100644 --- a/submodules/MtProtoKit/Sources/MTTcpConnection.m +++ b/submodules/MtProtoKit/Sources/MTTcpConnection.m @@ -947,7 +947,7 @@ struct ctr_state { } __weak MTTcpConnection *weakSelf = self; - [_resolveDisposable setDisposable:[resolveSignal startWithNext:^(MTTcpConnectionData *connectionData) { + [_resolveDisposable setDisposable:[resolveSignal startWithNextStrict:^(MTTcpConnectionData *connectionData) { [[MTTcpConnection tcpQueue] dispatchOnQueue:^{ __strong MTTcpConnection *strongSelf = weakSelf; if (strongSelf == nil || connectionData == nil) { @@ -1111,7 +1111,7 @@ struct ctr_state { [strongSelf->_socket readDataToLength:sizeof(struct socks5_ident_resp) withTimeout:-1 tag:MTTcpSocksLogin]; } }]; - }]]; + } file:__FILE_NAME__ line:__LINE__]]; } }]; } diff --git a/submodules/SSignalKit/SSignalKit/BUILD b/submodules/SSignalKit/SSignalKit/BUILD index eb2b9a82f7..98f1b6f95c 100644 --- a/submodules/SSignalKit/SSignalKit/BUILD +++ b/submodules/SSignalKit/SSignalKit/BUILD @@ -16,7 +16,6 @@ objc_library( "Source", ], deps = [ - "//submodules/SSignalKit/SwiftSignalKit" ], sdk_frameworks = [ "Foundation", From 9eb8bf93a7957456318054f4c042942765e07b48 Mon Sep 17 00:00:00 2001 From: Ali <> Date: Tue, 26 Sep 2023 18:47:51 +0400 Subject: [PATCH 2/6] Restore account presence manager updates --- submodules/TelegramCore/Sources/Account/Account.swift | 2 +- .../Sources/State/ManagedAccountPresence.swift | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/submodules/TelegramCore/Sources/Account/Account.swift b/submodules/TelegramCore/Sources/Account/Account.swift index 971e24bb3b..0e93e915b8 100644 --- a/submodules/TelegramCore/Sources/Account/Account.swift +++ b/submodules/TelegramCore/Sources/Account/Account.swift @@ -1196,7 +1196,7 @@ public class Account { self.accountPresenceManager.isPerformingUpdate() |> map { presenceUpdate in if presenceUpdate { print("accountPresenceManager isPerformingUpdate: true") - return [] + //return [] } return presenceUpdate ? AccountRunningImportantTasks.other : [] }, diff --git a/submodules/TelegramCore/Sources/State/ManagedAccountPresence.swift b/submodules/TelegramCore/Sources/State/ManagedAccountPresence.swift index b14f0fbc95..445008c1b9 100644 --- a/submodules/TelegramCore/Sources/State/ManagedAccountPresence.swift +++ b/submodules/TelegramCore/Sources/State/ManagedAccountPresence.swift @@ -16,6 +16,8 @@ private final class AccountPresenceManagerImpl { private let currentRequestDisposable = MetaDisposable() private var onlineTimer: SignalKitTimer? + private var wasOnline: Bool = false + init(queue: Queue, shouldKeepOnlinePresence: Signal, network: Network) { self.queue = queue self.network = network @@ -23,7 +25,13 @@ private final class AccountPresenceManagerImpl { self.shouldKeepOnlinePresenceDisposable = (shouldKeepOnlinePresence |> distinctUntilChanged |> deliverOn(self.queue)).start(next: { [weak self] value in - self?.updatePresence(value) + guard let self else { + return + } + if self.wasOnline != value { + self.wasOnline = value + self.updatePresence(value) + } }) } From 993db8cc1de15bcd1c6fdd533d118a98766d7c02 Mon Sep 17 00:00:00 2001 From: Ali <> Date: Wed, 27 Sep 2023 23:18:07 +0400 Subject: [PATCH 3/6] Fix CXXFLAGS --- third-party/libjxl/build-libjxl-bazel.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/third-party/libjxl/build-libjxl-bazel.sh b/third-party/libjxl/build-libjxl-bazel.sh index 17d46032b9..993dbf929f 100755 --- a/third-party/libjxl/build-libjxl-bazel.sh +++ b/third-party/libjxl/build-libjxl-bazel.sh @@ -15,6 +15,7 @@ if [ "$ARCH" = "arm64" ]; then IOS_PLATFORMDIR="$(xcode-select -p)/Platforms/iPhoneOS.platform" IOS_SYSROOT=($IOS_PLATFORMDIR/Developer/SDKs/iPhoneOS*.sdk) export CFLAGS="-Wall -arch arm64 -miphoneos-version-min=12.0 -funwind-tables" + export CXXFLAGS="$CFLAGS" cd "$BUILD_DIR" mkdir build @@ -31,7 +32,8 @@ elif [ "$ARCH" = "sim_arm64" ]; then IOS_PLATFORMDIR="$(xcode-select -p)/Platforms/iPhoneSimulator.platform" IOS_SYSROOT=($IOS_PLATFORMDIR/Developer/SDKs/iPhoneSimulator*.sdk) export CFLAGS="-Wall -arch arm64 --target=arm64-apple-ios12.0-simulator -miphonesimulator-version-min=12.0 -funwind-tables" - + export CXXFLAGS="$CFLAGS" + cd "$BUILD_DIR" mkdir build cd build @@ -47,7 +49,8 @@ elif [ "$ARCH" = "x86_64" ]; then IOS_PLATFORMDIR="$(xcode-select -p)/Platforms/iPhoneSimulator.platform" IOS_SYSROOT=($IOS_PLATFORMDIR/Developer/SDKs/iPhoneSimulator*.sdk) export CFLAGS="-Wall -arch x86_64 -miphoneos-version-min=12.0 -funwind-tables" - + export CXXFLAGS="$CFLAGS" + cd "$BUILD_DIR" mkdir build cd build From 5ca7082fbb4ed2c74ff72e8cf6e13b0236cda5be Mon Sep 17 00:00:00 2001 From: Ali <> Date: Wed, 27 Sep 2023 23:18:16 +0400 Subject: [PATCH 4/6] Fix string --- .../Sources/AnimatedCountLabelNode.swift | 20 +++++++++++++++---- .../Sources/StoryFooterPanelComponent.swift | 5 +++-- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/submodules/AnimatedCountLabelNode/Sources/AnimatedCountLabelNode.swift b/submodules/AnimatedCountLabelNode/Sources/AnimatedCountLabelNode.swift index 1e4d6911be..ae9341d834 100644 --- a/submodules/AnimatedCountLabelNode/Sources/AnimatedCountLabelNode.swift +++ b/submodules/AnimatedCountLabelNode/Sources/AnimatedCountLabelNode.swift @@ -375,7 +375,7 @@ public class AnimatedCountLabelView: UIView { fatalError("init(coder:) has not been implemented") } - public func update(size: CGSize, segments initialSegments: [Segment], transition: ContainedViewLayoutTransition) -> Layout { + public func update(size: CGSize, segments initialSegments: [Segment], reducedLetterSpacing: Bool = false, transition: ContainedViewLayoutTransition) -> Layout { var segmentLayouts: [ResolvedSegment.Key: (TextNodeLayoutArguments) -> (TextNodeLayout, () -> TextNode)] = [:] let wasEmpty = self.resolvedSegments.isEmpty for (segmentKey, segmentAndTextNode) in self.resolvedSegments { @@ -393,7 +393,15 @@ public class AnimatedCountLabelView: UIView { } let attributes = string.attributes(at: 0, longestEffectiveRange: nil, in: NSRange(location: 0, length: 1)) - var remainingValue = value + for character in string.string { + if let _ = Int(String(character)) { + segments.append(.number(id: 1000 + segments.count, value: value, string: NSAttributedString(string: String(character), attributes: attributes))) + } else { + segments.append(.text(id: 1000 + segments.count, string: NSAttributedString(string: String(character), attributes: attributes))) + } + } + + /*var remainingValue = value let insertPosition = segments.count @@ -405,7 +413,7 @@ public class AnimatedCountLabelView: UIView { if remainingValue == 0 { break } - } + }*/ case let .text(id, string): segments.append(.text(id: id, string: string)) } @@ -489,7 +497,11 @@ public class AnimatedCountLabelView: UIView { } else if textNode.frame != textFrame { transition.updateFrameAdditive(node: textNode, frame: textFrame) } - currentOffset.x += effectiveSegmentWidth + if reducedLetterSpacing { + currentOffset.x += effectiveSegmentWidth * 0.9 + } else { + currentOffset.x += effectiveSegmentWidth + } if let (_, currentTextNode) = self.resolvedSegments[segment.key] { if currentTextNode !== textNode { currentTextNode.removeFromSupernode() diff --git a/submodules/TelegramUI/Components/Stories/StoryFooterPanelComponent/Sources/StoryFooterPanelComponent.swift b/submodules/TelegramUI/Components/Stories/StoryFooterPanelComponent/Sources/StoryFooterPanelComponent.swift index 0c5cf7e035..f178635b82 100644 --- a/submodules/TelegramUI/Components/Stories/StoryFooterPanelComponent/Sources/StoryFooterPanelComponent.swift +++ b/submodules/TelegramUI/Components/Stories/StoryFooterPanelComponent/Sources/StoryFooterPanelComponent.swift @@ -537,7 +537,7 @@ public final class StoryFooterPanelComponent: Component { var regularSegments: [AnimatedCountLabelView.Segment] = [] if viewCount != 0 { - regularSegments.append(.number(viewCount, NSAttributedString(string: "\(viewCount)", font: Font.with(size: 15.0, traits: .monospacedNumbers), textColor: .white))) + regularSegments.append(.number(viewCount, NSAttributedString(string: countString(Int64(viewCount)), font: Font.with(size: 15.0, traits: .monospacedNumbers), textColor: .white))) } let viewPart: String @@ -555,7 +555,7 @@ public final class StoryFooterPanelComponent: Component { viewPart = string } - let viewStatsTextLayout = self.viewStatsCountText.update(size: CGSize(width: availableSize.width, height: size.height), segments: regularSegments, transition: isFirstTime ? .immediate : ContainedViewLayoutTransition.animated(duration: 0.25, curve: .easeInOut)) + let viewStatsTextLayout = self.viewStatsCountText.update(size: CGSize(width: availableSize.width, height: size.height), segments: regularSegments, reducedLetterSpacing: true, transition: isFirstTime ? .immediate : ContainedViewLayoutTransition.animated(duration: 0.25, curve: .easeInOut)) if self.viewStatsCountText.superview == nil { self.viewStatsCountText.isUserInteractionEnabled = false self.externalContainerView.addSubview(self.viewStatsCountText) @@ -602,6 +602,7 @@ public final class StoryFooterPanelComponent: Component { segments: [ .number(reactionCount, NSAttributedString(string: "\(reactionCount)", font: Font.with(size: 15.0, traits: .monospacedNumbers), textColor: .white)) ], + reducedLetterSpacing: true, transition: (isFirstTime || reactionsTransition.animation.isImmediate) ? .immediate : ContainedViewLayoutTransition.animated(duration: 0.25, curve: .easeInOut) ) reactionsTextSize = reactionStatsLayout.size From 3e0d9fd30c1fcda7bbf582c341daff515c3b0f13 Mon Sep 17 00:00:00 2001 From: Ali <> Date: Wed, 27 Sep 2023 23:40:07 +0400 Subject: [PATCH 5/6] [WIP] Settings experiment --- Telegram/BUILD | 19 ++- build-system/Make/Make.py | 13 ++ build-system/Make/ProjectGeneration.py | 141 +----------------- .../SyncCore/SyncCore_LoggingSettings.swift | 2 +- 4 files changed, 33 insertions(+), 142 deletions(-) diff --git a/Telegram/BUILD b/Telegram/BUILD index 027ec3a72c..bd8e5cbd95 100644 --- a/Telegram/BUILD +++ b/Telegram/BUILD @@ -74,6 +74,12 @@ bool_flag( visibility = ["//visibility:public"], ) +bool_flag( + name = "projectIncludeRelease", + build_setting_default = False, + visibility = ["//visibility:public"], +) + config_setting( name = "disableExtensionsSetting", flag_values = { @@ -88,6 +94,13 @@ config_setting( }, ) +config_setting( + name = "projectIncludeReleaseSetting", + flag_values = { + ":projectIncludeRelease": "True", + }, +) + bool_flag( name = "disableStripping", build_setting_default = False, @@ -2015,9 +2028,9 @@ xcodeproj( "Debug": { "//command_line_option:compilation_mode": "dbg", }, - "Release": { - "//command_line_option:compilation_mode": "opt", - }, + #"Release": { + # "//command_line_option:compilation_mode": "opt", + #}, }, default_xcode_configuration = "Debug" diff --git a/build-system/Make/Make.py b/build-system/Make/Make.py index 0e05a5e33c..3899cdb30f 100644 --- a/build-system/Make/Make.py +++ b/build-system/Make/Make.py @@ -546,6 +546,7 @@ def generate_project(bazel, arguments): disable_extensions = False disable_provisioning_profiles = False + project_include_release = False generate_dsym = False target_name = "Telegram" @@ -553,6 +554,8 @@ def generate_project(bazel, arguments): disable_extensions = arguments.disableExtensions if arguments.disableProvisioningProfiles is not None: disable_provisioning_profiles = arguments.disableProvisioningProfiles + if arguments.projectIncludeRelease is not None: + project_include_release = arguments.projectIncludeRelease if arguments.xcodeManagedCodesigning is not None and arguments.xcodeManagedCodesigning == True: disable_extensions = True if arguments.generateDsym is not None: @@ -566,6 +569,7 @@ def generate_project(bazel, arguments): build_environment=bazel_command_line.build_environment, disable_extensions=disable_extensions, disable_provisioning_profiles=disable_provisioning_profiles, + include_release=project_include_release, generate_dsym=generate_dsym, configuration_path=bazel_command_line.configuration_path, bazel_app_arguments=bazel_command_line.get_project_generation_arguments(), @@ -839,6 +843,15 @@ if __name__ == '__main__': ''' ) + generateProjectParser.add_argument( + '--projectIncludeRelease', + action='store_true', + default=False, + help=''' + Generate the Xcode project with Debug and Release configurations. + ''' + ) + generateProjectParser.add_argument( '--generateDsym', action='store_true', diff --git a/build-system/Make/ProjectGeneration.py b/build-system/Make/ProjectGeneration.py index 00d15eb602..37e2ca22bc 100644 --- a/build-system/Make/ProjectGeneration.py +++ b/build-system/Make/ProjectGeneration.py @@ -9,7 +9,7 @@ def remove_directory(path): if os.path.isdir(path): shutil.rmtree(path) -def generate_xcodeproj(build_environment: BuildEnvironment, disable_extensions, disable_provisioning_profiles, generate_dsym, configuration_path, bazel_app_arguments, target_name): +def generate_xcodeproj(build_environment: BuildEnvironment, disable_extensions, disable_provisioning_profiles, include_release, generate_dsym, configuration_path, bazel_app_arguments, target_name): if '/' in target_name: app_target_spec = target_name.split('/')[0] + '/' + target_name.split('/')[1] + ':' + target_name.split('/')[1] app_target = target_name @@ -49,140 +49,5 @@ def generate_xcodeproj(build_environment: BuildEnvironment, disable_extensions, call_executable(['open', xcodeproj_path]) -def generate_tulsi(build_environment: BuildEnvironment, disable_extensions, disable_provisioning_profiles, generate_dsym, configuration_path, bazel_app_arguments, target_name): - project_path = os.path.join(build_environment.base_path, 'build-input/gen/project') - - if '/' in target_name: - app_target_spec = target_name.split('/')[0] + '/' + target_name.split('/')[1] + ':' + target_name.split('/')[1] - app_target = target_name - app_target_clean = app_target.replace('/', '_') - else: - app_target_spec = '{target}:{target}'.format(target=target_name) - app_target = target_name - app_target_clean = app_target.replace('/', '_') - - os.makedirs(project_path, exist_ok=True) - remove_directory('{}/Tulsi.app'.format(project_path)) - remove_directory('{project}/{target}.tulsiproj'.format(project=project_path, target=app_target_clean)) - - tulsi_path = os.path.join(project_path, 'Tulsi.app/Contents/MacOS/Tulsi') - - tulsi_build_bazel_path = build_environment.bazel_path - - current_dir = os.getcwd() - os.chdir(os.path.join(build_environment.base_path, 'build-system/tulsi')) - - tulsi_build_command = [] - tulsi_build_command += [tulsi_build_bazel_path] - tulsi_build_command += ['build', '//:tulsi'] - if is_apple_silicon(): - tulsi_build_command += ['--macos_cpus=arm64'] - tulsi_build_command += ['--xcode_version={}'.format(build_environment.xcode_version)] - tulsi_build_command += ['--use_top_level_targets_for_symlinks'] - tulsi_build_command += ['--verbose_failures'] - tulsi_build_command += ['--swiftcopt=-whole-module-optimization'] - - call_executable(tulsi_build_command) - - os.chdir(current_dir) - - bazel_wrapper_path = os.path.abspath('build-input/gen/project/bazel') - - bazel_wrapper_arguments = [] - bazel_wrapper_arguments += ['--override_repository=build_configuration={}'.format(configuration_path)] - - with open(bazel_wrapper_path, 'wb') as bazel_wrapper: - bazel_wrapper.write('''#!/bin/sh -{bazel} "$@" {arguments} -'''.format( - bazel=build_environment.bazel_path, - arguments=' '.join(bazel_wrapper_arguments) - ).encode('utf-8')) - - call_executable(['chmod', '+x', bazel_wrapper_path]) - - call_executable([ - 'unzip', '-oq', - 'build-system/tulsi/bazel-bin/tulsi.zip', - '-d', project_path - ]) - - user_defaults_path = os.path.expanduser('~/Library/Preferences/com.google.Tulsi.plist') - if os.path.isfile(user_defaults_path): - os.unlink(user_defaults_path) - - with open(user_defaults_path, 'wb') as user_defaults: - user_defaults.write(''' - - - - - defaultBazelURL - {} - - -'''.format(bazel_wrapper_path).encode('utf-8')) - - bazel_build_arguments = [] - bazel_build_arguments += ['--override_repository=build_configuration={}'.format(configuration_path)] - if disable_extensions: - bazel_build_arguments += ['--//{}:disableExtensions'.format(app_target)] - if disable_provisioning_profiles: - bazel_build_arguments += ['--//{}:disableProvisioningProfiles'.format(app_target)] - if generate_dsym: - bazel_build_arguments += ['--apple_generate_dsym'] - bazel_build_arguments += ['--//{}:disableStripping'.format('Telegram')] - bazel_build_arguments += ['--strip=never'] - - call_executable([ - tulsi_path, - '--', - '--verbose', - '--create-tulsiproj', app_target_clean, - '--workspaceroot', './', - '--bazel', bazel_wrapper_path, - '--outputfolder', project_path, - '--target', '{target_spec}'.format(target_spec=app_target_spec), - '--build-options', ' '.join(bazel_build_arguments) - ]) - - additional_arguments = [] - additional_arguments += ['--override_repository=build_configuration={}'.format(configuration_path)] - additional_arguments += bazel_app_arguments - if disable_extensions: - additional_arguments += ['--//{}:disableExtensions'.format(app_target)] - - additional_arguments_string = ' '.join(additional_arguments) - - tulsi_config_path = 'build-input/gen/project/{target}.tulsiproj/Configs/{target}.tulsigen'.format(target=app_target_clean) - with open(tulsi_config_path, 'rb') as tulsi_config: - tulsi_config_json = json.load(tulsi_config) - for category in ['BazelBuildOptionsDebug', 'BazelBuildOptionsRelease']: - tulsi_config_json['optionSet'][category]['p'] += ' {}'.format(additional_arguments_string) - tulsi_config_json['sourceFilters'] = [ - '{}/...'.format(app_target), - 'submodules/...', - 'third-party/...' - ] - with open(tulsi_config_path, 'wb') as tulsi_config: - tulsi_config.write(json.dumps(tulsi_config_json, indent=2).encode('utf-8')) - - call_executable([ - tulsi_path, - '--', - '--verbose', - '--genconfig', '{project}/{target}.tulsiproj:{target}'.format(project=project_path, target=app_target_clean), - '--bazel', bazel_wrapper_path, - '--outputfolder', project_path, - '--no-open-xcode' - ]) - - xcodeproj_path = '{project}/{target}.xcodeproj'.format(project=project_path, target=app_target_clean) - - call_executable(['open', xcodeproj_path]) - - -def generate(build_environment: BuildEnvironment, disable_extensions, disable_provisioning_profiles, generate_dsym, configuration_path, bazel_app_arguments, target_name): - generate_xcodeproj(build_environment, disable_extensions, disable_provisioning_profiles, generate_dsym, configuration_path, bazel_app_arguments, target_name) - #generate_tulsi(build_environment, disable_extensions, disable_provisioning_profiles, generate_dsym, configuration_path, bazel_app_arguments, target_name) - +def generate(build_environment: BuildEnvironment, disable_extensions, disable_provisioning_profiles, include_release, generate_dsym, configuration_path, bazel_app_arguments, target_name): + generate_xcodeproj(build_environment, disable_extensions, disable_provisioning_profiles, include_release, generate_dsym, configuration_path, bazel_app_arguments, target_name) diff --git a/submodules/TelegramCore/Sources/SyncCore/SyncCore_LoggingSettings.swift b/submodules/TelegramCore/Sources/SyncCore/SyncCore_LoggingSettings.swift index 7b26a6324c..2516e3140a 100644 --- a/submodules/TelegramCore/Sources/SyncCore/SyncCore_LoggingSettings.swift +++ b/submodules/TelegramCore/Sources/SyncCore/SyncCore_LoggingSettings.swift @@ -6,7 +6,7 @@ public final class LoggingSettings: Codable { public let redactSensitiveData: Bool #if DEBUG - public static var defaultSettings = LoggingSettings(logToFile: true, logToConsole: true, redactSensitiveData: true) + public static var defaultSettings = LoggingSettings(logToFile: false, logToConsole: false, redactSensitiveData: true) #else public static var defaultSettings = LoggingSettings(logToFile: false, logToConsole: false, redactSensitiveData: true) #endif From d16de905c5257614289c64a077152220869bec5d Mon Sep 17 00:00:00 2001 From: Ali <> Date: Thu, 28 Sep 2023 17:20:56 +0400 Subject: [PATCH 6/6] Add more logs --- Telegram/NotificationService/Sources/NotificationService.swift | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Telegram/NotificationService/Sources/NotificationService.swift b/Telegram/NotificationService/Sources/NotificationService.swift index a3020311f1..2f1c4c85a7 100644 --- a/Telegram/NotificationService/Sources/NotificationService.swift +++ b/Telegram/NotificationService/Sources/NotificationService.swift @@ -731,6 +731,8 @@ private final class NotificationServiceHandler { }) semaphore.wait() + Logger.shared.log("NotificationService \(episode)", "Logging settings: (logToFile: \(loggingSettings.logToFile))") + Logger.shared.logToFile = loggingSettings.logToFile Logger.shared.logToConsole = loggingSettings.logToConsole Logger.shared.redactSensitiveData = loggingSettings.redactSensitiveData