crisp-im / crisp-sdk-android

:package: Crisp Android SDK, add a chat in any Android app and communicate with your users.
https://docs.crisp.chat/guides/chatbox-sdks/android-sdk/
Other
56 stars 17 forks source link

Crash when web sdk initialize a session #180

Closed reygie25 closed 1 month ago

reygie25 commented 3 months ago

Could you please review the video I created regarding the crash we encountered with the Android SDK? Below is a summary of the issue:

Here is the video link: https://drive.google.com/file/d/14zAOziLjh4N_gqf9_uaXfCCd-uQxsmm1/view?usp=sharing

Summary:

Doc1faux commented 3 months ago

Hi @reygie25 and thank you for your feedback.

Could you please paste here the stacktrace you show us in your video? It's simpler for us to symbolicate it this way ;)

Could you also precise which version of the SDK you're using?

reygie25 commented 3 months ago

@Doc1faux Hello! here's the stacktrace and the SDK version we used.

Android SDK version: im.crisp:crisp-sdk:2.0.1beta2 Web SDK version: "crisp-sdk-web": "^1.0.25",

Task threw exception java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String im.crisp.client.internal.data.b.d()'on a null object reference at im.crisp.client.internal.data.ChatMessage.t(Unknown Source: 12) at im.crisp.client.internal.b.a.a(SourceFile: 1) at im.crisp.client.internal.h.b.a(SourceFile: 27) at im.crisp.client.internal.h.b.a(SourceFile: 25) at im.crisp.client.internal.h.b.a(SourceFile: 24) at im.crisp.client.internal.h.b.d(SourceFile: 6) at im.crisp.client.internal.h.b.b(SourceFile: 10) at im.crisp.client.internal.h.b.a(SourceFile: 25) at im.crisp.client.internal.h.b.a(SourceFile: 24) at im.crisp.client.internal.h.a.a(SourceFile: 8) at im.crisp.client.internal.h.a.a(SourceFile: 25) at im.crisp.client.internal.h.a.c(SourceFile: 4) at im.crisp.client.internal.h.a.p(SourceFile: 1) at im.crisp.client.internal.h.a.$r8$lambda$JhVOR3VikYGPj6QfDtogpown5FM(Unknown Source: 0) at im.crisp.client.internal.h.a$$ExternalSyntheticLambda7.call(Unknown Source: 2) at io.socket.emitter.Emitter.emit(Emitter.java: 117) at io.socket.client.Socket.onevent(Socket.java: 320) at io.socket.client.Socket.onpacket(Socket.java: 271) at io.socket.client.Socket.access$100(Socket.java: 18) at io.socket.client.Socket$2$2.call(Socket.java: 88) at io.socket.emitter.Emitter.emit(Emitter.java: 117) at io.socket.client.Manager.ondecoded(Manager.java: 361) at io.socket.client.Manager.access$1200(Manager.java: 22) at io.socket.client.Manager$5.call(Manager.java: 355) at io.socket.parser.IOParser$Decoder.add(IOParser.java: 103) at io.socket.client.Manager$2.call(Manager.java: 331) at io.socket.emitter.Emitter.emit(Emitter.java: 117) at io.socket.engineio.client.Socket.onPacket(Socket.java: 558) at io.socket.engineio.client.Socket.access$1000(Socket.java: 36) at io.socket.engineio.client.Socket$5.call(Socket.java: 337) at io.socket.emitter.Emitter.emit(Emitter.java: 117) at io.socket.engineio.client.Transport.onPacket(Transport.java: 124) at io.socket.engineio.client.Transport.onData(Transport.java: 116) at io.socket.engineio.client.transports.WebSocket.access$100(WebSocket.java: 23) at io.socket.engineio.client.transports.WebSocket$1$2.run(WebSocket.java: 73) at io.socket.thread.EventThread$2.run(EventThread.java: 80) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java: 1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java: 644) at java.lang.Thread.run(Thread.java: 1012)

