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

IllegalArgumentException crash on Android #301

Closed
Trex28 opened this issue Mar 23, 2021 · 17 comments
Closed

IllegalArgumentException crash on Android #301

Trex28 opened this issue Mar 23, 2021 · 17 comments

Comments

@Trex28
Copy link

Trex28 commented Mar 23, 2021

Describe
Since upgrading to RN 0.64 we encounter following crash on Android

The weird part here is that in our project we use react-native-gesture-handle in other components but when we scroll to change the date from DatePickerField it starts to crash on Android and the log points out crash because of react-native-gesture-handler. I am not sure that i am right if i post this issue in here but in fact there are maybe related things between DatePickerField with this crash.

Crash log:

IllegalArgumentException. Unable to find JSIModule for class UIManager

java.lang.IllegalArgumentException: 
  at com.facebook.react.bridge.JSIModuleRegistry.getModule (JSIModuleRegistry.java:39)
  at com.facebook.react.bridge.CatalystInstanceImpl.getJSIModule (CatalystInstanceImpl.java:2)
  at com.facebook.react.uimanager.UIManagerHelper.getUIManager (UIManagerHelper.java:81)
  at com.facebook.react.uimanager.UIManagerHelper.getUIManager (UIManagerHelper.java:1)
  at com.facebook.react.uimanager.UIManagerHelper.getUIManagerForReactTag (UIManagerHelper.java:4)
  at com.facebook.react.animated.NativeAnimatedNodesManager.handleEvent (NativeAnimatedNodesManager.java:17)
  at com.facebook.react.animated.NativeAnimatedNodesManager.onEventDispatch (NativeAnimatedNodesManager.java:6)
  at com.facebook.react.uimanager.events.EventDispatcherImpl.dispatchEvent (EventDispatcherImpl.java:27)
  at com.facebook.react.uimanager.JSTouchDispatcher.handleTouchEvent (JSTouchDispatcher.java:58)
  at com.facebook.react.ReactRootView.dispatchJSTouchEvent (ReactRootView.java:49)
  at com.facebook.react.ReactRootView.onInterceptTouchEvent (ReactRootView.java)
  at android.view.ViewGroup.dispatchTouchEvent (ViewGroup.java:2753)
  at com.swmansion.gesturehandler.react.RNGestureHandlerEnabledRootView.dispatchTouchEvent (RNGestureHandlerEnabledRootView.java:12)
  at android.view.ViewGroup.dispatchTransformedTouchEvent (ViewGroup.java:3222)
  at android.view.ViewGroup.dispatchTouchEvent (ViewGroup.java:2845)
  at android.view.ViewGroup.dispatchTransformedTouchEvent (ViewGroup.java:3222)
  at android.view.ViewGroup.dispatchTouchEvent (ViewGroup.java:2845)
  at android.view.ViewGroup.dispatchTransformedTouchEvent (ViewGroup.java:3222)
  at android.view.ViewGroup.dispatchTouchEvent (ViewGroup.java:2845)
  at android.view.ViewGroup.dispatchTransformedTouchEvent (ViewGroup.java:3222)
  at android.view.ViewGroup.dispatchTouchEvent (ViewGroup.java:2845)
  at android.view.ViewGroup.dispatchTransformedTouchEvent (ViewGroup.java:3222)
  at android.view.ViewGroup.dispatchTouchEvent (ViewGroup.java:2845)
  at com.android.internal.policy.DecorView.superDispatchTouchEvent (DecorView.java:697)
  at com.android.internal.policy.PhoneWindow.superDispatchTouchEvent (PhoneWindow.java:1879)
  at android.app.Activity.dispatchTouchEvent (Activity.java:3487)
  at androidx.appcompat.view.WindowCallbackWrapper.dispatchTouchEvent (WindowCallbackWrapper.java:2)
  at com.android.internal.policy.DecorView.dispatchTouchEvent (DecorView.java:655)
  at android.view.View.dispatchPointerEvent (View.java:13732)
  at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent (ViewRootImpl.java:6131)
  at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess (ViewRootImpl.java:5909)
  at android.view.ViewRootImpl$InputStage.deliver (ViewRootImpl.java:5358)
  at android.view.ViewRootImpl$InputStage.onDeliverToNext (ViewRootImpl.java:5411)
  at android.view.ViewRootImpl$InputStage.forward (ViewRootImpl.java:5377)
  at android.view.ViewRootImpl$AsyncInputStage.forward (ViewRootImpl.java:5536)
  at android.view.ViewRootImpl$InputStage.apply (ViewRootImpl.java:5385)
  at android.view.ViewRootImpl$AsyncInputStage.apply (ViewRootImpl.java:5593)
  at android.view.ViewRootImpl$InputStage.deliver (ViewRootImpl.java:5358)
  at android.view.ViewRootImpl$InputStage.onDeliverToNext (ViewRootImpl.java:5411)
  at android.view.ViewRootImpl$InputStage.forward (ViewRootImpl.java:5377)
  at android.view.ViewRootImpl$InputStage.apply (ViewRootImpl.java:5385)
  at android.view.ViewRootImpl$InputStage.deliver (ViewRootImpl.java:5358)
  at android.view.ViewRootImpl.deliverInputEvent (ViewRootImpl.java:8420)
  at android.view.ViewRootImpl.doProcessInputEvents (ViewRootImpl.java:8353)
  at android.view.ViewRootImpl.enqueueInputEvent (ViewRootImpl.java:8306)
  at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent (ViewRootImpl.java:8535)
  at android.view.InputEventReceiver.dispatchInputEvent (InputEventReceiver.java:198)
  at android.os.MessageQueue.nativePollOnce (MessageQueue.java)
  at android.os.MessageQueue.next (MessageQueue.java:326)
  at android.os.Looper.loop (Looper.java:181)
  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:494)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:965)

