From 17b13e9f004081ddec00a3a3b9ac6d4fca554c4d Mon Sep 17 00:00:00 2001 From: Vishesh Handa Date: Fri, 11 Oct 2019 16:00:14 +0200 Subject: [PATCH] ios: Handle expensive operations in a background thread If we handle them in the main thread, then the UI blocks, especially when generating a new SSH key. --- ios/Runner/AppDelegate.m | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ios/Runner/AppDelegate.m b/ios/Runner/AppDelegate.m index b47dfeb6..42e75803 100644 --- a/ios/Runner/AppDelegate.m +++ b/ios/Runner/AppDelegate.m @@ -52,17 +52,17 @@ static FlutterMethodChannel* gitChannel = 0; result(filesDir); } else if ([@"gitClone" isEqualToString:method]) { - dispatch_async(dispatch_get_main_queue(), ^{ + dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ [self handleMethodCallAsync:call result:result]; }); } else if ([@"gitPull" isEqualToString:method]) { - dispatch_async(dispatch_get_main_queue(), ^{ + dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ [self handleMethodCallAsync:call result:result]; }); } else if ([@"gitPush" isEqualToString:method]) { - dispatch_async(dispatch_get_main_queue(), ^{ + dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ [self handleMethodCallAsync:call result:result]; }); } @@ -189,7 +189,7 @@ static FlutterMethodChannel* gitChannel = 0; } } else if ([@"generateSSHKeys" isEqualToString:method]) { - dispatch_async(dispatch_get_main_queue(), ^{ + dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ [self handleMethodCallAsync:call result:result]; }); }