material-components / material-components-android

Modular and customizable Material Design UI components for Android
Apache License 2.0
16.37k stars 3.07k forks source link

[BottomSheetBehavior] ANR when setting state as STATE_EXPANDED #2454

Closed waseefakhtar closed 2 years ago

waseefakhtar commented 3 years ago

Description:

  at android.os.MessageQueue.enqueueMessage (MessageQueue.java:692)
  at android.os.Handler.enqueueMessage (Handler.java:769)
  at android.os.Handler.sendMessageAtTime (Handler.java:718)
  at android.view.ViewRootImpl$ViewRootHandler.sendMessageAtTime (ViewRootImpl.java:4380)
  at android.os.Handler.sendMessageDelayed (Handler.java:688)
  at android.os.Handler.post (Handler.java:405)
  at android.view.View.post (View.java:16870)
  at com.google.android.material.bottomsheet.BottomSheetBehavior.setState (BottomSheetBehavior.java:642)
  at android.os.Handler.handleCallback (Handler.java:907)
  at android.os.Handler.dispatchMessage (Handler.java:105)
  at android.os.Looper.loop (Looper.java:216)
  at android.app.ActivityThread.main (ActivityThread.java:7625)
  at java.lang.reflect.Method.invoke (Native method)
  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:524)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:987)

and

  at android.os.MessageQueue.enqueueMessage (MessageQueue.java:574)
  at android.os.Handler.enqueueMessage (Handler.java:745)
  at android.os.Handler.sendMessageAtTime (Handler.java:697)
  at android.view.ViewRootImpl$ViewRootHandler.sendMessageAtTime (ViewRootImpl.java:4795)
  at android.os.Handler.sendMessageDelayed (Handler.java:667)
  at android.os.Handler.post (Handler.java:395)
  at android.view.View.post (View.java:16955)
  at androidx.customview.widget.ViewDragHelper.continueSettling (ViewDragHelper.java:762)
  at com.google.android.material.bottomsheet.BottomSheetBehavior$SettleRunnable.run (BottomSheetBehavior.java:922)
  at android.view.Choreographer$CallbackRecord.run (Choreographer.java:1047)
  at android.view.Choreographer.doCallbacks (Choreographer.java:859)
  at android.view.Choreographer.doFrame (Choreographer.java:788)
  at android.view.Choreographer$FrameDisplayEventReceiver.run (Choreographer.java:1033)
  at android.os.Handler.handleCallback (Handler.java:873)
  at android.os.Handler.dispatchMessage (Handler.java:99)
  at android.os.Looper.loop (Looper.java:233)
  at android.app.ActivityThread.main (ActivityThread.java:7212)
  at java.lang.reflect.Method.invoke (Native method)
  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:499)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:965)

Expected behavior: Should expand BottomSheet successfully.

Source code:

class CustomBottomSheetBehaviour(context: Context, attrs: AttributeSet) : BottomSheetBehavior<View>(context, attrs) {

    private var bottomSheet: View? = null

    fun setBottomSheet(bottomSheet: View) {
        this.bottomSheet = bottomSheet
    }

    fun show() {
        if (state != STATE_EXPANDED) {
            state = STATE_EXPANDED
        }
    }
}

Android API version: Android API 27+ (Mostly on Android API 30)

Material Library version: 1.0.0

Device: Huawei Mate 10 lite, Samsung Galaxy A10s, Redmi 9A, Samsung Galaxy A21s, etc.

waseefakhtar commented 2 years ago

It's been more than a month. Any update regarding this?

josefigueroa168 commented 2 years ago

Is there a specific instance in which you are calling this show method to change the state? I am currently unable to replicate this on the pixel 4 or 5.

josefigueroa168 commented 2 years ago

Closing the issue due to no further info available, please feel free to reopen it with more details.