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

Crash on Samsung Galaxy S7 Edge - OS 6.0.1, API 23

Open mendozamiche opened this issue 9 years ago • 5 comments

Receiving crash after the app was built from the master branch running on Samsung Galaxy S7 Edge - OS 6.0.1, API 23

Steps to reproduce:

search for contact add contact start chat with contact send message receive crash

sometimes happens when sending 1 message after the other with 1 second delay - in direct conversations and also in chat rooms

02-27 15:42:58.123 18954-18954/com.braunster.androidchatsdk.app E/ClipboardServiceEx: clipEx is android.sec.clipboard.ClipboardExManager@d4756b4
02-27 15:42:58.123 18954-18954/com.braunster.androidchatsdk.app E/ClipboardServiceEx: clipEx has text data : false
02-27 15:42:58.123 18954-18954/com.braunster.androidchatsdk.app E/ClipboardServiceEx: clipEx is android.sec.clipboard.ClipboardExManager@d4756b4
02-27 15:42:58.123 18954-18954/com.braunster.androidchatsdk.app E/ClipboardServiceEx: clipEx has text data : false
02-27 15:42:58.133 18954-18954/com.braunster.androidchatsdk.app E/SpannableStringBuilder: SPAN_EXCLUSIVE_EXCLUSIVE spans cannot have a zero length
02-27 15:42:58.133 18954-18954/com.braunster.androidchatsdk.app E/SpannableStringBuilder: SPAN_EXCLUSIVE_EXCLUSIVE spans cannot have a zero length
02-27 15:42:58.143 18954-26285/com.braunster.androidchatsdk.app V/BMessageWrapper: deserialize, Value: {user-firebase-id=QNTiaO17O7TB6UkJ4c2Cq6H8jlJ3, date=1488228178977, type=0, payload=Hrllo}
02-27 15:42:58.173 18954-18954/com.braunster.androidchatsdk.app D/ChatSDKMessagesListAdapter: Checking if exist
02-27 15:42:58.213 18954-18954/com.braunster.androidchatsdk.app V/BMessageWrapper: push message, onDone
02-27 15:42:58.213 18954-18954/com.braunster.androidchatsdk.app V/BFirebaseNetworkAdapter: pushForMessage
02-27 15:42:58.233 18954-18954/com.braunster.androidchatsdk.app D/AndroidRuntime: Shutting down VM
02-27 15:42:58.233 18954-18954/com.braunster.androidchatsdk.app E/AndroidRuntime: FATAL EXCEPTION: main
                                                                                  Process: com.braunster.androidchatsdk.app, PID: 18954
                                                                                  java.lang.IllegalStateException: Deferred object already finished, cannot notify progress
                                                                                      at org.jdeferred.impl.DeferredObject.notify(DeferredObject.java:82)
                                                                                      at com.braunster.chatsdk.network.AbstractNetworkAdapter$1.run(AbstractNetworkAdapter.java:170)
                                                                                      at android.os.Handler.handleCallback(Handler.java:739)
                                                                                      at android.os.Handler.dispatchMessage(Handler.java:95)
                                                                                      at android.os.Looper.loop(Looper.java:158)
                                                                                      at android.app.ActivityThread.main(ActivityThread.java:7229)
                                                                                      at java.lang.reflect.Method.invoke(Native Method)
                                                                                      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
                                                                                      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)

mendozamiche avatar Feb 27 '17 20:02 mendozamiche

Hi @mendozamiche,

Can you confirm whether this is before or after you have configured the chat to your own custom Firebase account? Does this same crash occur when running the cloned version of the Android Chat SDK? If you can confirm this we can narrow down whether this issue is coming from the project or from the Firebase configuration.

Simon

simonsmiley64 avatar Mar 02 '17 22:03 simonsmiley64

@simonsmiley64 This crash is happening when cloning the project and creating a build from the master branch. No configurations were made prior to making the build and running the app.

mendozamiche avatar Mar 03 '17 01:03 mendozamiche

The issue seems to be with this piece of code:

new Handler(Looper.getMainLooper()).postDelayed(new Runnable() {
            @Override
            public void run() {
                deferred.notify(message);
            }
}, 100);

inside sendMessageWithText method of the AnstractNetworkAdapter class. Specifically, the sendMessage call appears to be resolving the Promise in under 100ms, causing the 100ms delayed notify call on the deferred object to fail.

olawson avatar Mar 09 '17 16:03 olawson

Good find,

Classic race condition, I will patch this in the next hotfix.

-- Kyle

kykrueger avatar Mar 09 '17 16:03 kykrueger

Instead of removing the notification all together, I have added a check to see if the deferrable is completed before sending the notification. This should stop the app from crashing if the message sends faster than 100ms.

I will close this issue now. However, feel free to test the fix and re-open if needed. I was not able to reproduce it in the first place on my end.

kykrueger avatar Mar 11 '17 14:03 kykrueger