Skip to content

Commit

Permalink
6.0.3 (#987)
Browse files Browse the repository at this point in the history
Features:
- Improve crash handling and logging

Fixes:
- Bring back self-chat contact
- Fix crash when making call on iPad
- Fix race condition in iq handler timeout
  • Loading branch information
tmolitor-stud-tu authored Dec 31, 2023
2 parents d07923e + dabcd0d commit 6fb449a
Show file tree
Hide file tree
Showing 31 changed files with 274 additions and 178 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/beta.build-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,6 @@ jobs:
run: ./scripts/build.sh
- name: validate ios app
run: xcrun altool --validate-app --file ./Monal/build/ipa/Monal.ipa --type ios --asc-provider S8D843U34Y -u "$(cat /Users/ci/apple_connect_upload_mail.txt)" -p "$(cat /Users/ci/apple_connect_upload_secret.txt)"
- name: Update translations
run: |
chmod +x ./scripts/updateLocalization.sh
chmod +x ./scripts/xliff_extractor.py
./scripts/updateLocalization.sh BUILDSERVER
- name: push tag to beta repo
run: |
buildNumber=$(git tag --sort="v:refname" |grep "Build_iOS" | tail -n1 | sed 's/Build_iOS_//g')
Expand All @@ -75,6 +70,11 @@ jobs:
run: ./scripts/uploadNonAlpha.sh beta
- name: Publish catalyst to appstore connect
run: xcrun altool --upload-app --file ./Monal/build/app/Monal.pkg --type macos --asc-provider S8D843U34Y -u "$(cat /Users/ci/apple_connect_upload_mail.txt)" -p "$(cat /Users/ci/apple_connect_upload_secret.txt)" --primary-bundle-id org.monal-im.prod.catalyst.monal
- name: Update translations
run: |
chmod +x ./scripts/updateLocalization.sh
chmod +x ./scripts/xliff_extractor.py
./scripts/updateLocalization.sh BUILDSERVER
- uses: actions/upload-artifact@v3
with:
name: monal-catalyst
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/develop-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ jobs:
if [[ -e "/Users/ci/secrets.monal_alpha" ]]; then
echo "#import \"/Users/ci/secrets.monal_alpha\"" > Monal/Classes/secrets.h
fi
- name: Write git hash include
run: |
echo "Current commit hash: $(git show-ref --hash --abbrev refs/heads/develop)"
echo "#define ALPHA_COMMIT_HASH \"$(git show-ref --hash --abbrev refs/heads/develop)\"" > Monal/Classes/commitHash.h
- name: Make our build scripts executable
run: chmod +x ./scripts/build.sh
- name: Run build
Expand Down
2 changes: 1 addition & 1 deletion Monal/Classes/AddContactMenu.swift
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ struct AddContactMenu: View {
}
.pickerStyle(.menu)
}
TextField("Contact or Group/Channel Jid", text: $toAdd)
TextField(NSLocalizedString("Contact or Group/Channel Jid", comment: "placeholder when adding jid"), text: $toAdd)
//ios15: .textInputAutocapitalization(.never)
.autocapitalization(.none)
.autocorrectionDisabled()
Expand Down
2 changes: 1 addition & 1 deletion Monal/Classes/ContactDetails.swift
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ struct ContactDetails: View {
#endif

if(!contact.isGroup && !contact.isSelfChat) {
TextField("Rename Contact", text: $contact.nickNameView)
TextField(NSLocalizedString("Rename Contact", comment: "placeholder text in contact details"), text: $contact.nickNameView)
.textFieldStyle(RoundedBorderTextFieldStyle())
.addClearButton(text:$contact.nickNameView)
}
Expand Down
2 changes: 1 addition & 1 deletion Monal/Classes/ContactPicker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ struct ContactPicker: View {
} else {
List {
Section {
TextField("Search contacts", text: $searchFieldInput)
TextField(NSLocalizedString("Search contacts", comment: "placeholder in contact picker"), text: $searchFieldInput)
}
ForEach(Array(contacts.enumerated()), id: \.element) { idx, contact in
if matchesSearch(contact: contact) {
Expand Down
2 changes: 1 addition & 1 deletion Monal/Classes/ContactsViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ -(void) configureContactRequestsImage
hasNotification:[[DataLayer sharedInstance] allContactRequests].count > 0
withTapHandler:requestsTapRecoginzer];
[self.navigationItem.rightBarButtonItems[1] setIsAccessibilityElement:YES];
[self.navigationItem.rightBarButtonItems[1] setAccessibilityLabel:@"Open contacts list"];
[self.navigationItem.rightBarButtonItems[1] setAccessibilityLabel:NSLocalizedString(@"Open list of pending contact requests", @"")];

}

Expand Down
2 changes: 1 addition & 1 deletion Monal/Classes/CreateGroupMenu.swift
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ struct CreateGroupMenu: View {
}
.pickerStyle(.menu)
}
TextField("Group Name (optional)", text: $groupName)
TextField(NSLocalizedString("Group Name (optional)", comment: "placeholder when creating new group"), text: $groupName)
.autocorrectionDisabled()
.autocapitalization(.none)
.addClearButton(text:$groupName)
Expand Down
16 changes: 12 additions & 4 deletions Monal/Classes/DataLayer.m
Original file line number Diff line number Diff line change
Expand Up @@ -255,8 +255,7 @@ -(BOOL) updateAccounWithDictionary:(NSDictionary*) dictionary
[dictionary objectForKey:kAccountID],
];
BOOL retval = [self.db executeNonQuery:query andArguments:params];
//add self-chat
[self addContact:[NSString stringWithFormat:@"%@@%@", dictionary[kUsername], dictionary[kDomain]] forAccount:dictionary[kAccountID] nickname:nil];
[self addSelfChatForAccount:dictionary[kAccountID]];
return retval;
}];
}
Expand All @@ -283,8 +282,7 @@ -(NSNumber*) addAccountWithDictionary:(NSDictionary*) dictionary
if(result == YES) {
NSNumber* accountID = [self.db lastInsertId];
DDLogInfo(@"Added account %@ to account table with accountNo %@", [dictionary objectForKey:kUsername], accountID);
//add self-chat
[self addContact:[NSString stringWithFormat:@"%@@%@", dictionary[kUsername], dictionary[kDomain]] forAccount:accountID nickname:nil];
[self addSelfChatForAccount:accountID];
return accountID;
} else {
return (NSNumber*)nil;
Expand Down Expand Up @@ -374,6 +372,16 @@ -(void) persistState:(NSDictionary*) state forAccount:(NSNumber*) accountNo

#pragma mark contact Commands

-(BOOL) addSelfChatForAccount:(NSNumber*) accountNo
{
BOOL encrypt = NO;
#ifndef DISABLE_OMEMO
encrypt = [[HelperTools defaultsDB] boolForKey:@"OMEMODefaultOn"];
#endif// DISABLE_OMEMO
NSDictionary* accountDetails = [self detailsForAccount:accountNo];
return [self.db executeNonQuery:@"INSERT INTO buddylist ('account_id', 'buddy_name', 'full_name', 'nick_name', 'muc', 'muc_nick', 'encrypt') VALUES(?, ?, ?, ?, ?, ?, ?) ON CONFLICT(account_id, buddy_name) DO UPDATE SET subscription='both';" andArguments:@[accountNo, [NSString stringWithFormat:@"%@@%@", accountDetails[kUsername], accountDetails[kDomain]], @"", @"", @0, @"", @(encrypt)]];
}

-(BOOL) addContact:(NSString*) contact forAccount:(NSNumber*) accountNo nickname:(NSString*) nickName
{
if(accountNo == nil || !contact)
Expand Down
9 changes: 7 additions & 2 deletions Monal/Classes/HelperTools.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ NS_ASSUME_NONNULL_BEGIN
@class UIView;
@class UITapGestureRecognizer;

typedef NS_ENUM(NSUInteger, MLVersionType) {
MLVersionTypeIQ,
MLVersionTypeLog,
};

void logException(NSException* exception);
void swizzle(Class c, SEL orig, SEL new);

Expand All @@ -49,7 +54,7 @@ void swizzle(Class c, SEL orig, SEL new);
+(void) postError:(NSString*) description withNode:(XMPPStanza* _Nullable) node andAccount:(xmpp*) account andIsSevere:(BOOL) isSevere andDisableAccount:(BOOL) disableAccount;
+(void) postError:(NSString*) description withNode:(XMPPStanza* _Nullable) node andAccount:(xmpp*) account andIsSevere:(BOOL) isSevere;
+(NSString*) extractXMPPError:(XMPPStanza*) stanza withDescription:(NSString* _Nullable) description;
+(void) showErrorOnAlpha:(NSString*) description withNode:(XMPPStanza* _Nullable) node andAccount:(xmpp*) account andFile:(char*) file andLine:(int) line andFunc:(char*) func;
+(void) showErrorOnAlpha:(NSString*) description withNode:(XMPPStanza* _Nullable) node andAccount:(xmpp* _Nullable) account andFile:(char*) file andLine:(int) line andFunc:(char*) func;

+(NSDictionary<NSString*, NSString*>*) getInvalidPushServers;
+(NSString*) getSelectedPushServerBasedOnLocale;
Expand Down Expand Up @@ -139,7 +144,7 @@ void swizzle(Class c, SEL orig, SEL new);
//don't use these four directly, but via createTimer() makro
+(monal_void_block_t) startQueuedTimer:(double) timeout withHandler:(monal_void_block_t) handler andCancelHandler:(monal_void_block_t _Nullable) cancelHandler andFile:(char*) file andLine:(int) line andFunc:(char*) func onQueue:(dispatch_queue_t _Nullable) queue;

+(NSString*) appBuildVersionInfo;
+(NSString*) appBuildVersionInfoFor:(MLVersionType) type;

+(BOOL) deviceUsesSplitView;

Expand Down
55 changes: 36 additions & 19 deletions Monal/Classes/HelperTools.m
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
#import "OmemoState.h"
#import "MLUDPLogger.h"
#import "MLStreamRedirect.h"
#import "commithash.h"

@import UserNotifications;
@import CoreImage;
Expand All @@ -71,6 +72,7 @@ @interface KSCrash()
static char _origLogfilePath[1024] = "";
static char _logfilePath[1024] = "";
static NSObject* _isAppExtensionLock = nil;
static NSMutableDictionary* _versionInfoCache;
static MLStreamRedirect* _stdoutRedirector = nil;
static MLStreamRedirect* _stderrRedirector = nil;
static volatile void (*_oldExceptionHandler)(NSException*) = NULL;
Expand Down Expand Up @@ -172,8 +174,10 @@ static void addFilePathWithSize(const KSCrashReportWriter* writer, char* name, c
static void crash_callback(const KSCrashReportWriter* writer)
{
int copyRetval = asyncSafeCopyFile(_origLogfilePath, _logfilePath);
int errnoCopy = errno;
writer->addStringElement(writer, "logfileCopied", "YES");
writer->addIntegerElement(writer, "logfileCopyResult", copyRetval);
writer->addIntegerElement(writer, "logfileCopyErrno", errnoCopy);
addFilePathWithSize(writer, "logfileCopy", _logfilePath);
//this comes last to make sure we see size differences if the logfile got written during crash data collection (could be other processes)
addFilePathWithSize(writer, "currentLogfile", _origLogfilePath);
Expand Down Expand Up @@ -229,6 +233,7 @@ @implementation HelperTools
+(void) initialize
{
_isAppExtensionLock = [NSObject new];
_versionInfoCache = [NSMutableDictionary new];

u_int32_t i = arc4random();
_processID = [self hexadecimalString:[NSData dataWithBytes:&i length:sizeof(i)]];
Expand Down Expand Up @@ -280,7 +285,6 @@ +(void) __attribute__((noreturn)) handleRustPanicWithText:(NSString*) text andBa
_crash_info.message = abort_msg.UTF8String;
_crash_info.signature = abort_msg.UTF8String; //use signature for apple crash reporter which does not handle message field
_crash_info.backtrace = backtrace.UTF8String;
_crash_info.message2 = backtrace.UTF8String; //use message2 for kscrash which does not handle backtrace field

//log error and flush all logs
[DDLog flushLog];
Expand Down Expand Up @@ -314,18 +318,30 @@ +(void) postError:(NSString*) description withNode:(XMPPStanza* _Nullable) node
[[MLNotificationQueue currentQueue] postNotificationName:kXMPPError object:account userInfo:@{@"message": message, @"isSevere":@(isSevere)}];
}

+(void) showErrorOnAlpha:(NSString*) description withNode:(XMPPStanza* _Nullable) node andAccount:(xmpp*) account andFile:(char*) file andLine:(int) line andFunc:(char*) func
+(void) showErrorOnAlpha:(NSString*) description withNode:(XMPPStanza* _Nullable) node andAccount:(xmpp* _Nullable) account andFile:(char*) file andLine:(int) line andFunc:(char*) func
{
NSString* fileStr = [NSString stringWithFormat:@"%s", file];
NSArray* filePathComponents = [fileStr pathComponents];
if([filePathComponents count]>1)
fileStr = [NSString stringWithFormat:@"%@/%@", filePathComponents[[filePathComponents count]-2], filePathComponents[[filePathComponents count]-1]];
NSString* message = description;
if(node)
message = [HelperTools extractXMPPError:node withDescription:description];
message = [self extractXMPPError:node withDescription:description];
#ifdef IS_ALPHA
DDLogError(@"Notifying alpha user about error at %@:%d in %s: %@", fileStr, line, func, message);
[[MLNotificationQueue currentQueue] postNotificationName:kXMPPError object:account userInfo:@{@"message": message, @"isSevere":@YES}];
if(account != nil)
[[MLNotificationQueue currentQueue] postNotificationName:kXMPPError object:account userInfo:@{@"message": message, @"isSevere":@YES}];
else
{
UNMutableNotificationContent* content = [UNMutableNotificationContent new];
content.title = @"Global Error";
content.body = message;
content.sound = [UNNotificationSound defaultSound];
UNNotificationRequest* request = [UNNotificationRequest requestWithIdentifier:[[NSUUID UUID] UUIDString] content:content trigger:nil];
NSError* error = [self postUserNotificationRequest:request];
if(error)
DDLogError(@"Error posting global alpha xmppError notification: %@", error);
}
#else
DDLogWarn(@"Ignoring alpha-only error at %@:%d in %s: %@", fileStr, line, func, message);
#endif
Expand Down Expand Up @@ -1643,11 +1659,7 @@ +(void) configureLogging
DDLogDebug(@"File attributes: %@", attrs);

//log version info as early as possible
NSDictionary* infoDict = [[NSBundle mainBundle] infoDictionary];
NSString* version = [infoDict objectForKey:@"CFBundleShortVersionString"];
NSString* buildDate = [NSString stringWithUTF8String:__DATE__];
NSString* buildTime = [NSString stringWithUTF8String:__TIME__];
DDLogInfo(@"Starting: Version %@ (%@ %@ UTC, %@) on iOS/macOS %@", version, buildDate, buildTime, [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleIdentifier"], [UIDevice currentDevice].systemVersion);
DDLogInfo(@"Starting: %@", [self appBuildVersionInfoFor:MLVersionTypeLog]);
//[SCRAM SSDPXepOutput];
[DDLog flushLog];

Expand Down Expand Up @@ -1730,15 +1742,11 @@ +(void) installCrashHandler
handler.demangleLanguages = KSCrashDemangleLanguageAll;
handler.maxReportCount = 4;
handler.deadlockWatchdogInterval = 0; // no main thread watchdog
NSDictionary* infoDict = [[NSBundle mainBundle] infoDictionary];
NSString* version = [infoDict objectForKey:@"CFBundleShortVersionString"];
NSString* buildDate = [NSString stringWithUTF8String:__DATE__];
NSString* buildTime = [NSString stringWithUTF8String:__TIME__];
handler.userInfo = @{
@"isAppex": @([self isAppExtension]),
@"processName": [[[NSBundle mainBundle] executablePath] lastPathComponent],
@"bundleName": nilWrapper([[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleName"]),
@"appVersion": [NSString stringWithFormat:NSLocalizedString(@"Version %@ (%@ %@ UTC)", @""), version, buildDate, buildTime],
@"appVersion": [self appBuildVersionInfoFor:MLVersionTypeLog],
};
//we can not use [KSCrash install] because this uses the bundle names to store our crash reports which are different
//in appex and mainapp use the lowlevel C api with dummy bundle name "UnifiedReport" instead
Expand Down Expand Up @@ -2068,15 +2076,24 @@ +(NSString*) encodeRandomResource
return resource;
}

+(NSString*) appBuildVersionInfo
+(NSString*) appBuildVersionInfoFor:(MLVersionType) type
{
NSDictionary* infoDict = [[NSBundle mainBundle] infoDictionary];
@synchronized(_versionInfoCache) {
if(_versionInfoCache[@(type)] != nil)
return _versionInfoCache[@(type)];

#ifdef IS_ALPHA
NSString* versionTxt = [NSString stringWithFormat:@"Alpha %@ (%s: %s UTC)", [infoDict objectForKey:@"CFBundleShortVersionString"], __DATE__, __TIME__];
NSString* rawVersionString = [NSString stringWithFormat:@"Alpha %s (%s %s UTC)", ALPHA_COMMIT_HASH, __DATE__, __TIME__];
#else
NSString* versionTxt = [NSString stringWithFormat:@"%@ (%@)", [infoDict objectForKey:@"CFBundleShortVersionString"], [infoDict objectForKey:@"CFBundleVersion"]];
NSDictionary* infoDict = [[NSBundle mainBundle] infoDictionary];
NSString* rawVersionString = [NSString stringWithFormat:@"%@ (%@)", [infoDict objectForKey:@"CFBundleShortVersionString"], [infoDict objectForKey:@"CFBundleVersion"]];
#endif
return versionTxt;
if(type == MLVersionTypeIQ)
return _versionInfoCache[@(type)] = rawVersionString;
else if(type == MLVersionTypeLog)
return _versionInfoCache[@(type)] = [NSString stringWithFormat:@"Version %@, %@ on iOS/macOS %@", rawVersionString, [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleIdentifier"], [UIDevice currentDevice].systemVersion];
unreachable(@"unknown version type!");
}
}

+(NSNumber*) currentTimestampInSeconds
Expand Down
1 change: 1 addition & 0 deletions Monal/Classes/MLContact.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ FOUNDATION_EXPORT NSString* const kAskSubscribe;
@property (nonatomic, readonly) BOOL isSubscribedFrom;
@property (nonatomic, readonly) BOOL isSubscribedBoth;
@property (nonatomic, readonly) BOOL hasIncomingContactRequest;
@property (nonatomic, readonly) BOOL hasOutgoingContactRequest;

-(BOOL) isEqualToContact:(MLContact*) contact;
-(BOOL) isEqualToMessage:(MLMessage*) message;
Expand Down
7 changes: 6 additions & 1 deletion Monal/Classes/MLContact.m
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,11 @@ -(BOOL) hasIncomingContactRequest
return self.isGroup == NO && [[DataLayer sharedInstance] hasContactRequestForContact:self];
}

-(BOOL) hasOutgoingContactRequest
{
return self.isGroup == NO && [self.ask isEqualToString:kAskSubscribe];
}

// this will cache the unread count on first access
-(NSInteger) unreadCount
{
Expand Down Expand Up @@ -676,7 +681,7 @@ -(NSString*) id

-(NSString*) description
{
return [NSString stringWithFormat:@"%@: %@ (%@) %@%@", self.accountId, self.contactJid, self.isGroup ? self.mucType : @"1:1", self.isInRoster ? @"inRoster" : @"not(inRoster)", self.hasIncomingContactRequest ? @"[incomingContactRequest]" : @""];
return [NSString stringWithFormat:@"%@: %@ (%@) %@%@%@, kSub=%@", self.accountId, self.contactJid, self.isGroup ? self.mucType : @"1:1", self.isInRoster ? @"inRoster" : @"not(inRoster)", self.hasIncomingContactRequest ? @"[incomingContactRequest]" : @"", self.hasOutgoingContactRequest ? @"[outgoingContactRequest]" : @"", self.subscription];
}

+(MLContact*) contactFromDictionary:(NSDictionary*) dic
Expand Down
Loading

0 comments on commit 6fb449a

Please sign in to comment.