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

Chat messages disappearing until pull torefresh or app kill

Open jagas opened this issue 9 years ago • 17 comments

Chat messages in any thread first appears when you send it, but if you go back and go back into chat that message is not there.

jagas avatar Oct 31 '17 15:10 jagas

Noticed same issue

brucexia avatar Oct 31 '17 17:10 brucexia

I can't replicate this. Just to confirm:

  1. Open 1-to-1 thread
  2. Send text message
  3. Message appears
  4. Click back
  5. Re-open thread

After doing this, I see the message as expected. If you are seeing something different, can you give me exact steps to reproduce the issue?

bensmiley avatar Oct 31 '17 18:10 bensmiley

Yes, I can confirm that these are exact steps I take to reproduce it. I also noticed t hat after step 3 if you wait some time (not long, lets say approx 30 sec or a 60sec) it will stay when you come back.

Maybe this will shed some light on that: when I write a message and go back I also see that I have new message from myself in that chat and I can see it as "lastMessage" under the username, but when I go in I cannot see it unless I wait sometime. Some kind of sync happens

P.S.

This happens in any chat 1-to-1, group & public

jagas avatar Oct 31 '17 18:10 jagas

I can't replicate this issue. Does it happen on default version of the ChatSDK from Github with no modification? If so, can you give me details of the hardware you're using and the Android device?

bensmiley avatar Nov 02 '17 09:11 bensmiley

I did compile new fresh version from Github with one slight modification, but its styling issue (app crashing when inflating view) problem still happens every time I send a message, it happens in every chat, always.

Android version 6.0.1 hardware: samsung note 4 it also happens to my friends phone which is one plus 3

I could attach video if that would help

jagas avatar Nov 02 '17 12:11 jagas

Can you attach a video?

bensmiley avatar Nov 09 '17 17:11 bensmiley

Hi,

here is a video showing that when I write a message in group or 1-to-1 chat they do not appear there. this is not modified version except the tabs style thing, so it would compile

https://www.dropbox.com/s/7432hvmagq3svft/2017_11_13_13_57_26.mp4?dl=0

jagas avatar Nov 13 '17 12:11 jagas

I can't reproduce this. Does it happen with the completely non-modified version? Are there any exceptions thrown in the logs?

bensmiley avatar Nov 13 '17 18:11 bensmiley

yes, it also happens when i install demo apk that you built

jagas avatar Nov 13 '17 22:11 jagas

and to add more, it happens everytime for every message. not that it happens sometimes. in other words I have not been avle to send a message properly yet

jagas avatar Nov 13 '17 22:11 jagas

And it happens when you checkout the project and compile? Are there any exceptions? Have you tried using the latest version? There have been updates recently.

bensmiley avatar Nov 21 '17 23:11 bensmiley

hi, #188 explains why it happens, my clock was one minute off and thats why it was happening. Another question is: why it still shows me a new message is in the chat when I wrote it myself?

jagas avatar Nov 22 '17 09:11 jagas

The Chat is designed to mark messages from yourself as read immediately.

Is it showing the message when you send a message and quickly leave the chat or when you send a message and it updates correctly? It has been known to occur in the first instance but shouldn't with the second

simonsmiley64 avatar Nov 22 '17 10:11 simonsmiley64

For me it happens each time.

  1. I write a message
  2. wait around for 5-10 sec, press back and it shows me as unread
  3. go to a different chat room, do the same thing, press back
  4. now the old "unread" is gone, but new message took over and is unread

jagas avatar Nov 22 '17 10:11 jagas

I'm facing the same issue. And also after full reinstall unread messages counter displays all messages from chat (mine and not mine) as unread until I open chat. For that counter I use folowing snippet:

    Thread currentThread = StorageManager.shared().fetchThreadWithEntityID(mCurrentChatId);
    int unreadCount = 0;
    if (currentThread != null) {
        unreadCount = currentThread.getUnreadMessagesCount();
    }

Yariko-chan avatar Nov 27 '17 14:11 Yariko-chan

I'd like to contribute from my long experience with Google App Engine and Datastore. After talking to the App Engine developers, these were the conclusions:

The app engine server is not a single server. It is many connected machines. The "server timestamp" may vary by machine. Note that the variation may be dependent on the user's location, which may explain why the issue always shows for e.g. @jagas, @Yariko-chan but not for you.

The solution: Always read a little bit into the past. The Google app server engineers suggested that 12 seconds should be safe. Make sure you deal with duplicate and with "past" messages correctly on the client.

Just my 2 cents... :)

OferRnz avatar Dec 14 '17 20:12 OferRnz

@OferRnz Thanks for your comment. I double checked the code and I don't think that the timestamp should cause a problem. What happens in the code is that when the app starts, a listener is added which listens for any messages that have arrived since the last message. If there were an issue with the timestamp, we would expect the app to work correctly after 12 had passed (even if it didn't handle messages that had been sent within 12 seconds of the last message).

I did manage to replicate an issue which is similar to this. To replicate the issue:

  1. Open the chat view
  2. Put the app in the background
  3. Send a message to the app from a different device
  4. Re-open the app. The message will be absent from the list.

This has now been fixed and will be available in the next Gradle release - 4.0.9. For the time being I'm closing this issue because I've not been able to replicate it. If it continues, please reopen the issue.

bensmiley avatar Jan 10 '18 18:01 bensmiley