Crash on Samsung Galaxy S7 Edge - OS 6.0.1, API 23
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)
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 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.
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.
Good find,
Classic race condition, I will patch this in the next hotfix.
-- Kyle
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.