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

IllegalStateException no_session #144

Closed Damien-L closed 1 year ago

Damien-L commented 1 year ago

Hi,

We faced a new issue with a Xiaomi 11 Lite 5G NE Android 12 with crisp SDK 1.0.13.

Fatal Exception: java.lang.IllegalStateException: no_session at im.crisp.client.internal.c.b.(SourceFile:102) at im.crisp.client.internal.c.b.a(SourceFile:9) at im.crisp.client.internal.c.b.b(SourceFile:1) at im.crisp.client.internal.t.b.h(SourceFile:15) at im.crisp.client.internal.t.b.b(SourceFile) at im.crisp.client.internal.t.b.$r8$lambda$euraMwwcc3sYrIw2PCjjWiIVhGE(SourceFile) at im.crisp.client.internal.t.b$$InternalSyntheticLambda$1$9205c5bb810fa1df9ae1fe2919a5c7d83dfb800e50183d62bda7a5959c098f5f$2.onClick(b.java:2) at android.view.View.performClick(View.java:7750) at android.view.View.performClickInternal(View.java:7727) at android.view.View.access$3700(View.java:861) at android.view.View$PerformClick.run(View.java:29133) at android.os.Handler.handleCallback(Handler.java:938) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loopOnce(Looper.java:210) at android.os.Looper.loop(Looper.java:299) at android.app.ActivityThread.main(ActivityThread.java:8103) at java.lang.reflect.Method.invoke(Method.java) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:556) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1045)

Doc1faux commented 1 year ago

Hi @Damien-L and thank you for your feedback.

This crash occurs if no session is found while a user tries to send a message. This seems very unlikely as UI is visible only if a session is ongoing (socket connection & session joined).

However, to better understand this issue, do you have some other I/O Exception bound to DiskLruCache or not along with this crash? The only way I believe this can occur is when we fail to save the session locally to access it later.

Damien-L commented 1 year ago

We got some.

image

Some of them speak about Crisp in the stacktrace. Like this one :

main (native): tid=1 systid=28184

00 pc 0x85c9c libc.so (syscall + 28)

01 pc 0x394f3c libart.so (art::ConditionVariable::WaitHoldingLocks(art::Thread*) + 148)

02 pc 0x3d4ce4 libart.so (art::JNI::NewObjectV(_JNIEnv, _jclass, _jmethodID*, std::__va_list) + 1296)

03 pc 0x3d4774 libart.so (art::JNI::NewObject(_JNIEnv, _jclass, _jmethodID*, ...) + 120)

04 pc 0x28b68 libjavacore.so (Linux_open(_JNIEnv, _jobject, _jstring*, int, int) + 336)

   at libcore.io.Linux.open(Native method)
   at libcore.io.ForwardingOs.open(ForwardingOs.java:567)
   at libcore.io.BlockGuardOs.open(BlockGuardOs.java:273)
   at libcore.io.ForwardingOs.open(ForwardingOs.java:567)
   at android.app.ActivityThread$AndroidOs.open(ActivityThread.java:8523)
   at libcore.io.IoBridge.open(IoBridge.java:561)
   at java.io.FileInputStream.<init>(FileInputStream.java:160)
   at com.jakewharton.disklrucache.DiskLruCache.get(DiskLruCache.java:422)
   at im.crisp.client.internal.a.a.j(unavailable)
   at im.crisp.client.internal.a.a.g(unavailable)
   at im.crisp.client.internal.a.a.n(unavailable)
   at im.crisp.client.internal.a.a.<init>(unavailable)
   at im.crisp.client.internal.a.a.a(unavailable)
   at im.crisp.client.Crisp.configure(unavailable)
   at fr.leocare.app.App.setupCrisp(App.kt:175)
   at fr.leocare.app.App.setupAll(App.kt:115)
   at fr.leocare.app.App.onCreate(App.kt:76)
   at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1211)
   at android.app.ActivityThread.handleBindApplication(ActivityThread.java:7506)
   at android.app.ActivityThread.access$1700(ActivityThread.java:310)
   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2281)
   at android.os.Handler.dispatchMessage(Handler.java:106)
   at android.os.Looper.loopOnce(Looper.java:226)
   at android.os.Looper.loop(Looper.java:313)
   at android.app.ActivityThread.main(ActivityThread.java:8663)
   at java.lang.reflect.Method.invoke(Native method)
   at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:567)
   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1135)

Or this one :

main (runnable): tid=1 systid=11878 at java.util.LinkedHashMap.get(LinkedHashMap.java:464) at com.jakewharton.disklrucache.DiskLruCache.get(DiskLruCache.java:407) at im.crisp.client.internal.b.a.e(SourceFile) at im.crisp.client.internal.b.a.k(SourceFile) at im.crisp.client.internal.b.a.j(SourceFile) at im.crisp.client.internal.b.a.(SourceFile) at im.crisp.client.internal.b.a.a(SourceFile) at im.crisp.client.Crisp.configure(SourceFile) at fr.leocare.app.App.setupCrisp(App.kt:173) at fr.leocare.app.App.setupAll(App.kt:113) at fr.leocare.app.App.onCreate(App.kt:74) at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1211) at android.app.ActivityThread.handleBindApplication(ActivityThread.java:7506) at android.app.ActivityThread.access$1700(ActivityThread.java:310) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2281) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loopOnce(Looper.java:226) at android.os.Looper.loop(Looper.java:313) at android.app.ActivityThread.main(ActivityThread.java:8663) at java.lang.reflect.Method.invoke(Native method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:567) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1135)

It's always when the app is launched and we call Crisp.configure. But, i guess, the session is not saved when calling Crisp.configure ? So, maybe that's not the problem ?

Doc1faux commented 1 year ago

When calling Crisp.configure for the 1st time in app lifecycle, we initiate our cache and read some data from it. Currently, it runs on MainThread but it will be updated in the near future to run Cache, WebSocket and UI in separate threads as in the app. It will fix most of the ANRs generated.

However, to better understand this issue, do you have some other I/O Exception bound to DiskLruCache or not along with this crash?

What I was asking here is do you have some calls to DiskLruCache in the stacktrace you reported firstly, whether in the thread where the crash occurs or another?

Currently, the best I could do is protect against session write failures when session is joined.

Damien-L commented 1 year ago

Hi,

Sadly, I didn't find anything about DiskLruCache in the stacktrace i reported firstly in any thread...

Doc1faux commented 1 year ago

1.0.16 fixing this crash has just been released. It can take a few hours before it will be available. I close the issue.