FATAL EXCEPTION: EventThread Process: com.staffup.groovestaffing_dev, PID: 2575 java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String im.crisp.client.internal.data.b.d()' on a null object reference at im.crisp.client.internal.data.ChatMessage.t(Unknown Source: 12) at im.crisp.client.internal.b.a.a(SourceFile: 1) at im.crisp.client.internal.h.b.a(SourceFile: 27) at im.crisp.client.internal.h.b.a(SourceFile: 25) at im.crisp.client.internal.h.b.a(SourceFile: 24) at im.crisp.client.internal.h.b.d(SourceFile: 6) at im.crisp.client.internal.h.b.b(SourceFile: 10) at im.crisp.client.internal.h.b.a(SourceFile: 25) at im.crisp.client.internal.h.b.a(SourceFile: 24) at im.crisp.client.internal.h.a.a(SourceFile: 8) at im.crisp.client.internal.h.a.a(SourceFile: 25) at im.crisp.client.internal.h.a.c(SourceFile: 4) at im.crisp.client.internal.h.a.p(SourceFile: 1) at im.crisp.client.internal.h.a.$r8$lambda$JhVOR3VikYGPj6QfDtogpown5FM(Unknown Source: 0) at im.crisp.client.internal.h.a$$ExternalSyntheticLambda7.call(Unknown Source: 2) at io.socket.emitter.Emitter.emit(Emitter.java: 117) at io.socket.client.Socket.onevent(Socket.java: 320) at io.socket.client.Socket.onpacket(Socket.java: 271) at io.socket.client.Socket.access$100(Socket.java: 18) at io.socket.client.Socket$2$2.call(Socket.java: 88) at io.socket.emitter.Emitter.emit(Emitter.java: 117) at io.socket.client.Manager.ondecoded(Manager.java: 361) at io.socket.client.Manager.access$1200(Manager.java: 22) at io.socket.client.Manager$5.call(Manager.java: 355) at io.socket.parser.IOParser$Decoder.add(IOParser.java: 103) at io.socket.client.Manager$2.call(Manager.java: 331) at io.socket.emitter.Emitter.emit(Emitter.java: 117) at io.socket.engineio.client.Socket.onPacket(Socket.java: 558) at io.socket.engineio.client.Socket.access$1000(Socket.java: 36) at io.socket.engineio.client.Socket$5.call(Socket.java: 337) at io.socket.emitter.Emitter.emit(Emitter.java: 117) at io.socket.engineio.client.Transport.onPacket(Transport.java: 124) at io.socket.engineio.client.Transport.onData(Transport.java: 116) at io.socket.engineio.client.transports.WebSocket.access$100(WebSocket.java: 23) at io.socket.engineio.client.transports.WebSocket$1$2.run(WebSocket.java: 73) at io.socket.thread.EventThread$2.run(EventThread.java: 80) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java: 1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java: 644) at java.lang.Thread.run(Thread.java: 1012)

Doc1faux commented 3 months ago

Thanks for the infos @reygie25, I take a look at it

Doc1faux commented 3 months ago

After a deep dive into this crash, this is most likely due to the message being sent by a plugin (is this your case?) which leads the user to be null.

I did not anticipate this case :o

I already fixed it and it will be released in the next 2.0.2beta3 release.

reygie25 commented 3 months ago

@Doc1faux, Thanks! Can you give us an ETA for when the next release will be?

Doc1faux commented 2 months ago

Sorry for the late reply, I think next release could be available by mi-august. We want to add #160 and #169 at least and some minor fixes.

reygie25 commented 2 months ago

@Doc1faux We tried to find a workaround to avoid the user being null when a message is sent by a plugin. Can you check this question?

So, when sending a message using the plugin as OPERATOR in this API (https://docs.crisp.chat/references/rest-api/v1/#send-a-message-in-conversation), the USER object is not required, but we are sending it anyway. However, I noticed that we are not sending the 'type' (USER.TYPE, only the nickname and avatar. When sending a message as an operator, what should the value of type be? Should it be "website" or "participant"? I just want to confirm which one we should use.

Doc1faux commented 2 months ago

Hi @reygie25, in order to avoid the crash with the current version while waiting the next release fixing the crash, you can send the message with these fields:

{
   "from": "operator",
   "user: {
      "type": "website"
   }
}

It will behave like it was sent by your Crisp bot.

Doc1faux commented 1 month ago

I just shipped the new 2.0.2beta3 release which should fix this issue. It can take a couple of hours to be available. I close the issue.