-
-
Notifications
You must be signed in to change notification settings - Fork 52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
check for anr in chatlist #1085
Comments
@dignifiedquire reported that the used sqlite-core-library in combination with the limited number of threads may cause problems: due to async, sql-requests are scheduled over the threads available, the scheduler does not take care much about the calling thread - so it may happen, that a theoretically fast call takes some seconds as it is randomly in the same thread-queue as eg. some longer taking operation that is done before (on android/desktop this is less an issue as there are more threads available (ios has only 7)) the "real" fix could be sth. as using sqlx in core, however, we could mitigate the issue by avoiding calls to core in ui-thread (where possible) and also by taking care not doing lots unneeded core calls (we had that here and there by these "computed properties" where @dignifiedquire is that summary roughly correct? i am not sure if i got it correctly :) |
meanwhile, there is sqlx coming, so we should reconsider that once deltachat/deltachat-core-rust#2089 is merged and/or in use on ios. |
after some days of running sqlx on my testphone, note sure, if sqlx helps on these anr, at least not alone. first, i had the feeling, things are a bit faster, but that seemed to be a false impression, resulting just from the restart of the app. to reproduce, it is needed that the app is running for some hours, then from inside the app, hit the home button (not: swipe away to exit) and the hit the app-icon. that results in an anr of sometimes several seconds pretty reliably (at least on my 3gig db). general impression is, that i got anr only for the top-level viewcontrollers, so, qr, chatlist, top-settings. being eg. in the chat, things are smoother. meanwhile, i dived a bit in the code:
might be, the anr is not solvable by a single code-change. maybe, the power of all these optimisations plus sqlx is needed at the end. |
k, getting closer: for whatever reason, dc_get_chatlist() is called several times after getting back from foreground:
a single call is okayish with 300ms (rembember: this is a 3gig db with several hundreds chats), however, calling it 10 times is not okay. |
i found the issue: every time the view controller come is displayed, a new foregroundObserver/applicationDidBecomeActive is created - and each one is called when the app becomes active. reasons seems to be that the removeObserver does not work as expected, we probably have to call removeObserver(self) for observers that to take a member and not a closure. |
sometimes, there are anr in charlist and chat, maybe because of incoming messages, maybe because of markseen, not sure, this does not happens always and i did not find a way to reproduce that, unfortunately.
a symptom of that is that views may be opened several times, eg. when hitting the "open chat" button during an anr several times, the chat is opened several times as well (you need to hit "back" several times to go back to the chatlist then). however, idea is to get anr fixed, not the symptom :)
The text was updated successfully, but these errors were encountered: