cometchat / chat-sdk-android

Text Chat SDK for Android
https://www.cometchat.com
22 stars 12 forks source link

[2.1.6] My whole application start crashing just because of cometchat internal crash #35

Closed haris-qayyum closed 3 years ago

haris-qayyum commented 3 years ago

Describe the bug First of all, I'm not using comet-chat UI Kit, instead, I'm using comet-chat SDK with my own UI... Everything was working fine till the last 2 days.. but today (after the weekend) when I'm sending any message or receiving any calls etc, my application is being crashed with an error

java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.String.equalsIgnoreCase(java.lang.String)' on a null object reference at com.cometchat.pro.core.CometChat$1$1.run(CometChat.java:95) at android.os.Handler.handleCallback(Handler.java:899) at android.os.Handler.dispatchMessage(Handler.java:100) at android.os.Looper.loop(Looper.java:238) at android.app.ActivityThread.main(ActivityThread.java:7853) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:984)

As far as I debug, it is being crash due to 'null' value of 'messageReceipt.getReceiptType()'.

Please fix that issue ASAP. Thanks.

adityagokula2210 commented 3 years ago

Hello @haris-qayyum , Can you please share the code snippet you are using to mark the message as read?

haris-qayyum commented 3 years ago

Hi @adityagokula2210, I'm calling the following method to mark any message as read. public static void markMessageAsRead(BaseMessage baseMessage) { CometChat.markAsRead(baseMessage.getId(), baseMessage.getSender().getUid(), CometChatConstants.RECEIVER_TYPE_USER); }

adityagokula2210 commented 3 years ago

Can you please share your appId and a couple of sample users so that I can test this at my end?

haris-qayyum commented 3 years ago

implementation 'com.cometchat:pro-android-chat-sdk:2.1.1'

haris-qayyum commented 3 years ago

public static String APP_ID = "27834d968f8f279";

You can use Client One user.

adityagokula2210 commented 3 years ago

Also, can you please try using version 2.1.6 and confirm if the same crash is happening in 2.1.6 version too ?

haris-qayyum commented 3 years ago

I even tried with your latest beta version, but still, I was getting the same crashing..

adityagokula2210 commented 3 years ago

Can you give me 2 UIDs that i can use for testing at my end?

haris-qayyum commented 3 years ago

232801eb-b1fb-44ff-aaf5-84c3a97757a0 70b34158-3204-4dd1-9b6c-7b5653a25b0a

haris-qayyum commented 3 years ago

I was thinking if you guys can handle that exception in any try/catch block then It never crash the main app.

haris-qayyum commented 3 years ago

can you please check your database to see such records where receipt type is null?

adityagokula2210 commented 3 years ago

Hello @haris-qayyum Can you please stop using the two UIDs for testing as we are using them here and it's causing us some problems in investigating the crash

haris-qayyum commented 3 years ago

Yes, sure.. Sorry for the inconvenience..

adityagokula2210 commented 3 years ago

@haris-qayyum I can see that the same users are logged in from some iOS devices too. Can you please log the users out of all the devices or kill all the apps and then let me know so that we can check this

Thanks

haris-qayyum commented 3 years ago

Sorry again, I asked everyone to not use these but don't know who is using these accounts.. So, Please use these accounts, they are new and not in use by any developer here. 14a35922-8187-4bc2-aff0-98a5b39cd83a 878a6e4c-8c0d-4de8-8265-8d85181a2076

adityagokula2210 commented 3 years ago

Thanks

adityagokula2210 commented 3 years ago

Hello @haris-qayyum We have identified the issue. The issue will only be encountered when the same user is logged in from 1 android device and 1 iOS device. There is some inconsistency with the format of the data shared by the iOS SDK while marking the message read when there are multiple devices involved. We have informed the iOS team about this and we will be releasing a patch in the next iOS SDK version. In the next version of the Android SDK we will be adding an error handling mechanism so that it does not cause a crash. We will let you know once both these versions are live

Thanks

adityagokula2210 commented 3 years ago

Issue fixed in version 2.1.7-beta3.