Smartphone

  • OS: Android
  • React Native version: 0.64.0
  • react-native-date-picker: 3.2.10
  • react-native-gesture-handler: 1.10.3
@Trex28
Copy link
Author

Trex28 commented Mar 23, 2021

Related to this issue on react-native-gesture-handler repo: software-mansion/react-native-gesture-handler#1284

@ajen010
Copy link

ajen010 commented Apr 2, 2021

Is there a workaround for this problem? My android simulator and phone crash whenever I touch the datepicker.

@henninghall
Copy link
Owner

Hi! I believe there is a naming collision. Could you help me try this out? Rename the UIManager.java and its references in this project and rebuild.

You can do it in node modules or in android studio.

@devautor
Copy link

devautor commented Apr 4, 2021

Hi! I believe there is a naming collision. Could you help me try this out? Rename the UIManager.java and its references in this project and rebuild.

You can do it in node modules or in android studio.

I am not able to resolve this using this fix. With my limited understanding, I believe this issue is closer to the RN core as being discussed here: facebook/react-native#31245

@sharifhh
Copy link

sharifhh commented Apr 7, 2021

Here is a patch-package script as a workaround for now

diff --git a/node_modules/react-native-date-picker/android/src/main/java/com/henninghall/date_picker/PickerView.java b/node_modules/react-native-date-picker/android/src/main/java/com/henninghall/date_picker/PickerView.java
index 53ee357..de0fcca 100644
--- a/node_modules/react-native-date-picker/android/src/main/java/com/henninghall/date_picker/PickerView.java
+++ b/node_modules/react-native-date-picker/android/src/main/java/com/henninghall/date_picker/PickerView.java
@@ -34,6 +34,7 @@ public class PickerView extends RelativeLayout {
         if (didUpdate(VariantProp.name)) {
             this.removeAllViewsInLayout();
             inflate(getContext(), state.derived.getRootLayout(), this);
+            findViewById(R.id.container).setId(100023);
             uiManager = new UIManager(state, this);
         }
 

@zmtmaster
Copy link

zmtmaster commented Apr 7, 2021

@sharifhh makes sense. I will take a look to see if this helps to solve the issue

This is due to an issue on React Native Core (a new function that was implemented to support FABRIC architecture).

Error is caused by views that are not directly managed by React Native. In particular, views that are not created by this method:
https://github.com/facebook/react-native/blob/master/ReactAndroid/src/main/java/com/facebook/react/uimanager/ViewManager.java#L140-L141

The Core team is trying to remove the usage of the UIManager.

Since the way React Native Core is checking if View is FABRIC or not is being used with the viewId mod 2:
https://github.com/facebook/react-native/blob/24bfa463a7f1b4eac666d038c9d0f919d0cc404f/ReactAndroid/src/main/java/com/facebook/react/uimanager/common/ViewUtil.java#L22

@henninghall
Copy link
Owner

I don't manage to reproduce this crash 🤔 Would be great if anyone could provide a code sample or explanation of how to reproduce this from an empty project.

@zmtmaster
Copy link

zmtmaster commented Apr 12, 2021

@henninghall reproduced, minimal repro here: https://github.com/zmtmaster/issue

The crash seems to be happening on only when PanGestureHandler (from react-native-gesture-handler) exist, which makes me believe its not an issue with react-native-date-picker but with react-native-gesture-handler

https://github.com/zmtmaster/issue/blob/7d0899db5641cdc6bb40d1dadf23f8b84c833843/App.tsx#L28

@gangstarmn
Copy link

I've same problems. Has anyone solved this problem?

@zmtmaster
Copy link

zmtmaster commented Apr 12, 2021

I've same problems. Has anyone solved this problem?

Working on it. Still investigating.

This isn't related to RNGH, the only reason RNGH is showing up in the error is that it passes event data back to the Android touch system here to be handled by RN.

So it is an issue with RN Core team, we probably have to wait for a fix on 0.64.1.

@zmtmaster
Copy link

Seems that there is a commit on master that should resolve the issue, should be fixed on the next version of react-native (0.65).
facebook/react-native@c317f55

@vsheyanov
Copy link

@sharifhh thanks for the workaround!
Can you explain for a person who doesn't really know the native side, why it works, are there any side effects possible that I should know of?

@psyzz
Copy link

psyzz commented May 26, 2021

@sharifhh the patch-package script doesn't work for us, we can scroll the date picker now but still crashing 4/5 times (was 5/5 before ^^)

@henninghall
Copy link
Owner

I also tried @sharifhh's solution and unfortunately still get the crash.

@ipekmuhammet
Copy link

ipekmuhammet commented Jun 7, 2021

its happening when you pull wheel diagonal on android

image

@henninghall
Copy link
Owner

This issue is fixed in react native 0.64.2 🥳

@marwane1b3
Copy link

marwane1b3 commented Aug 28, 2021

    findViewById(R.id.container).setId(100023);

this fixed my problem thank you :) @sharifhh

nitishprasadspinny added a commit to nitishprasadspinny/react-native-date-picker that referenced this issue Nov 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests