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] NullPointerException - java.util.ArrayDeque.addLast from com.swmansion.reanimated.NodesManager.startUpdatingOnAnimationFrame

See original GitHub issue

Hi there,

We started seeing this error when we upgraded another library which in turn required an upgrade to Reanimated from 1.0.0 to 1.4.0:

java.lang.NullPointerException
    ArrayDeque.java:228 java.util.ArrayDeque.addLast
    ReactChoreographer:91 com.facebook.react.modules.core.ReactChoreographer.postFrameCallback
    NodesManager:130 com.swmansion.reanimated.NodesManager.startUpdatingOnAnimationFrame
    NodesManager:382 com.swmansion.reanimated.NodesManager.onEventDispatch
    EventDispatcher:113 com.facebook.react.uimanager.events.EventDispatcher.dispatchEvent
    UIImplementation:919 com.facebook.react.uimanager.UIImplementation.applyUpdatesRecursive
...
    UIImplementation:904 com.facebook.react.uimanager.UIImplementation.applyUpdatesRecursive
    UIImplementation:644 com.facebook.react.uimanager.UIImplementation.updateViewHierarchy
    UIImplementation:599 com.facebook.react.uimanager.UIImplementation.dispatchViewUpdates
    UIManagerModule:782 com.facebook.react.uimanager.UIManagerModule.onBatchComplete
    NativeModuleRegistry:118 com.facebook.react.bridge.NativeModuleRegistry.onBatchComplete
    CatalystInstanceImpl:164 com.facebook.react.bridge.CatalystInstanceImpl$BridgeCallback.onBatchComplete
    SourceFile:-2 com.facebook.react.bridge.queue.NativeRunnable.run
    Handler.java:789 android.os.Handler.handleCallback
    Handler.java:98 android.os.Handler.dispatchMessage
    MessageQueueThreadHandler:26 com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage
    Looper.java:164 android.os.Looper.loop
    MessageQueueThreadImpl:225 com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run
    Thread.java:764 java.lang.Thread.run

This implies that NodesManager’s mChoreographerCallback is null, which doesn’t make sense since it gets initialized in the constructor.

Since other issues have mentioned that 1.7.0 has fixes for other NPEs, we tried upgrading to 1.7.0, but that hasn’t helped. I’m still investigating, but am wondering if others have seen this problem or know a workaround?

Thanks!

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:11 (2 by maintainers)

github_iconTop GitHub Comments

7reactions
smacgregorcommented, Jul 18, 2020

We’ve temporarily used patch-package to cover it up in node_modules/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/NodesManager.java

   private void startUpdatingOnAnimationFrame() {
     if (!mCallbackPosted.getAndSet(true)) {
-      mReactChoreographer.postFrameCallback(
-              ReactChoreographer.CallbackType.NATIVE_ANIMATED_MODULE,
-              mChoreographerCallback);
+      // attempt to suppress NPE spike described in: 
+      // https://github.com/software-mansion/react-native-reanimated/issues/604
+      if (mChoreographerCallback != null) {
+        mReactChoreographer.postFrameCallback(
+                ReactChoreographer.CallbackType.NATIVE_ANIMATED_MODULE,
+                mChoreographerCallback);
+      }
     }
   }

This ‘fixed it’ and surprisingly the crash didn’t move elsewhere.

1reaction
CharlieJ213commented, Mar 1, 2022

Hello. I am using the JitsiMeetSDK which has this as a dependency: Gradle: com.facebook.react:react-native-reanimated:1.13.3-jitsi-9316999@aar

Running it with React-Native version 0.67.1, the app keeps crashing with this error every time the activity launches on Android:

E/JitsiMeetSDK: JitsiMeetUncaughtExceptionHandler FATAL ERROR
    java.lang.IncompatibleClassChangeError: Found interface com.facebook.react.uimanager.events.EventDispatcher, but class was expected (declaration of 'com.facebook.react.uimanager.events.EventDispatcher' appears in /data/app/~~W8jlH1sETpdxE6DCzcBEeQ==/com.jitsitesting-KiRtJu2u391XcJtskkaV8w==/base.apk!classes10.dex)
        at com.swmansion.reanimated.NodesManager.<init>(NodesManager.java:116)
        at com.swmansion.reanimated.ReanimatedModule.getNodesManager(ReanimatedModule.java:95)
        at com.swmansion.reanimated.ReanimatedModule.access$000(ReanimatedModule.java:24)
        at com.swmansion.reanimated.ReanimatedModule$1.execute(ReanimatedModule.java:80)
        at com.facebook.react.uimanager.UIViewOperationQueue$UIBlockOperation.execute(UIViewOperationQueue.java:579)
        at com.facebook.react.uimanager.UIViewOperationQueue$1.run(UIViewOperationQueue.java:915)
        at com.facebook.react.uimanager.UIViewOperationQueue.flushPendingBatches(UIViewOperationQueue.java:1026)
        at com.facebook.react.uimanager.UIViewOperationQueue.access$2600(UIViewOperationQueue.java:47)
        at com.facebook.react.uimanager.UIViewOperationQueue$DispatchUIFrameCallback.doFrameGuarded(UIViewOperationQueue.java:1086)
        at com.facebook.react.uimanager.GuardedFrameCallback.doFrame(GuardedFrameCallback.java:29)
        at com.facebook.react.modules.core.ReactChoreographer$ReactChoreographerDispatcher.doFrame(ReactChoreographer.java:175)
        at com.facebook.react.modules.core.ChoreographerCompat$FrameCallback$1.doFrame(ChoreographerCompat.java:85)
        at android.view.Choreographer$CallbackRecord.run(Choreographer.java:970)
        at android.view.Choreographer.doCallbacks(Choreographer.java:796)
        at android.view.Choreographer.doFrame(Choreographer.java:727)
        at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:957)
        at android.os.Handler.handleCallback(Handler.java:938)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:223)
        at android.app.ActivityThread.main(ActivityThread.java:7656)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)

Will also ask in the Jitsi Meet repo

Read more comments on GitHub >

github_iconTop Results From Across the Web

NullPointerException encountered when adding objects to ...
Anyway, when executing the addRoom() method providing an integer as a parameter, the ArrayDeque throws a NullPointerException on line 14 where I ...
Read more >
525350 – NullPointerException in ArrayDeque.addFirst ... - Bugs
Error while parsing /llvm/lib/Target/X86/X86MacroFusion.cpp. java.lang.NullPointerException at java.util.ArrayDeque.
Read more >
2020年12月_weixin_39963341的博客
[Android] NullPointerException - java.util.ArrayDeque.addLast from com.swmansion.reanimated.NodesManager.startUpdatingOnAnimationFrame. 2021-01-10 ...
Read more >
如何解决android中的java.lang.nullpointerexception, 如何处理 ...
[Android] NullPointerException - java.util.ArrayDeque.addLast 来自com. swmansion.reanimated.NodesManager.startUpdatingOnAnimationFrame #604。关闭.
Read more >
NullPointerException
java.util.concurrent.atomic ... NullPointerException; NullPointerException ... NullPointerException objects may be constructed by the virtual machine as if ...
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