tdlib / td

Cross-platform library for building Telegram clients
https://core.telegram.org/tdlib
Boost Software License 1.0
7.11k stars 1.44k forks source link

loadChats is loading all chats despite the specified limit #2371

Closed bubblecsh closed 1 year ago

bubblecsh commented 1 year ago

After calling loadChats with limit of 25 i see in tdlib logs:

[ 3][t 4][1680189969.694483041][Td.cpp:2911][#1][!Td][&td_requests] Receive request 3: loadChats { chat_list = chatListMain { } limit = 25 } [ 3][t 4][1680189969.694524049][MessagesManager.cpp:17299][#1][!LoadChatsRequest] Get chats in Main chat list with offset [9221294780217032704, 0] and limit 25. last_dialog_date = [9221294780217032704, 0], last_pinned_dialog_date_ = [0, 0], are_pinned_dialogs_inited_ = true [ 3][t 4][1680189969.694534063][MessagesManager.cpp:17511][#1][!LoadChatsRequest] Load chat list in folder 0 with limit 25 [ 3][t 4][1680189969.694548130][MessagesManager.cpp:17588][#1][!LoadChatsRequest] Load 25 chats in folder 0 from database from [9221294780217032704, 0], last database server dialog date = [0, 0] [ 3][t 4][1680189969.694565296][MessagesManager.cpp:17475][#1][!LoadChatsRequest] Wait for loading of 25 chats in Main chat list ... [ 3][t 4][1680189969.695298194][MessagesManager.cpp:17609][#1][!MessagesManager] Receive 25 from expected 25 chats in folder 0 in from database with next order 7215345981250907670 and next chat 6033907928

But then it is sending updateNewChat, updateChatLastMessage and updateUser events for all chats no matter if it is account with 100 chats or 2000 chats. Sometimes this is happening along with lots of flood wait delays and errors.

What could be the cause of this?

levlam commented 1 year ago

Chats are expected to be slowly preloaded in background. This can't cause any flood wait delays or errors.

bubblecsh commented 1 year ago

Here i get thousands of chats with a speed of 100 updateNewChat events per second after calling loadChats just once. Does this also qualify as slow background preload?

levlam commented 1 year ago

Yes. 100 chats per second is the slow preload.

bubblecsh commented 1 year ago

Cool then Thanks