Skip to content

Message Load Room Investigation

Christopher Gamache edited this page Apr 26, 2019 · 1 revision

The problem does not really appear if you have a sufficiently fast internet. Once I found out how to throttle my emulators internet I found the main culprit.

https://github.com/RocketChat/Rocket.Chat.Android/blob/6f2f5c88754d520e91f8087166117cabe51acfbf/app/src/main/java/chat/rocket/android/chatroom/presentation/ChatRoomPresenter.kt#L138

The function call client.chatRoomRoles takes somewhere between 3-10 seconds to execute and eventually kicks out with a thrown exception. "HTTP FAILED: java.net.SocketTimeoutException: timeout."

During this same time I also see "E/RecyclerView: No adapter attached; skipping layout"

And a few instances of "I/Choreographer: Skipped 42 frames! The application may be doing too much work on its main thread."

The client.chatRoomRoles function is launched within a global scope, I'm not sure if this is necessary but perhaps on a slow internet it is bogging down the main thread with blocking behavior. The actual function is defined in the Rocket.Chat.Kotlin.SDK. https://github.com/RocketChat/Rocket.Chat.Kotlin.SDK/blob/d348a56154e7b704dcc6976f312343f829a80c8c/core/src/main/kotlin/chat/rocket/core/internal/rest/ChatRoom.kt#L601

On a less serious note displaying the local messages right after the following and then loading in the rest would add a bit of perceived responsiveness. https://github.com/RocketChat/Rocket.Chat.Android/blob/6f2f5c88754d520e91f8087166117cabe51acfbf/app/src/main/java/chat/rocket/android/chatroom/presentation/ChatRoomPresenter.kt#L225