Skip to content

Commit 863d8de

Browse files
Fix weird double shutdown bug
While preapring for app freeze, we reset _shutdownPending to NO. That deactivated the failsafe used to ignore idle states on disconnected accounts and triggered a second shutdown. (But since the app suspension was already triggered (the bg task was terminated), the double shutdown got delayed to next app foreground.) The second shutdown tried to flush the log, but the logging queue was already suspended, so the flushing blocked the main thread indefinitely leading to the iOS watchdog killing the app. This was not visible in any logfiles, because of the suspended logging queue, but our new udp logger force send made it visible.
1 parent ddd1108 commit 863d8de

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

Monal/Classes/MonalAppDelegate.m

+5-9
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ @interface MonalAppDelegate()
5959
MLContact* _contactToOpen;
6060
monal_id_block_t _completionToCall;
6161
BOOL _shutdownPending;
62-
BOOL _wasFreezed;
62+
BOOL _wasFrozen;
6363
}
6464
@end
6565

@@ -323,7 +323,7 @@ -(id) init
323323
_wakeupCompletions = [NSMutableDictionary new];
324324
DDLogVerbose(@"Setting _shutdownPending to NO...");
325325
_shutdownPending = NO;
326-
_wasFreezed = NO;
326+
_wasFrozen = NO;
327327

328328
//[self runParserTests];
329329
//[self runSDPTests];
@@ -1134,11 +1134,7 @@ -(void) prepareForFreeze:(NSNotification*) notification
11341134
for(xmpp* account in [MLXMPPManager sharedInstance].connectedXMPP)
11351135
[account freeze];
11361136
[MLProcessLock unlock];
1137-
_wasFreezed = YES;
1138-
@synchronized(self) {
1139-
DDLogVerbose(@"Setting _shutdownPending to NO...");
1140-
_shutdownPending = NO;
1141-
}
1137+
_wasFrozen = YES;
11421138
}
11431139

11441140
-(void) applicationWillEnterForeground:(UIApplication*) application
@@ -1156,14 +1152,14 @@ -(void) applicationWillEnterForeground:(UIApplication*) application
11561152

11571153
//only show loading HUD if we really got freezed before
11581154
MBProgressHUD* loadingHUD;
1159-
if(_wasFreezed)
1155+
if(_wasFrozen)
11601156
{
11611157
loadingHUD = [MBProgressHUD showHUDAddedTo:[self getTopViewController].view animated:YES];
11621158
loadingHUD.label.text = NSLocalizedString(@"Refreshing...", @"");
11631159
loadingHUD.mode = MBProgressHUDModeIndeterminate;
11641160
loadingHUD.removeFromSuperViewOnHide = YES;
11651161

1166-
_wasFreezed = NO;
1162+
_wasFrozen = NO;
11671163
}
11681164

11691165
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{

0 commit comments

Comments
 (0)