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

Sentry Performance crash: Caused by java.lang.NullPointerException: Attempt to invoke virtual method 'int java.util.ArrayList.size()' on a null object reference #1798

Closed
8 tasks done
dmytroKarataiev opened this issue Nov 8, 2021 · 8 comments · Fixed by #1799
Labels
performance Performance API issues Platform: Android Type: Bug Something isn't working

Comments

@dmytroKarataiev
Copy link

dmytroKarataiev commented Nov 8, 2021

Platform:

  • Android -> If yes, which Device API (and compileSdkVersion/targetSdkVersion/Build tools) version?

compileSdkVersion 30
targetSdkVersion 30
Device API: Galaxy S8, Android 9

IDE:

  • Android Studio -> If yes, which version?
    4.3

Build system:

  • Gradle -> If yes, which version?
    7.0.1

Android Gradle Plugin:

  • Yes -> If yes, which version?
    4.2.2

Sentry Android Gradle Plugin:

  • Yes -> If yes, which version?
    2.1.5

Proguard/R8:

  • Enabled
  • Disabled

Platform installed with:

  • Maven Central

The version of the SDK:
5.3.0


I have the following issue:

Caused by java.lang.NullPointerException: Attempt to invoke virtual method 'int java.util.ArrayList.size()' on a null object reference
       at android.view.View.findFrameMetricsObserver(View.java:7279)
       at android.view.View.removeFrameMetricsListener(View.java:7250)
       at android.view.Window.removeOnFrameMetricsAvailableListener(Window.java:886)
       at androidx.core.app.FrameMetricsAggregator$FrameMetricsApi24Impl.remove(FrameMetricsAggregator.java:433)
       at androidx.core.app.FrameMetricsAggregator.remove(FrameMetricsAggregator.java:243)
       at io.sentry.android.core.ActivityFramesTracker.setMetrics(ActivityFramesTracker.java:69)
       at io.sentry.android.core.ActivityLifecycleIntegration.lambda$startTracing$0$ActivityLifecycleIntegration(ActivityLifecycleIntegration.java:152)
       at io.sentry.android.core.-$$Lambda$ActivityLifecycleIntegration$OZU_BVfUTV1Z-vCLPnw148HJdoA.execute(:4)
       at io.sentry.SentryTracer.finish(SentryTracer.java:241)
       at io.sentry.android.core.ActivityLifecycleIntegration.finishTransaction(ActivityLifecycleIntegration.java:223)
       at io.sentry.android.core.ActivityLifecycleIntegration.stopPreviousTransactions(ActivityLifecycleIntegration.java:128)
       at io.sentry.android.core.ActivityLifecycleIntegration.startTracing(ActivityLifecycleIntegration.java:135)
       at io.sentry.android.core.ActivityLifecycleIntegration.onActivityCreated(ActivityLifecycleIntegration.java:232)
       at android.app.Application.dispatchActivityCreated(Application.java:245)
       at android.app.Activity.onCreate(Activity.java:1108)
       at androidx.core.app.ComponentActivity.onCreate(ComponentActivity.java:85)
       at androidx.activity.ComponentActivity.onCreate(ComponentActivity.java:323)
       at androidx.fragment.app.FragmentActivity.onCreate(FragmentActivity.java:273)
       at com.plaid.internal.link.LinkActivity.onCreate(SourceFile:1)
       at android.app.Activity.performCreate(Activity.java:7327)
       at android.app.Activity.performCreate(Activity.java:7318)
       at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1271)
       at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3096)
       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3259)
       at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
       at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
       at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1950)
       at android.os.Handler.dispatchMessage(Handler.java:106)
       at android.os.Looper.loop(Looper.java:214)
       at android.app.ActivityThread.main(ActivityThread.java:7073)
       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:964)

Steps to reproduce:

  • Add Plaid SDK to your app, launch Platypus Oauth Account, proceed with the fake account until you get a crash.
    Could not reproduce on Android 11, but it happens 100% of the time on Android 9 (any manufacturer).

Let me know if you need more info.

Actual result:

  • Stack trace is posted above.

Expected result:

  • No runtime crash.

This is a different from this crash: #1780

@marandaneto
Copy link
Contributor

@dmytroKarataiev thanks for reporting.
what's the version of your androidx.core lib?

our SDK does call frameMetricsAggregator.remove(activity) but the crash itself happens on androidx.core and we don't have control over it.

@marandaneto marandaneto added Platform: Android performance Performance API issues labels Nov 9, 2021
@marandaneto
Copy link
Contributor

Sentry uses AndroidX.Core 1.3.2 min.
The latest Plaid SDK uses a mix of 1.1.0 and 1.3.0, not sure if the dependency resolution here fails and get a very old version maybe.
Can you try to exclude the AndroidX.Core of either the Sentry Android SDK or the Plaid SDK so we can isolate the problem?

How to do it: https://docs.sentry.io/platforms/android/performance/instrumentation/automatic-instrumentation/#androidx-support

@dmytroKarataiev
Copy link
Author

what's the version of your androidx.core lib?

1.6.0.

  1. Tried to exclude this dependency from Sentry, Plaid and both. Didn't help.
  2. Tried to force 1.6.0 for all consumers with this:
configurations.all {
    resolutionStrategy {
        force 'androidx.core:core:1.6.0'
    }
}

And confirmed that it was forced with gradle dependencies scan, but it didn't help either. The issue is still easily reproducible on any Android 9 device (including an emulator).

@marandaneto
Copy link
Contributor

@dmytroKarataiev thanks for the reply.

I've tried to reproduce using Android 9 emulator and androidx.core 1.6.0, with no success, would you mind setting up a minimal reproducible example on GH or giving me exact steps? maybe you have a custom setup in your Activity that triggers this error?

@HenryHaoson
Copy link

i have the same problem.
And I think it was the change from 5.2.4. (#1769)
The WxEnterActivity only called onCreate with out onStart
image

@HenryHaoson
Copy link

I think there are two solutions:

@marandaneto
Copy link
Contributor

thanks @HenryHaoson

I cannot add back to onActivityCreated since it would lead to the previous problem, I'm wondering tho how an activity can be called without onStart? is it even possible?

good finding with the https://android.googlesource.com/platform/frameworks/base/+/140ff5ea8e2d99edc3fbe63a43239e459334c76b bug, sounds like a good workaround, will do it.

@HenryHaoson
Copy link

the case is calling finish in onCreate

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
performance Performance API issues Platform: Android Type: Bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants