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

android crash when update sheetAllowedDetents using setOptions #12374

Open
1 of 12 tasks
debugtheworldbot opened this issue Jan 6, 2025 · 3 comments
Open
1 of 12 tasks

Comments

@debugtheworldbot
Copy link

Current behavior

I'm updating a modal's detent when the content height change, something like:

  useEffect(() => {
      navigation.setOptions({
        sheetAllowedDetents: needExpand ? [1] : [0.5, 1]
      })
  }, [navigation, needExpand])

it works fine on ios, but on android, when I scroll the page to change the detents, the app crashed.

I'm using expo 52

here is the error:

Your app just crashed. See the error below.
java.lang.IllegalArgumentException: [RNScreens] Invalid state 4 for detentCount 1
  com.swmansion.rnscreens.bottomsheet.SheetUtils.detentIndexFromSheetState(SheetUtils.kt:87)
  com.swmansion.rnscreens.ScreenStackFragment$bottomSheetStateCallback$1.onStateChanged(ScreenStackFragment.kt:170)
  com.google.android.material.bottomsheet.BottomSheetBehavior.setStateInternal(BottomSheetBehavior.java:1305)
  com.google.android.material.bottomsheet.BottomSheetBehavior$4.onViewDragStateChanged(BottomSheetBehavior.java:1624)
  androidx.customview.widget.ViewDragHelper.setDragState(ViewDragHelper.java:920)
  androidx.customview.widget.ViewDragHelper.captureChildView(ViewDragHelper.java:508)
  androidx.customview.widget.ViewDragHelper.tryCaptureViewForDrag(ViewDragHelper.java:943)
  androidx.customview.widget.ViewDragHelper.shouldInterceptTouchEvent(ViewDragHelper.java:1095)
  com.google.android.material.bottomsheet.BottomSheetBehavior.onInterceptTouchEvent(BottomSheetBehavior.java:623)
  androidx.coordinatorlayout.widget.CoordinatorLayout.performEvent(CoordinatorLayout.java:548)
  androidx.coordinatorlayout.widget.CoordinatorLayout.performIntercept(CoordinatorLayout.java:503)
  androidx.coordinatorlayout.widget.CoordinatorLayout.onInterceptTouchEvent(CoordinatorLayout.java:570)
  android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2653)
  android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3121)
  android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2802)
  android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3121)
  android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2802)
  android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3121)
  android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2802)
  android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3121)
  android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2802)
  android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3121)
  android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2802)
  android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3121)
  android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2802)
  android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3121)
  android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2802)
  android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3121)
  android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2802)
  android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3121)
  android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2802)
  android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3121)
  android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2802)
  android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3121)
  android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2802)
  expo.modules.devmenu.DevMenuReactRootViewContainer.dispatchTouchEvent(DevMenuReactRootViewContainer.kt:52)
  android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3121)
  android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2802)
  android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3121)
  android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2802)
  android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3121)
  android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2802)
  android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3121)
  android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2802)
  android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3121)
  android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2802)
  com.android.internal.policy.DecorView.superDispatchTouchEvent(DecorView.java:500)
  com.android.internal.policy.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1905)
  android.app.Activity.dispatchTouchEvent(Activity.java:4263)
  androidx.appcompat.view.WindowCallbackWrapper.dispatchTouchEvent(WindowCallbackWrapper.java:69)
  com.android.internal.policy.DecorView.dispatchTouchEvent(DecorView.java:458)
  android.view.View.dispatchPointerEvent(View.java:15262)
  android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:6654)
  android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:6454)
  android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:5910)
  android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:5967)
  android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:5933)
  android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:6098)
  android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:5941)
  android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:6155)
  android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:5914)
  android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:5967)
  android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:5933)
  android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:5941)
  android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:5914)
  android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:8996)
  android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:8947)
  android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:8916)
  android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:9119)
  android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:267)
  android.view.InputEventReceiver.nativeConsumeBatchedInputEvents(Native Method)
  android.view.InputEventReceiver.consumeBatchedInputEvents(InputEventReceiver.java:247)
  android.view.ViewRootImpl.doConsumeBatchedInput(ViewRootImpl.java:9076)
  android.view.ViewRootImpl$ConsumeBatchedInputRunnable.run(ViewRootImpl.java:9210)
  android.view.Choreographer$CallbackRecord.run(Choreographer.java:1231)
  android.view.Choreographer$CallbackRecord.run(Choreographer.java:1239)
  android.view.Choreographer.doCallbacks(Choreographer.java:899)
  android.view.Choreographer.doFrame(Choreographer.java:824)
  android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1214)
  android.os.Handler.handleCallback(Handler.java:942)
  android.os.Handler.dispatchMessage(Handler.java:99)
  android.os.Looper.loopOnce(Looper.java:201)
  android.os.Looper.loop(Looper.java:288)
  android.app.ActivityThread.main(ActivityThread.java:7872)
  java.lang.reflect.Method.invoke(Native Method)
  com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
  com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)

Expected behavior

Works fine like ios

Reproduction

https://snack.expo.dev/@ppzzzzzzzzzzzz/android-decent-crash

Platform

  • Android
  • iOS
  • Web
  • Windows
  • MacOS

Packages

  • @react-navigation/bottom-tabs
  • @react-navigation/drawer
  • @react-navigation/material-top-tabs
  • @react-navigation/stack
  • @react-navigation/native-stack
  • react-native-drawer-layout
  • react-native-tab-view

Environment

  • [*] I've removed the packages that I don't use
package version
@react-navigation/native ^7.0.1
react-native-screens ^4.1.0
react-native-safe-area-context 4.12.0
react-native-gesture-handler ~2.20.2
react-native-reanimated ~3.16.1
react-native 0.76.2
expo ~52.0.7
node v20.16.0
npm or yarn npm
Copy link

github-actions bot commented Jan 6, 2025

The versions mentioned in the issue for the following packages differ from the latest versions on npm:

  • @react-navigation/native (found: 7.0.1, latest: 7.0.14)

Can you verify that the issue still exists after upgrading to the latest versions of these packages?

@debugtheworldbot
Copy link
Author

yes, still have this issue at 7.0.14

Copy link

github-actions bot commented Jan 6, 2025

Hey! Thanks for opening the issue. Seems that this issue is related to react-native-screens library which is a dependency of React Navigation. Can you also post your issue in this repo so that it's notified to the maintainers of that library? This will help us fix the issue faster since it's upto the maintainers of that library to investigate it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants