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] IllegalArgumentException crash with 0.64-rc.2 #1284

Closed
beetlebum opened this issue Dec 23, 2020 · 17 comments
Closed

[Android] IllegalArgumentException crash with 0.64-rc.2 #1284

beetlebum opened this issue Dec 23, 2020 · 17 comments

Comments

@beetlebum
Copy link

beetlebum commented Dec 23, 2020

Since upgrading to RN 0.64 we're seeing the following crash on Android:

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)

I haven't been able to reproduce the issue.
Could this be a compatibility issue with the new version of React Native?

  • React: 17.0.1
  • React Native: 0.64.rc.2
  • React Native Gesture Handler: 1.9.0
@jakub-gonet
Copy link
Member

Thanks for bringing up this issue. This is likely a compatibility issue as you mentioned.
Is this crash deterministic and happens on every startup? Could you please provide some repro repository?

@beetlebum
Copy link
Author

Thanks for bringing up this issue. This is likely a compatibility issue as you mentioned.
Is this crash deterministic and happens on every startup? Could you please provide some repro repository?

Unfortunately I can't repro it although I'm seeing it pop up quite frequently on our crash reporting tool. My guess is the app is already in some sort of closing state and a touch is registered, but I was hoping someone had experienced a similar issue and could shed some light on this.

@evelant
Copy link

evelant commented Jan 24, 2021

I had a lot of similar crashes happening in my app, not deterministic, only showed up in production crash reporting. Eventually I had to remove react-native-gesture-handler and react-native-reanimated. After that almost all crashes are gone. I think that these packages, while nice, are unfortunately pretty unstable across the broad spectrum of Android devices. I never had any crashes on iOS.

@tomasswood
Copy link

This crash happens for me when trying to scroll our date picker: https://github.com/henninghall/react-native-date-picker

@Bardiamist
Copy link

Bardiamist commented Mar 17, 2021

I have that crash on react-native-camera touch in stable React native 0.64.0. No problems in React native 0.63.4.

@rennehir
Copy link

@tomasswood we have exactly the same problem. Have you had any luck finding out why this happens? Our problems started when we were updating a lot of dependencies and have not yet figured out which one started causing the error. it had been working fine for a long time before.

If this has something to do with react-native-gesture-handler, if it helps, we updated the package from "^1.7.0" to "^1.10.3". We'll try and revert that update and see what happens.

@vilindberg
Copy link

@tomasswood @rennehir I have the same issue. Downgrading react-native-gesture-handler to 1.9.0 did not help.

@tomasswood
Copy link

@rennehir @vilindberg it happened after updating to RN-0.64.0 for me

@BrendonSled
Copy link

Also seeing this crash with react-native-camera. Tapping on the view port will cause this.

Serchinastico added a commit to Serchinastico/fourdays that referenced this issue Mar 21, 2021
However, there is a crash in release versions when clicking on the
category input while adding new food.

This is likely the reason:
software-mansion/react-native-gesture-handler#1284
@DanielMarkiel
Copy link

Hi,
I've probably noticed the same (or similar) issue but connected to @react-native-picker/picker. It occurs when I'm trying to open the picker.

  • React: 17.0.1
  • React Native: 0.64.0
  • React Native Gesture Handler: 1.10.3
  • @react-native-picker/picker: 1.12.0
  • react-native-reanimated: 2.0.0
