zhanghai / AndroidFastScroll

Fast scroll for Android RecyclerView and more
https://play.google.com/store/apps/details?id=me.zhanghai.android.fastscroll.sample
Apache License 2.0
698 stars 64 forks source link

App crash #4

Closed ghost closed 4 years ago

ghost commented 4 years ago

AndroidFastScroll version 1.0.0

My setup

FastScrollerBuilder(recyclerView)
            .setTrackDrawable(ContextCompat.getDrawable(requireContext(), R.drawable.afs_md2_track)!!)
            .setThumbDrawable(ContextCompat.getDrawable(requireContext(), R.drawable.afs_md2_thumb)!!)
            .setPopupStyle(popupStyle)
            .build()

private val popupStyle = Consumer<TextView> { popupView ->
        PopupStyles.MD2.accept(popupView)
        popupView.setTextColor(Color.WHITE)
    }

at me.zhanghai.android.fastscroll.Md2PopupBackground.getOutline(Md2PopupBackground.java:142)

Fatal Exception: java.lang.IllegalArgumentException: path must be convex at android.graphics.Outline.setConvexPath(Outline.java:284) at me.zhanghai.android.fastscroll.Md2PopupBackground.getOutline(Md2PopupBackground.java:142) at android.view.ViewOutlineProvider$1.getOutline(ViewOutlineProvider.java:38) at android.view.View.rebuildOutline(View.java:17362) at android.view.View.setBackgroundBounds(View.java:22166) at android.view.View.drawBackground(View.java:22110) at android.view.View.draw(View.java:21872) at android.view.View.updateDisplayListIfDirty(View.java:20754) at android.view.View.draw(View.java:21607) at android.view.ViewGroup.drawChild(ViewGroup.java:4558) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4333) at android.view.ViewOverlay$OverlayViewGroup.dispatchDraw(ViewOverlay.java:251) at android.view.View.draw(View.java:21896) at androidx.recyclerview.widget.RecyclerView.draw(RecyclerView.java:4429) at android.view.View.updateDisplayListIfDirty(View.java:20754) at android.view.View.draw(View.java:21607) at android.view.ViewGroup.drawChild(ViewGroup.java:4558) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4333) at android.view.View.draw(View.java:21884) at android.view.View.updateDisplayListIfDirty(View.java:20754) at android.view.View.draw(View.java:21607) at android.view.ViewGroup.drawChild(ViewGroup.java:4558) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4333) at android.view.View.draw(View.java:21884) at androidx.viewpager.widget.ViewPager.draw(ViewPager.java:2426) at android.view.View.updateDisplayListIfDirty(View.java:20754) at android.view.View.draw(View.java:21607) at android.view.ViewGroup.drawChild(ViewGroup.java:4558) at androidx.coordinatorlayout.widget.CoordinatorLayout.drawChild(CoordinatorLayout.java:1256) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4333) at android.view.View.updateDisplayListIfDirty(View.java:20740) at android.view.View.draw(View.java:21607) at android.view.ViewGroup.drawChild(ViewGroup.java:4558) at androidx.drawerlayout.widget.DrawerLayout.drawChild(DrawerLayout.java:1426) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4333) at android.view.View.draw(View.java:21884) at android.view.View.updateDisplayListIfDirty(View.java:20754) at android.view.View.draw(View.java:21607) at android.view.ViewGroup.drawChild(ViewGroup.java:4558) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4333) at android.view.View.updateDisplayListIfDirty(View.java:20740) at android.view.View.draw(View.java:21607) at android.view.ViewGroup.drawChild(ViewGroup.java:4558) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4333) at android.view.View.updateDisplayListIfDirty(View.java:20740) at android.view.View.draw(View.java:21607) at android.view.ViewGroup.drawChild(ViewGroup.java:4558) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4333) at android.view.View.updateDisplayListIfDirty(View.java:20740) at android.view.View.draw(View.java:21607) at android.view.ViewGroup.drawChild(ViewGroup.java:4558) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4333) at android.view.View.updateDisplayListIfDirty(View.java:20740) at android.view.View.draw(View.java:21607) at android.view.ViewGroup.drawChild(ViewGroup.java:4558) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4333) at android.view.View.updateDisplayListIfDirty(View.java:20740) at android.view.View.draw(View.java:21607) at android.view.ViewGroup.drawChild(ViewGroup.java:4558) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4333) at android.view.View.draw(View.java:21884) at com.android.internal.policy.DecorView.draw(DecorView.java:1082) at android.view.View.updateDisplayListIfDirty(View.java:20754) at android.view.ThreadedRenderer.updateViewTreeDisplayList(ThreadedRenderer.java:725) at android.view.ThreadedRenderer.updateRootDisplayList(ThreadedRenderer.java:731) at android.view.ThreadedRenderer.draw(ThreadedRenderer.java:840) at android.view.ViewRootImpl.draw(ViewRootImpl.java:3947) at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:3721) at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:3029) at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1888) at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:8511) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:949) at android.view.Choreographer.doCallbacks(Choreographer.java:761) at android.view.Choreographer.doFrame(Choreographer.java:696) at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:935) at android.os.Handler.handleCallback(Handler.java:873) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:214) at android.app.ActivityThread.main(ActivityThread.java:7050) at java.lang.reflect.Method.invoke(Method.java) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:965)

zhanghai commented 4 years ago

Do you know how to reproduce this? I tested it on OnePlus 5 Android P and a Q emulator, and it worked well. I'm suspecting some floating point accuracy issue but not sure, so knowing the reproduction step would help a lot.

ghost commented 4 years ago

Yesterday, I tested on Nokia 7 Plus Android 9.0, it was good too. But now, I test on Galaxy J5 Android 6.0, it crashed on both my app and your sample. You should test on Android 6.0, I think you will see this problem.

ghost commented 4 years ago

I will test help you when you release a new version. I have many real devices from Android 5.1 to 9.0. 😄

zhanghai commented 4 years ago

I tested on Android 6 emulator (notice the marshmallow icon in status bar) and it worked.

image

I suspect it would be a floating point bug that is sometimes causing this under certain DPI or screen size, because the calculation involes a sqrt(2).

One hacky way to resolve this is to just skip the shadow when we detect that the path isn't considered convex, which can only happen before Q because on Q Android allows non-convex outline. What do you think?

ghost commented 4 years ago

I think we can ignore shadow, it isn't effect to UX.

Oh, In the picture demo, popupview was showing at the center of thumb bar. this is greater than top.

zhanghai commented 4 years ago

Fixed in 1.0.2.

zhanghai commented 4 years ago

(Popup cannot move outside of the RecyclerView so it is pushed down a bit - this is expected.)