Delay between viewWillAppear and viewDidLoad after entering foreground











up vote
0
down vote

favorite












A delay of 2 seconds occurs between viewWillAppear and viewDidAppear only in one screen when application comes back from the background. Normally, there isn't a delay in this screen when the app is active. In debugging, it seems both viewWillAppear and viewDidAppear are completed in a few milliseconds.



In the screen, there is a horizontal scrollview of 9 pages and in each one, there is a tableview. I realized that the delay disappears when the below code of tableviews' reload is removed from viewWillAppear.



for i in 0 ..< self.levelTables.count {
self.levelTables[i].tableView.reloadData()
}


I don't understand why this causes delay. When the app is active, there is no delay. It only appears when the application comes from the background. What's the difference? If it takes time, why is this delay not occurring always?



Any ideas?










share|improve this question






















  • How many tables do you have? Also, you should try using Instruments for profiling, it should help you find which function is causing the freeze.
    – Guy Kogus
    Nov 10 at 19:25










  • I have 9 tables and I realized that reloading causes freeze. But why only when coming back from the background? Also, I tried putting reloading into DispatchGroup.main.async but it didn’t work. :(
    – D3sT
    Nov 10 at 19:34












  • The reloading itself shouldn't take too long, assuming your views aren't doing anything that they shouldn't. Find what's blocking your main thread using Instruments. If you need to learn how start here: raywenderlich.com/…
    – Guy Kogus
    Nov 10 at 19:36










  • Thank you very much. I've checked but I didn't get useful info. It points "main" with a self weight of 1.18s. When double click, it refers to "class AppDelegate: UIResponder, UIApplicationDelegate" line.
    – D3sT
    Nov 10 at 20:40















up vote
0
down vote

favorite












A delay of 2 seconds occurs between viewWillAppear and viewDidAppear only in one screen when application comes back from the background. Normally, there isn't a delay in this screen when the app is active. In debugging, it seems both viewWillAppear and viewDidAppear are completed in a few milliseconds.



In the screen, there is a horizontal scrollview of 9 pages and in each one, there is a tableview. I realized that the delay disappears when the below code of tableviews' reload is removed from viewWillAppear.



for i in 0 ..< self.levelTables.count {
self.levelTables[i].tableView.reloadData()
}


I don't understand why this causes delay. When the app is active, there is no delay. It only appears when the application comes from the background. What's the difference? If it takes time, why is this delay not occurring always?



Any ideas?










share|improve this question






















  • How many tables do you have? Also, you should try using Instruments for profiling, it should help you find which function is causing the freeze.
    – Guy Kogus
    Nov 10 at 19:25










  • I have 9 tables and I realized that reloading causes freeze. But why only when coming back from the background? Also, I tried putting reloading into DispatchGroup.main.async but it didn’t work. :(
    – D3sT
    Nov 10 at 19:34












  • The reloading itself shouldn't take too long, assuming your views aren't doing anything that they shouldn't. Find what's blocking your main thread using Instruments. If you need to learn how start here: raywenderlich.com/…
    – Guy Kogus
    Nov 10 at 19:36










  • Thank you very much. I've checked but I didn't get useful info. It points "main" with a self weight of 1.18s. When double click, it refers to "class AppDelegate: UIResponder, UIApplicationDelegate" line.
    – D3sT
    Nov 10 at 20:40













up vote
0
down vote

favorite









up vote
0
down vote

favorite











A delay of 2 seconds occurs between viewWillAppear and viewDidAppear only in one screen when application comes back from the background. Normally, there isn't a delay in this screen when the app is active. In debugging, it seems both viewWillAppear and viewDidAppear are completed in a few milliseconds.



In the screen, there is a horizontal scrollview of 9 pages and in each one, there is a tableview. I realized that the delay disappears when the below code of tableviews' reload is removed from viewWillAppear.



for i in 0 ..< self.levelTables.count {
self.levelTables[i].tableView.reloadData()
}


I don't understand why this causes delay. When the app is active, there is no delay. It only appears when the application comes from the background. What's the difference? If it takes time, why is this delay not occurring always?



Any ideas?










share|improve this question













A delay of 2 seconds occurs between viewWillAppear and viewDidAppear only in one screen when application comes back from the background. Normally, there isn't a delay in this screen when the app is active. In debugging, it seems both viewWillAppear and viewDidAppear are completed in a few milliseconds.



In the screen, there is a horizontal scrollview of 9 pages and in each one, there is a tableview. I realized that the delay disappears when the below code of tableviews' reload is removed from viewWillAppear.



for i in 0 ..< self.levelTables.count {
self.levelTables[i].tableView.reloadData()
}


I don't understand why this causes delay. When the app is active, there is no delay. It only appears when the application comes from the background. What's the difference? If it takes time, why is this delay not occurring always?



Any ideas?







swift tableview delay viewwillappear viewdidappear






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 10 at 18:21









D3sT

67




67












  • How many tables do you have? Also, you should try using Instruments for profiling, it should help you find which function is causing the freeze.
    – Guy Kogus
    Nov 10 at 19:25










  • I have 9 tables and I realized that reloading causes freeze. But why only when coming back from the background? Also, I tried putting reloading into DispatchGroup.main.async but it didn’t work. :(
    – D3sT
    Nov 10 at 19:34












  • The reloading itself shouldn't take too long, assuming your views aren't doing anything that they shouldn't. Find what's blocking your main thread using Instruments. If you need to learn how start here: raywenderlich.com/…
    – Guy Kogus
    Nov 10 at 19:36










  • Thank you very much. I've checked but I didn't get useful info. It points "main" with a self weight of 1.18s. When double click, it refers to "class AppDelegate: UIResponder, UIApplicationDelegate" line.
    – D3sT
    Nov 10 at 20:40


















  • How many tables do you have? Also, you should try using Instruments for profiling, it should help you find which function is causing the freeze.
    – Guy Kogus
    Nov 10 at 19:25










  • I have 9 tables and I realized that reloading causes freeze. But why only when coming back from the background? Also, I tried putting reloading into DispatchGroup.main.async but it didn’t work. :(
    – D3sT
    Nov 10 at 19:34












  • The reloading itself shouldn't take too long, assuming your views aren't doing anything that they shouldn't. Find what's blocking your main thread using Instruments. If you need to learn how start here: raywenderlich.com/…
    – Guy Kogus
    Nov 10 at 19:36










  • Thank you very much. I've checked but I didn't get useful info. It points "main" with a self weight of 1.18s. When double click, it refers to "class AppDelegate: UIResponder, UIApplicationDelegate" line.
    – D3sT
    Nov 10 at 20:40
















How many tables do you have? Also, you should try using Instruments for profiling, it should help you find which function is causing the freeze.
– Guy Kogus
Nov 10 at 19:25




How many tables do you have? Also, you should try using Instruments for profiling, it should help you find which function is causing the freeze.
– Guy Kogus
Nov 10 at 19:25












I have 9 tables and I realized that reloading causes freeze. But why only when coming back from the background? Also, I tried putting reloading into DispatchGroup.main.async but it didn’t work. :(
– D3sT
Nov 10 at 19:34






I have 9 tables and I realized that reloading causes freeze. But why only when coming back from the background? Also, I tried putting reloading into DispatchGroup.main.async but it didn’t work. :(
– D3sT
Nov 10 at 19:34














The reloading itself shouldn't take too long, assuming your views aren't doing anything that they shouldn't. Find what's blocking your main thread using Instruments. If you need to learn how start here: raywenderlich.com/…
– Guy Kogus
Nov 10 at 19:36




The reloading itself shouldn't take too long, assuming your views aren't doing anything that they shouldn't. Find what's blocking your main thread using Instruments. If you need to learn how start here: raywenderlich.com/…
– Guy Kogus
Nov 10 at 19:36












Thank you very much. I've checked but I didn't get useful info. It points "main" with a self weight of 1.18s. When double click, it refers to "class AppDelegate: UIResponder, UIApplicationDelegate" line.
– D3sT
Nov 10 at 20:40




Thank you very much. I've checked but I didn't get useful info. It points "main" with a self weight of 1.18s. When double click, it refers to "class AppDelegate: UIResponder, UIApplicationDelegate" line.
– D3sT
Nov 10 at 20:40

















active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














 

draft saved


draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53242054%2fdelay-between-viewwillappear-and-viewdidload-after-entering-foreground%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes
















 

draft saved


draft discarded



















































 


draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53242054%2fdelay-between-viewwillappear-and-viewdidload-after-entering-foreground%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Florida Star v. B. J. F.

Danny Elfman

Lugert, Oklahoma