Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash on an null object reference in showAlignBottom (Balloon.java:2557) #280

Closed
DevHugo opened this issue Nov 17, 2021 · 3 comments
Closed
Assignees
Labels
Released Released already on the latest version.

Comments

@DevHugo
Copy link

DevHugo commented Nov 17, 2021

Please complete the following information:

  • Library Version [e.g. v1.0.0] : 1.4.0
  • Affected Device(s) : Not relevant but all manufacturer: Motorola ( moto g(8) power lite, g6, G5S), Samsung (Galaxy S10+, Galaxy J5 Prime), Xiaomi, Huawei, ... . Android 8 to Android 11.

Describe the Bug:

First, I just wanted to say a big thank you for your work.

It not something that happen often like less than one hundred crash per day. So we are searching something edge case here.

Fatal Exception: java.lang.NullPointerException: Attempt to read from field 'int android.view.ViewGroup$LayoutParams.width' on a null object reference
       at android.widget.PopupWindow.alignToAnchor(PopupWindow.java:2680)
       at android.widget.PopupWindow.access$000(PopupWindow.java:114)
       at android.widget.PopupWindow$1.onViewAttachedToWindow(PopupWindow.java:258)
       at android.view.View.dispatchAttachedToWindow(View.java:19867)
       at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3597)
       at android.view.ViewGroup.addViewInner(ViewGroup.java:5370)
       at android.view.ViewGroup.addView(ViewGroup.java:5156)
       at android.view.ViewGroup.addView(ViewGroup.java:5096)
       at androidx.recyclerview.widget.RecyclerView$5.addView(RecyclerView.java:856)
       at androidx.recyclerview.widget.ChildHelper.addView(ChildHelper.java:107)
       at androidx.recyclerview.widget.RecyclerView$LayoutManager.addViewInt(RecyclerView.java:8601)
       at androidx.recyclerview.widget.RecyclerView$LayoutManager.addView(RecyclerView.java:8559)
       at androidx.recyclerview.widget.RecyclerView$LayoutManager.addView(RecyclerView.java:8547)
       at androidx.recyclerview.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1641)
       at androidx.recyclerview.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1587)
       at androidx.recyclerview.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:665)
       at androidx.recyclerview.widget.RecyclerView.dispatchLayoutStep2(RecyclerView.java:4134)
       at androidx.recyclerview.widget.RecyclerView.dispatchLayout(RecyclerView.java:3851)
       at androidx.recyclerview.widget.RecyclerView.consumePendingUpdateOperations(RecyclerView.java:1867)
       at androidx.recyclerview.widget.RecyclerView.scrollByInternal(RecyclerView.java:1936)
       at androidx.recyclerview.widget.RecyclerView.scrollBy(RecyclerView.java:1812)
       at androidx.recyclerview.widget.RecyclerView$LayoutManager.requestChildRectangleOnScreen(RecyclerView.java:9913)
       at androidx.recyclerview.widget.RecyclerView$LayoutManager.requestChildRectangleOnScreen(RecyclerView.java:9886)
       at androidx.recyclerview.widget.RecyclerView.requestChildRectangleOnScreen(RecyclerView.java:2938)
       at android.view.View.requestRectangleOnScreen(View.java:7748)
       at android.widget.PopupWindow.findDropDownPosition(PopupWindow.java:1883)
       at android.widget.PopupWindow.showAsDropDown(PopupWindow.java:1458)
       at android.widget.PopupWindow.showAsDropDown(PopupWindow.java:1420)
       at com.skydoves.balloon.Balloon$showAlignBottom$$inlined$show$1.run(Balloon.java:2557)
       at android.os.Handler.handleCallback(Handler.java:900)
       at android.os.Handler.dispatchMessage(Handler.java:103)
       at android.os.Looper.loop(Looper.java:219)
       at android.app.ActivityThread.main(ActivityThread.java:8393)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:513)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1055)

Hypothesis: the stacktrace seems to show that in the method showAlignBottom, the show callback is called. This callback is called after anchor.post method. I was asking myself, the check of !isShowing && !destroyed && !context.isFinishing && bodyWindow.contentView.parent == null && ViewCompat.isAttachedToWindow(anchor) should be inside the anchor.post method or just before calling the callback.
I don't know the code base and I would really appreciate your insight :)

Expected Behavior:

Not crash :P

@skydoves
Copy link
Owner

Hey @DevHugo, I'm sorry for replying late.
It's released a new snapshot 1.4.1-SNAPSHOT, would you please build with this version?
Thanks for reporting this issue!

@DevHugo
Copy link
Author

DevHugo commented Nov 29, 2021

Thanks !

Since we can not reproduce it easily, I just merged the pr with the updated version of the lib. I will keep you inform if it has fixed the issue when we release a new version in a few days in production :)

@skydoves skydoves added the Release Next This feature will be released on next version label Dec 2, 2021
@skydoves skydoves self-assigned this Dec 2, 2021
@skydoves
Copy link
Owner

skydoves commented Dec 9, 2021

Hey @DevHugo,
Do you have any news? 😄

@skydoves skydoves added Released Released already on the latest version. and removed Release Next This feature will be released on next version labels Dec 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Released Released already on the latest version.
Projects
None yet
Development

No branches or pull requests

2 participants