2021-03-22 13:07:19.330 11188-11188/com.example E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.example, PID: 11188
    java.lang.IllegalArgumentException: Unable to find JSIModule for class UIManager
        at com.facebook.react.bridge.JSIModuleRegistry.getModule(JSIModuleRegistry.java:24)
        at com.facebook.react.bridge.CatalystInstanceImpl.getJSIModule(CatalystInstanceImpl.java:564)
        at com.facebook.react.uimanager.UIManagerHelper.getUIManager(UIManagerHelper.java:90)
        at com.facebook.react.uimanager.UIManagerHelper.getUIManager(UIManagerHelper.java:46)
        at com.facebook.react.uimanager.UIManagerHelper.getUIManagerForReactTag(UIManagerHelper.java:40)
        at com.facebook.react.animated.NativeAnimatedNodesManager.handleEvent(NativeAnimatedNodesManager.java:505)
        at com.facebook.react.animated.NativeAnimatedNodesManager.onEventDispatch(NativeAnimatedNodesManager.java:483)
        at com.facebook.react.uimanager.events.EventDispatcherImpl.dispatchEvent(EventDispatcherImpl.java:116)
        at com.facebook.react.uimanager.JSTouchDispatcher.handleTouchEvent(JSTouchDispatcher.java:74)
        at com.facebook.react.ReactRootView.dispatchJSTouchEvent(ReactRootView.java:283)
        at com.facebook.react.ReactRootView.onInterceptTouchEvent(ReactRootView.java:201)
        at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2609)
        at com.swmansion.gesturehandler.react.RNGestureHandlerEnabledRootView.dispatchTouchEvent(RNGestureHandlerEnabledRootView.java:39)
        at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3060)
        at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2698)
        at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3060)
        at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2698)
        at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3060)
        at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2698)
        at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3060)
        at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2698)
        at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3060)
        at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2698)
        at com.android.internal.policy.DecorView.superDispatchTouchEvent(DecorView.java:465)
        at com.android.internal.policy.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1849)
        at android.app.Activity.dispatchTouchEvent(Activity.java:3993)
        at androidx.appcompat.view.WindowCallbackWrapper.dispatchTouchEvent(WindowCallbackWrapper.java:69)
        at androidx.appcompat.view.WindowCallbackWrapper.dispatchTouchEvent(WindowCallbackWrapper.java:69)
        at com.android.internal.policy.DecorView.dispatchTouchEvent(DecorView.java:423)
        at android.view.View.dispatchPointerEvent(View.java:13674)
        at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:5482)
        at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:5285)
        at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4788)
        at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4841)
        at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4807)
        at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:4947)
        at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4815)
        at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:5004)
        at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4788)
        at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4841)
        at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4807)
        at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4815)
        at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4788)
        at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:7505)
        at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:7474)
        at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:7435)
        at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:7630)
2021-03-22 13:07:19.331 11188-11188/com.example E/AndroidRuntime:     at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:188)
        at android.os.MessageQueue.nativePollOnce(Native Method)
        at android.os.MessageQueue.next(MessageQueue.java:336)
        at android.os.Looper.loop(Looper.java:174)
        at android.app.ActivityThread.main(ActivityThread.java:7356)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)

com.swmansion.gesturehandler.react.RNGestureHandlerEnabledRootView.dispatchTouchEvent(RNGestureHandlerEnabledRootView.java:39) line points at thereturn super.dispatchTouchEvent(ev) line of the following method:

  @Override
  public boolean dispatchTouchEvent(MotionEvent ev) {
    if (mGestureRootHelper != null && mGestureRootHelper.dispatchTouchEvent(ev)) {
      return true;
    }
    return super.dispatchTouchEvent(ev);
  }

Related issue in the @react-native-picker/picker repository -> react-native-picker/picker#220

*To be honest. I'm not sure if it's something on the react-native-gesture-handler package side...

@Trex28
Copy link

Trex28 commented Mar 23, 2021

Hi,
I've have the same problem here on Android. It occurs sometimes when I'm trying to open the date picker modal and then scrolling it to change the date and then it crashed

Here are my dependencies:
React: 17.0.1
React Native: 0.64.0
React Native Gesture Handler: 1.10.3
react-native-reanimated: 2.0.0
react-native-date-picker: 3.2.10

I still wonder why this related to react-native-gesture-handler. But Android cash logs throw exactly like the logs from @DanielMarkiel
Do you guys get any solutions for this issue ?

@teamzz111
Copy link

same here wiith rncamera

@mikehardy
Copy link

I can't see how this is a gesture handler problem. Looks like gesture handler is just tickling a react-native issue based on the stack. How is gesture handler responsible for react-native's UIManagerHelper finding the JSIModule for it's own UIManager? 🤔

@DanielMarkiel
Copy link

@mikehardy Yes, that's a good point.
Moreover, I noticed that some of the pasted stacks don't have the line related to react-native-gesture-handler (I suspect they are not using it, or any related packages like react-navigation / react-native-screens) and they've got the same Unable to find JSIModule for class UIManager error.

@jakub-gonet
Copy link
Member

@mikehardy and @DanielMarkiel are right - gesture handler is showing up just because we pass event data to be handled by RN. We don't have any repro as well so I'm going to close this one. If you have strong evidence with reproduction example then feel free to open another issue.

@Bardiamist
Copy link

Bardiamist commented Mar 26, 2021

I reproduced, minimal repro here: https://github.com/Bardiamist/jsimodule

I went through many options before I figured out that crash happening on react-native-camera view port press only when PanGestureHandler exist.

@fabOnReact
Copy link

This link has video explanation of what UIManager is in React Native https://youtu.be/QwoQgzBgJu8?t=883

RNGestureHandlerEnabledRootView inherits from ReactRootView

