App freezes for a moment after clicking back on ChannelActivity

UIKit Version:
2.2.3

Android Version:
11

Device:
Microsoft Surface Duo 2

Summary:
We have noticed that our application often freezes for a few seconds immediately after visiting a SendBird UIKit ChannelActivity and pressing back to return to one our own activities. Sometimes, this freeze is long enough to trigger an ANR.

I am able to reproduce this issue about 1 out of every 10 times I visit ChannelActivity and immediately press the back button on the top toolbar.

Each time this happens, there are a few SendBird connection failure logs. After the connection failure logs, the system logs that frames were skipped. Sometimes, but not every time, there is also a SendBirdException stack trace printed to the logs.

For example, here are the logs around one of the times that the issue occurred:

V/FA: Activity paused, time: 664942
E/PINGER: [14:34:44.247 Connection$Pinger:stop():507] Pinger stop true
E/Sendbird:PINGER: [14:34:44.247 Connection$Pinger:stop():508] Pinger stop true
W/SendBird: [14:34:44.248 Connection$1:onFailure():235] onFailed instance : com.sendbird.android.Connection@8ebf711
W/Sendbird: [14:34:44.248 Connection$1:onFailure():236] onFailed instance : com.sendbird.android.Connection@8ebf711
W/SendBird: [14:34:44.249 Connection$1:onFailure():241] onFailed handler : com.sendbird.android.SocketManager@efcaa1
W/Sendbird: [14:34:44.249 Connection$1:onFailure():242] onFailed handler : com.sendbird.android.SocketManager@efcaa1
W/SendBird: [14:34:44.249 SocketManager:onError():972] >> onError : Socket is closed, reconnecting : false, explicitDisconnect : true
E/MainActivity: Branch error: Warning. Session initialization already happened. To force a new session, set intent extra, "branch_force_new_session", to true.
D/UnreadMessageCountManager: Total unread SendBird message count subscriber count: 2
V/FA: Activity resumed, time: 666119
I/PlayCore: UID: [10270]  PID: [11451] AppUpdateService : requestUpdateInfo(sport.mojo.android)
D/MojoAnalytics: Tracking user traits analytics: {last_screen_viewed=Chat List}
D/MojoAnalytics: Tracking analytics event: Screen Viewed - {screen_name=Chat List}
I/Choreographer: Skipped 105 frames!  The application may be doing too much work on its main thread.
I/PlayCore: UID: [10270]  PID: [11451] AppUpdateService : Initiate binding to the service.
I/OpenGLRenderer: Davey! duration=1210ms; Flags=1, IntendedVsync=664947359050, Vsync=666114025705, OldestInputEvent=9223372036854775807, NewestInputEvent=0, HandleInputStart=666124086410, AnimationStart=666124087347, PerformTraversalsStart=666124174222, DrawStart=666143161097, SyncQueued=666147500264, SyncStart=666148241410, IssueDrawCommandsStart=666148705524, SwapBuffers=666152570108, FrameCompleted=666158365576, DequeueBufferDuration=234167, QueueBufferDuration=376041, GpuCompleted=614032440909, 
I/PlayCore: UID: [10270]  PID: [11451] AppUpdateService : ServiceConnectionImpl.onServiceConnected(ComponentInfo{com.android.vending/com.google.android.finsky.installservice.DevTriggeredUpdateService})
I/PlayCore: UID: [10270]  PID: [11451] AppUpdateService : linkToDeath
W/FA: setCurrentScreen cannot be called with the same class and name
I/PlayCore: UID: [10270]  PID: [11451] OnRequestInstallCallback : onRequestInfo
I/PlayCore: UID: [10270]  PID: [11451] AppUpdateService : Unbind from service.
W/SendBird: [14:34:45.145 Connection$1:onMessage():220] onMessage instance : [LOGI] com.sendbird.android.Connection@e9bd83a
W/Sendbird: [14:34:45.145 Connection$1:onMessage():221] onMessage instance : [LOGI] com.sendbird.android.Connection@e9bd83a
W/SendBird: [14:34:45.146 EventController$1:call():141] ++ result[LOGI] runnable=null
W/SendBird: [14:34:45.188 Connection$1:onMessage():220] onMessage instance : [PONG] com.sendbird.android.Connection@e9bd83a
W/Sendbird: [14:34:45.188 Connection$1:onMessage():221] onMessage instance : [PONG] com.sendbird.android.Connection@e9bd83a
W/SendBird: [14:34:45.189 EventController$1:call():141] ++ result[PONG] runnable=null
D/SBUIKIT: [14:34:45.280 ChannelViewModel:onChannelUpdated():334] >> ChannelViewModel::onChannelUpdated() from=CHANNEL_CHANGELOG, url=mojo_channel_admin_7809
D/SBUIKIT: [14:34:45.280 ChannelViewModel:notifyChannelDataChanged():210] >> ChannelViewModel::notifyChannelDataChanged()
I/SBUIKIT: [14:34:45.462 ChannelViewModel:disposeMessageCollection():146] >> ChannelViewModel::disposeMessageCollection()
I/SBUIKIT: [14:34:45.463 ChannelFragment:onDestroy():177] >> ChannelFragment::onDestroy()
E/SendBird: [14:34:45.464 MessageCollection$19:run():1434] SendBirdException{code=800120, message=null}
        at com.sendbird.android.APIRequest.request(APIRequest.java:177)
        at com.sendbird.android.APIRequest.GET(APIRequest.java:136)
        at com.sendbird.android.APIClient.messageList(APIClient.java:741)
        at com.sendbird.android.APIClient.messageList(APIClient.java:655)
        at com.sendbird.android.BaseChannel.getMessagesBlocking(BaseChannel.java:508)
        at com.sendbird.android.MessageRepository.loadMessagesWithoutCache(MessageRepository.java:264)
        at com.sendbird.android.MessageRepository.loadPrevious(MessageRepository.java:102)
        at com.sendbird.android.MessageRepository.loadPreviousWithoutCache(MessageRepository.java:306)
        at com.sendbird.android.MessageCollection$19.run(MessageCollection.java:1398)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:462)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
        at java.lang.Thread.run(Thread.java:923)
D/MainViewModel$networkCallback: The default network has changed capabilities.

In this case, it seems that SendBird was having network issues (Error code: 800120). It is worth noting that network issues are not always logged when the freeze happens. Sometimes no specific error is logged.

Either way, it seems that SendBird’s error handling logic might be doing too much work on the main thread. Any guidance is appreciated!

Thank you,
Stephen

Hi, @stephen-mojo Sorry to late reply!

Currently, our UIKit latest version for V2 is v2.2.5. Please update the version!

I want to check the precise reproducible steps.

  1. How did you keep your network status? always online?
  2. Do you use our ChannelListActivity?
  3. Is this issue able to be reproduced when you enter and press back button for the first time (after app is statred) or when you enter and press back button at least N times?