parley-messaging / android-library

Parley Android app library
MIT License
3 stars 3 forks source link

Crash: #56

Closed Rolf-Smit closed 3 weeks ago

Rolf-Smit commented 3 weeks ago

Context:

When updating for 3.7.1 to 3.9.5 when opening the Fragment in which we show the ParleyView we are greeted with the below crash.

Please note that a Fragment may not at all times be in an attached state. In our case I think this crash occurs because the visibility at first is not visible and thus removeTouchExplorationStateChangeListener is called first without addTouchExplorationStateChangeListener ever being called. This obviously means callback is null. I think that a simple check to see if the callback is null would be sufficient to fix this issue.

java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.Object.hashCode()' on a null object reference
    at androidx.core.view.accessibility.AccessibilityManagerCompat$b.hashCode(SourceFile:3)
    at android.util.ArrayMap.indexOfKey(ArrayMap.java:442)
    at android.view.accessibility.AccessibilityManager.removeTouchExplorationStateChangeListener(AccessibilityManager.java:1019)
    at androidx.core.view.accessibility.AccessibilityManagerCompat$a.b(SourceFile:6)
    at androidx.core.view.accessibility.AccessibilityManagerCompat.b(SourceFile:1)
    at util.wy.a.g(SourceFile:7)
    at nu.parley.android.view.ParleyView.onVisibilityChanged(SourceFile:72)
    at android.view.View.dispatchVisibilityChanged(View.java:16153)
    at android.view.ViewGroup.dispatchVisibilityChanged(ViewGroup.java:1620)
    at android.view.ViewGroup.dispatchVisibilityChanged(ViewGroup.java:1624)
    at android.view.ViewGroup.dispatchVisibilityChanged(ViewGroup.java:1624)
    at android.view.View.setFlags(View.java:17761)
    at android.view.View.setVisibility(View.java:12964)
    at androidx.fragment.app.x$b.n(SourceFile:111)
    at androidx.fragment.app.x.k(SourceFile:165)
    at androidx.fragment.app.FragmentManager.f0(SourceFile:386)
    at androidx.fragment.app.FragmentManager.s1(SourceFile:92)
    at androidx.fragment.app.FragmentManager.c0(SourceFile:22)
    at androidx.fragment.app.FragmentManager$f.run(SourceFile:4)
    at android.os.Handler.handleCallback(Handler.java:958)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loopOnce(Looper.java:257)
    at android.os.Looper.loop(Looper.java:368)
    at android.app.ActivityThread.main(ActivityThread.java:8826)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:572)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1049)
alexkok commented 3 weeks ago

Thanks for reporting! Agree, think the cause is the callback being null in this case yeah.

Should be fixed in 3.9.6 🚀