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

java.lang.NullPointerException Attempt to invoke interface method 'void com.facebook.react.uimanager.UIViewOperationQueue$UIOperation.execute()' on a null object reference #514

Closed
evelant opened this issue Sep 16, 2020 · 10 comments · Fixed by #1121
Assignees

Comments

@evelant
Copy link

evelant commented Sep 16, 2020

This nullPointerException only occurs when Instabug is integrated into my app. If I remove Instabug this issue goes away. This appears to be a thread safety issue where something is accessing react-natives ui operations queue from a thread other than the UI thread. There's more information in these issues:

facebook/react-native#11428
facebook/react-native#27819

This is a very severe issue for us. It crashes ~10% of all sessions which means we cannot use Instabug while this issue is ongoing. We tried a lot of things to track this one down and found out it was Instabug by trial and error.

This only happens in our release build on the play store. We have not been able to reproduce it on demand but it happens for > 10% of all user sessions.

Fatal Exception: java.lang.NullPointerException
Attempt to invoke interface method 'void com.facebook.react.uimanager.UIViewOperationQueue$UIOperation.execute()' on a null object reference
com.facebook.react.uimanager.UIViewOperationQueue$1.run (UIViewOperationQueue.java:917)
com.facebook.react.uimanager.UIViewOperationQueue.flushPendingBatches (UIViewOperationQueue.java:1028)
com.facebook.react.uimanager.UIViewOperationQueue.access$2600 (UIViewOperationQueue.java:48)
com.facebook.react.uimanager.UIViewOperationQueue$DispatchUIFrameCallback.doFrameGuarded (UIViewOperationQueue.java:1088)
com.facebook.react.uimanager.GuardedFrameCallback.doFrame (GuardedFrameCallback.java:29)
com.facebook.react.modules.core.ReactChoreographer$ReactChoreographerDispatcher.doFrame (ReactChoreographer.java:175)
com.facebook.react.modules.core.ChoreographerCompat$FrameCallback$1.doFrame (ChoreographerCompat.java:85)
android.view.Choreographer$CallbackRecord.run (Choreographer.java:1055)
android.view.Choreographer.doCallbacks (Choreographer.java:875)
android.view.Choreographer.doFrame (Choreographer.java:772)
android.view.Choreographer$FrameDisplayEventReceiver.run (Choreographer.java:1042)
android.os.Handler.handleCallback (Handler.java:900)
android.os.Handler.dispatchMessage (Handler.java:103)
android.os.Looper.loop (Looper.java:219)
android.app.ActivityThread.main (ActivityThread.java:8347)
java.lang.reflect.Method.invoke (Method.java)
com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:513)
com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1055)

Steps to Reproduce the Problem

Run a release build of a RN 0.63.2 app with Instabug on Android

Expected Behavior

App should not crash

Actual Behavior

App crashes randomly with the above exception for >10% of sessions. If we remove Instabug our app is 100% crash free.

Instabug integration code

package.json
"instabug-reactnative": "^9.1.7",

MainApplication.java

import com.instabug.reactlibrary.RNInstabugReactnativePackage;
.....


  @Override
  public void onCreate() {
        .....

    new RNInstabugReactnativePackage.Builder("MY_TOKEN", MainApplication.this)
        .setInvocationEvent("shake")

        .setInvocationEvent("button").setPrimaryColor("#1D82DC").setFloatingEdge("right")
        .setFloatingButtonOffsetFromTop(500)
        .build();
    super.onCreate();
      .....
  }

App js code

  Instabug.startWithToken("MY_TOKEN", [Instabug.invocationEvent.shake])

        if (Platform.OS == "ios") {
            //only call this on ios, on android it results in two buttons
            let instabug_button_position = 0.55 * height
            Instabug.setFloatingButtonEdge(Instabug.floatingButtonEdge.right, instabug_button_position)
        }

        BugReporting.setAutoScreenRecordingEnabled(false)

SDK Version

9.1.7 react native

React Native, iOS and Android Versions

RN 0.63.2

Device Model

Any Android device

[Optional] Project That Reproduces the Issue

Unable to reproduce on demand. Only happens in release build on play store where it appears to happen at random.

@evelant
Copy link
Author

evelant commented Sep 17, 2020

I have confirmed that this issue still happens with Instabug build https://github.com/Instabug/Instabug-React-Native\#snapshot-android/9.1.7.1-INSD-4445 from Instabug/Instabug-Android#333. My build without Instabug still does not throw this error.

@AliAbdelfattah
Copy link
Contributor

@AndrewMorsillo just so we're on the same page, the snapshot you mentioned wasn't targeted to address the issue in here.

@AliAbdelfattah
Copy link
Contributor

@AndrewMorsillo we're currently looking into the crashes you've submitted, and we'll update you once we reach any conclusions. Appreciate your patience 🙏

@evelant
Copy link
Author

evelant commented Sep 17, 2020

@AliAbdelfattah Yep, thanks for the clarification, I assumed that update wouldn't help with this issue but I wanted to make sure you had exact information about what builds I've reproduced the issue with.

I hope we can get this figured out quickly, we're seeing about 17% of end user sessions crashing with Instabug enabled and 0% without Instabug... but Instabug is so useful and critical to our beta testing we can't start without it! Please let me know if I can do anything or provide any more information to help you debug. Thanks!

@evelant
Copy link
Author

evelant commented Sep 23, 2020

@AliAbdelfattah I made a new build where I removed all calls to Instabug.setPrivateView and I haven't seen this issue since. This crash previously always appeared within hours of a new build (it was our most common crash). There were no other changes in that build. I'm almost 100% certain now that this crash is caused by Instabug.setPrivateView on react-native.

@evelant
Copy link
Author

evelant commented Sep 30, 2020

Hi @AliAbdelfattah just following up, I still haven't seen this crash since I disabled Instabug.setPrivateView. It seems fairly certain there's a bug in the Instabug SDK there.

@AliAbdelfattah
Copy link
Contributor

@AndrewMorsillo I've created a snapshot that has a defensive code specifically for Instabug.setPrivateView API. Since we can't reproduce the issue on our end, could you please give it a try and let us know how it goes?
npm install --save https://github.com/Instabug/Instabug-React-Native#snapshot/9.1.8-hide-view-defensive

@evelant
Copy link
Author

evelant commented Oct 14, 2020

@AliAbdelfattah I upgraded to that build and re-enabled setPrivateView. The crashes came back right away exactly as before, no improvement, it's definitely setPrivateView causing this crash. I don't know if you got a chance to review these two issues but they had some potentially useful clues:

facebook/react-native#11428
facebook/react-native#27819

@sfuqua
Copy link

sfuqua commented Mar 23, 2021

Possible culprit: setPrivateView via JS will call the Java hideView method, which then mutates the React UI operation queue:

See RNInstabugReactnativeModule.java:

UIManagerModule uiManagerModule = getReactApplicationContext().getNativeModule(UIManagerModule.class);
uiManagerModule.prependUIBlock(new UIBlock() {

@AliAbdelfattah
Copy link
Contributor

Closing this as we're not able to reproduce and the stack trace doesn't have any references to Instabug.

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

Successfully merging a pull request may close this issue.

3 participants