stream-chat-android icon indicating copy to clipboard operation
stream-chat-android copied to clipboard

CPU usage increases when events are received

Open workspace opened this issue 3 years ago • 2 comments

Describe the bug I'm using client and offline only. (not stream-compose) I got some performance issue(ex. LazyColumn is laggy) when many users use our service. (in late night, I don't have any problem 😅)

First, I tried to optimize our application, however, It still has a problem. So, I tried to test compose sample application and found something to investigate.

👉CPU usage increases when events are received. (90% ~ 100%) (UserWatchingStarted/StoppedEvent, TypingStarted/StoppedEvent and MessageReadEvent) Sync and recovery is also one of the reason for high cpu usage. (It replays a lot of events which occurred when user is in background)

Watch screen record in Screenshots for details.

SDK version

  • develop branch (dda4ba96a929c05eb5078b80a264be19955048a0)
  • 4.30.0

To Reproduce Steps to reproduce the behavior:

  1. Prepare stream-chat-android-compose-sample to test
  2. Prepare credential which is used in real service (20+ channels, 500+ active users. I can provide it if you need)
  3. Just stay in sample application
  4. Check cpu usage when events are arrived. (do nothing with test. Just keep screen on)

Expected behavior lower CPU usage

Device:

  • Vendor and model: Samsung Galaxy S21 Ultra
  • Android version: 12

Screenshots Screen Record (with develop branch app) (Android Studio - CPU profiler) (Application) (Logcat) https://youtu.be/QcJ5CH7hvUE

workspace avatar Mar 18 '22 11:03 workspace

At first, I sent a message to @skydoves to describe this issue. After talking about this issue, he recommended to tag @adasiewiczr @filbabic to investigate this issue.

workspace avatar Mar 18 '22 11:03 workspace

hey @workspace, thanks for reporting this. We'll investigate this and we'll come up with a solution as soon as possible.

adasiewiczr avatar Mar 18 '22 11:03 adasiewiczr

Closing this as we've had a series of improvements around event handling.

We can look into it if it's still an issue with these changes.

filbabic avatar Feb 01 '23 08:02 filbabic