perf(login)!: Fix slow login by delaying messenger filters initialization (#20173)

Fixes the slow login when users have joined large communities, such as the
Status one. Related status-go PR
https://github.com/status-im/status-go/pull/5229.

What we mean by "slow" is that the user was getting stuck on the login screen
for almost 20s in some devices (even on iOS things were bad). And this entire
process was happening in status-go, hence most changes come from there.

By "login" we mean the process to authenticate and initialize vital data in
status-go. Setting up message filters can be slow with large communities, and
that's exactly this part we moved out of the login phase in status-go. This step
now happens implicitly when the client calls wakuext_startMessenger.

In a way, the solution makes sense because setting up filters isn't essential
for the user to access other parts of the app, such as the Wallet, Settings,
Profile, and Activity Center.

How can we magically eliminate the login delay? In reality, the time we used to
spent during login, blocking the user, still happens, but it happens in the
background and after the user is redirected to the home screen. This also means
that, until the filters are established, all chats are still in their "loading
skeleton state".

In terms of UX, this is probably fine as long as it doesn't take too long for
this setup to finish in status-go. In the future, we have room to further
optimize how filters are set up in status-go.

Fixes https://github.com/status-im/status-mobile/issues/20059
This commit is contained in:
Icaro Motta 2024-06-11 07:41:29 -03:00 committed by GitHub
parent 94e728bdf3
commit 9f245ceb30
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 22 additions and 19 deletions

View File

@ -53,20 +53,25 @@
(assoc-in [:activity-center :loading?] true))
pairing-completed?
(dissoc :syncing))
:fx (into [[:dispatch [:universal-links/generate-profile-url]]
:fx (into [[:json-rpc/call
[{:method "wakuext_startMessenger"
:on-success [:profile.login/messenger-started]
:on-error #(log/error "failed to start messenger" %)}]]
[:dispatch [:universal-links/generate-profile-url]]
[:dispatch [:community/fetch]]
[:dispatch [:wallet/initialize]]
[:push-notifications/load-preferences]
[:fetch-chats-preview
{:on-success (fn [result]
(rf/dispatch [:chats-list/load-success result])
(rf/dispatch [:communities/get-user-requests-to-join])
(rf/dispatch [:profile.login/get-chats-callback]))}]
[:profile.config/get-node-config]
[:logs/set-level log-level]
[:activity-center.notifications/fetch-pending-contact-requests-fx]
[:activity-center/update-seen-state]
[:activity-center.notifications/fetch-unread-count]]
[:activity-center.notifications/fetch-unread-count]
;; Immediately try to open last chat. We can't wait until the
;; messenger has started and has processed all chats because
;; the whole process can take a handful of seconds.
(when-not (:universal-links/handling db)
[:effects.chat/open-last-chat (:key-uid profile-overview)])]
(cond
pairing-completed?
@ -90,12 +95,7 @@
(let [{:keys [notifications-enabled? key-uid
preview-privacy?]} (:profile/profile db)]
{:db db
:fx [[:json-rpc/call
[{:method "wakuext_startMessenger"
:on-success [:profile.login/messenger-started]
:on-error #(log/error
"failed to start messenger")}]]
[:effects.profile/enable-local-notifications]
:fx [[:effects.profile/enable-local-notifications]
[:contacts/initialize-contacts]
[:browser/initialize-browser]
[:dispatch [:mobile-network/on-network-status-change]]
@ -107,8 +107,6 @@
[:switcher-cards/fetch]
(when (ff/enabled? ::ff/wallet.wallet-connect)
[:dispatch [:wallet-connect/init]])
(when-not (:universal-links/handling db)
[:effects.chat/open-last-chat key-uid])
(when notifications-enabled?
[:effects/push-notifications-enable])]})))
@ -118,7 +116,12 @@
{:db (-> db
(assoc :messenger/started? true)
(mailserver/add-mailservers mailservers))
:fx [[:json-rpc/call
:fx [[:fetch-chats-preview
{:on-success (fn [result]
(rf/dispatch [:chats-list/load-success result])
(rf/dispatch [:communities/get-user-requests-to-join])
(rf/dispatch [:profile.login/get-chats-callback]))}]
[:json-rpc/call
[{:method "admin_nodeInfo"
:on-success [:profile.login/node-info-fetched]
:on-error #(log/error "node-info: failed error" %)}]]

View File

@ -3,7 +3,7 @@
"_comment": "Instead use: scripts/update-status-go.sh <rev>",
"owner": "status-im",
"repo": "status-go",
"version": "v0.179.28",
"commit-sha1": "33ccf784c52e56d98f2928b4618db5490a1e1f95",
"src-sha256": "0cz8cbzqbp6i3p9la0iibk73s2fmlk449zd9fznms8b02g4n3xic"
"version": "v0.180.30",
"commit-sha1": "b665d68d0cff7cd4521ac8791fcf6eac29b23cd9",
"src-sha256": "1bpj3x2bmrh7whhx9sb2wgwc4q8knm4c3rzvimp0s84fsvna5ynq"
}