RocketChat / Rocket.Chat.Android

Legacy mobile Rocket.Chat client in Kotlin for Android
https://rocket.chat
MIT License
871 stars 556 forks source link

[BUG] Cannot load all channels/rooms #2290

Open hypery2k opened 5 years ago

hypery2k commented 5 years ago

Describe the bug

When loading rooms with lots of message the loading indicator never goes away. Rooms with less messages work. The iOS app with the same backend is working fine. The REST call is fast (~200ms response time)

To Reproduce

  1. Open app
  2. select room
  3. Wait ...

Expected behavior

Loading ;)

Logs

I can see that the http call goes through:

D/AppModule$provideHttpLo: {"messages":[....],"count":30,"offset":0,"total":7334,"success":true}
D/AppModule$provideHttpLo: <-- END HTTP (14728-byte body)
I/art: Background sticky concurrent mark sweep GC freed 370650(20MB) AllocSpace objects, 14(708KB) LOS objects, 31% free, 44MB/65MB, paused 1.507ms total 148.003ms

Screenshots

-

Devices and Versions

Additional context

I debugged the app and i can see that I hit a breakpoint here:

https://github.com/RocketChat/Rocket.Chat.Kotlin.SDK/blob/ebeaa66c8d557ef869ed9c2b6a488b63f1972c97/core/src/main/kotlin/chat/rocket/core/internal/rest/Message.kt#L301

But the return is never reached:

https://github.com/RocketChat/Rocket.Chat.Kotlin.SDK/blob/ebeaa66c8d557ef869ed9c2b6a488b63f1972c97/core/src/main/kotlin/chat/rocket/core/internal/rest/Message.kt#L318

I think it's an memory issue with the JSON Mapping:

image

Even tried to request more memory via AndroidManifest.xml and doesn't work out:

android:largeHeap="true"

If i lower count in the client.message call to 20 its working: https://github.com/RocketChat/Rocket.Chat.Android/blob/a1cc67224d67c24c7a53eab8a863f83edb7737d4/app/src/main/java/chat/rocket/android/chatroom/presentation/ChatRoomPresenter.kt#L266

I think one approach to solve this, would be to let check for memory warnings there and reduce the loading ahead (aka count)

hypery2k commented 5 years ago

just noticed that it's occuring on a message with many replies in a thread. Maybe that's the real issue

hypery2k commented 5 years ago

this could be related: https://github.com/square/moshi/issues/509

pxlfrk commented 5 years ago

We also experience this issue on multiple Android devices, as described above.

kenkendk commented 5 years ago

Same here, used to work, but recent update to Android app broke it somehow. Not sure it is related to message count, as we have multiple large channels, and only some of them fail to load in the app (all work on Desktop, and presumably iOS).

hypery2k commented 5 years ago

Same here, used to work, but recent update to Android app broke it somehow. Not sure it is related to message count, as we have multiple large channels, and only some of them fail to load in the app (all work on Desktop, and presumably iOS).

I don't think its really depending on the messages in the channel, from the code and memory stats I think it's more related to data complexity. e.g. if a channel has linked items on a post, e.g. links, threads, reactions the JSON Mapping consumes more memory here, which might by an issue on Android due the heap restrictions on DalvikVM, as i also see this in the logs:

I/art: Background sticky concurrent mark sweep GC freed 405886(29MB) AllocSpace objects, 0(0B) LOS objects, 37% free, 44MB/70MB, paused 2.806ms total 132.842ms
I/art: Background sticky concurrent mark sweep GC freed 400591(29MB) AllocSpace objects, 0(0B) LOS objects, 37% free, 44MB/70MB, paused 2.595ms total 118.279ms
pxlfrk commented 5 years ago

Additional information that might be useful for debugging: The Beta-App (Rocket Chat Experimental on Play Store) works fine. I'm not able to reproduce the bug described above with the exact same channels/rooms. So using this App is a small Workaround for those who need to access affected channels/rooms on a mobile device.