question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Android] IllegalArgumentException crash with 0.64-rc.2

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:5
  • Comments:17 (2 by maintainers)

github_iconTop GitHub Comments

8reactions
tomasswoodcommented, Mar 17, 2021

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

5reactions
fabriziobertoglio1987commented, Mar 26, 2021

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

RNGestureHandlerEnabledRootView inherits from ReactRootView

https://github.com/software-mansion/react-native-gesture-handler/blob/4d598c173587ba1f080a1de106c5d798fbbf59aa/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerEnabledRootView.java#L34-L40

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 🙏 ☮

Read more comments on GitHub >

github_iconTop Results From Across the Web

Wrong state class if the app was background for a period of ...
Android IllegalArgumentException : Wrong state class if the app was background for a period of time ... It looks like due to the...
Read more >
Android 12 crash
Hello support team, We have recently migrated to Android 12 and started getting crashes pointing to your library.
Read more >
IllegalArgumentException
IllegalArgumentException ; IllegalArgumentException; IllegalArgumentException ... Constructs an IllegalArgumentException with no detail message.
Read more >
java.lang.IllegalArgumentException: ChunkNibbleArrays ...
If your server is crashing with the error java.lang.IllegalArgumentException: ChunkNibbleArrays should be 2048 bytes not: 0 , it means that your world is ......
Read more >
[Android S] java.lang.IllegalArgumentException [194108978]
On the 'App launch' retrieved the crash (everywhere in the app applied FLAG_IMMUTABLE or FLAG_MUTABLE to the using PendingIntents): java.lang.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found