@Override
public boolean dispatchTouchEvent(MotionEvent ev) {
if (mGestureRootHelper != null && mGestureRootHelper.dispatchTouchEvent(ev)) {
return true;
}
return super.dispatchTouchEvent(ev);
}

The android ViewGroup calls onInterceptTouchEvent a method overridden by ReactRootView

https://github.com/aosp-mirror/platform_frameworks_base/blob/1ac46f932ef88a8f96d652580d8105e361ffc842/core/java/android/view/ViewGroup.java#L2664

intercepted = onInterceptTouchEvent(ev);

https://github.com/facebook/react-native/blob/eacc94005b1b1d33d47b3bea88a6fd242560dafb/ReactAndroid/src/main/java/com/facebook/react/ReactRootView.java#L204-L207

  public boolean onInterceptTouchEvent(MotionEvent ev) {
    dispatchJSTouchEvent(ev);
    return super.onInterceptTouchEvent(ev);
  }

The error is casued by the UIManager trying to dispatch this event to JavaScript via the bridge.
The UIManager tries to retrieve the JavaScript Module responsible for handling this event, but no module is found and the consequent runtime is triggered.

https://github.com/facebook/react-native/blob/eacc94005b1b1d33d47b3bea88a6fd242560dafb/ReactAndroid/src/main/java/com/facebook/react/uimanager/JSTouchDispatcher.java#L64-L95

  /**
   * Main catalyst view is responsible for collecting and sending touch events to JS. This method
   * reacts for an incoming android native touch events ({@link MotionEvent}) and calls into {@link
   * com.facebook.react.uimanager.events.EventDispatcher} when appropriate. It uses {@link
   * com.facebook.react.uimanager.TouchTargetHelper#findTouchTargetView} helper method for figuring
   * out a react view ID in the case of ACTION_DOWN event (when the gesture starts).
   */
  public void handleTouchEvent(MotionEvent ev, EventDispatcher eventDispatcher) {
    int action = ev.getAction() & MotionEvent.ACTION_MASK;
    if (action == MotionEvent.ACTION_DOWN) {
      if (mTargetTag != -1) {
        FLog.e(
            ReactConstants.TAG, "Got DOWN touch before receiving UP or CANCEL from last gesture");
      }


      // First event for this gesture. We expect tag to be set to -1, and we use helper method
      // {@link #findTargetTagForTouch} to find react view ID that will be responsible for handling
      // this gesture
      mChildIsHandlingNativeGesture = false;
      mGestureStartTime = ev.getEventTime();


      mTargetTag = findTargetTagAndSetCoordinates(ev);
      eventDispatcher.dispatchEvent(
          TouchEvent.obtain(
              getSurfaceId(),
              mTargetTag,
              TouchEventType.START,
              ev,
              mGestureStartTime,
              mTargetCoordinates[0],
              mTargetCoordinates[1],
              mTouchEventCoalescingKeyHelper));
/**
 * Class responsible for dispatching UI events to JS. The main purpose of this class is to act as an
 * intermediary between UI code generating events and JS, making sure we don't send more events than
 * JS can process.
 *
 * <p>To use it, create a subclass of {@link Event} and call {@link #dispatchEvent(Event)} whenever
 * there's a UI event to dispatch.
 *
 * <p>This class works by installing a Choreographer frame callback on the main thread. This
 * callback then enqueues a runnable on the JS thread (if one is not already pending) that is
 * responsible for actually dispatch events to JS. This implementation depends on the properties
 * that 1) FrameCallbacks run after UI events have been processed in Choreographer.java 2) when we
 * enqueue a runnable on the JS queue thread, it won't be called until after any previously enqueued
 * JS jobs have finished processing
 **/
  /** Sends the given Event to JS, coalescing eligible events if JS is backed up. */
  public void dispatchEvent(Event event) {
    Assertions.assertCondition(event.isInitialized(), "Dispatched event hasn't been initialized");


    for (EventDispatcherListener listener : mListeners) {
      listener.onEventDispatch(event);
    }


    synchronized (mEventsStagingLock) {
      mEventStaging.add(event);
      Systrace.startAsyncFlow(
          Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, event.getEventName(), event.getUniqueID());
    }
    maybePostFrameCallbackFromNonUI();
  }

The JavaScript module is not found and triggers the above error

  public <T extends JavaScriptModule> T getJSModule(Class<T> jsInterface) {
    return mJSModuleRegistry.getJavaScriptModule(this, jsInterface);
  }

would be interesting adding some debug statements in this react native source and see the different variables when using RNGestureHandlerEnabledRootView and normal React Native without Gesture Handler, to better understand the reason for this error. Thanks 🙏 ☮

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