crisp-im/crisp-sdk-android

2.0.1beta2: app crashes when swiping down the chat screen

gekylafas opened this issue · 9 comments

In our app we open the chat screen using the following code

startActivity(Intent(context, ChatActivity::class.java))

Unfortunately, we have noticed that the app crashes if the user tries to close the chat screen (ChatActivity) not by pressing the "X" button but by swiping the chat screen down. We got two distinct stack traces, depending on whether we called the code above from a Fragment or from an Activity:

Fatal Exception: java.lang.IllegalStateException: Fragment d{c1f92c} (11a31416-37f8-4d4e-b1fe-19110436c190) has not been attached yet.
       at androidx.fragment.app.Fragment.getChildFragmentManager(Fragment.java:1142)
       at im.crisp.client.internal.v.d.f(SourceFile:1)
       at im.crisp.client.internal.v.d.b(SourceFile:3)
       at im.crisp.client.internal.v.d.d(SourceFile:3)
       at im.crisp.client.internal.v.d.a(SourceFile:3)
       at im.crisp.client.internal.v.d$d.e(SourceFile:1)
       at im.crisp.client.internal.v.d$d.$r8$lambda$f5zzx9QQEmu9lrxeSnlZRKsE2xg()
       at im.crisp.client.internal.v.d$d$$ExternalSyntheticLambda3.run(D8$$SyntheticClass)
       at android.os.Handler.handleCallback(Handler.java:959)
       at android.os.Handler.dispatchMessage(Handler.java:100)
       at android.os.Looper.loopOnce(Looper.java:232)
       at android.os.Looper.loop(Looper.java:317)
       at android.app.ActivityThread.main(ActivityThread.java:8501)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:878)

and

Fatal Exception: java.lang.IllegalArgumentException: You cannot start a load for a destroyed activity
       at com.bumptech.glide.manager.RequestManagerRetriever.assertNotDestroyed(RequestManagerRetriever.java:236)
       at com.bumptech.glide.manager.RequestManagerRetriever.get(RequestManagerRetriever.java:110)
       at com.bumptech.glide.manager.RequestManagerRetriever.get(RequestManagerRetriever.java:176)
       at com.bumptech.glide.Glide.with(Glide.java:634)
       at im.crisp.client.internal.v.k.b(SourceFile:6)
       at im.crisp.client.internal.v.k.a(SourceFile:2)
       at im.crisp.client.internal.v.k$a.b(SourceFile:1)
       at im.crisp.client.internal.v.k$a.$r8$lambda$tDEkukCqoTsvxBfaU8EYMQxQXWA()
       at im.crisp.client.internal.v.k$a$$ExternalSyntheticLambda2.run(D8$$SyntheticClass)
       at android.os.Handler.handleCallback(Handler.java:942)
       at android.os.Handler.dispatchMessage(Handler.java:99)
       at android.os.Looper.loopOnce(Looper.java:201)
       at android.os.Looper.loop(Looper.java:288)
       at android.app.ActivityThread.main(ActivityThread.java:7872)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)

Are we doing something wrong or is it a bug in the SDK?
Is there a way to disable swipe down gesture in ChatActivity?

Hi @gekylafas and thank you for your feedback.

At a first glance, you don't seem to do anything wrong.
For the moment, the swipe down gesture cannot be disable, but it could be a feature later?

Do you only updated to 2.0.1beta2? Is there any other change in your code interacting with the Crisp SDK?
From which version do you updated?

This is a strange crash because in the stacktraces you provided, it always starts with the equivalent of the Session has loaded event from the WebSocket and any following UI call is protected with a check if the fragment is still attached to its activity because both WebSocket and UI are running in separate threads, so it should never happen...

@Doc1faux Thanks for the prompt reply.

We didn't update Crisp SDK from a previous version, this is the initial addition of the SDK to our app. I tried with 2.0.0beta1 and it shows the same behavior too. Version 1.0.18 doesn't seem to support swipe down, so no crash there 🤷‍♂️ . Is that version considered OK to be used by an app or is it deprecated?

As for the crash itself, and provided there is something wrong with the SDK and not our app (which might as well be), I am willing to help you debug this (e.g. try snapshot versions etc).

So you don't reproduce it in the latest v1, interesting...
I'll be grateful for more insights on this crash as I do not reproduce it on my side, either on debug/release, minified or not and on emulator or device :/

On which device (brand, model) or emulator and on which Android version are you testing your app?
Can you provide me (here or in private), a minimal project where you reproduce it?

v1.0.18 is not deprecated but you'll miss functionalities and bug/crash fixes in very specific cases, I let you browse our releases to see for yourself if you could downgrade to it while we're fixing this crash.

Well, I can't reproduce it in v1 because this only happens on swipe down and v1 doesn't support swipe down, from what I can tell. 🤷‍♂️

I can reproduce it in both emulators and my device, for debug builds (haven't tried for release).

About a minimal project reproducing it, I will try to come up with something...