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.IllegalArgumentException: attempt to remove OnFrameMetricsAvailableListener that was never added #1780

Closed
8 tasks done
dmytroKarataiev opened this issue Oct 22, 2021 · 3 comments

Comments

@dmytroKarataiev
Copy link

Platform:

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

compileSdkVersion 30
targetSdkVersion 30
Device API: SM-G960U1, Android 10

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.0

Proguard/R8:

  • Enabled
  • Disabled

Platform installed with:

  • Maven Central

The version of the SDK:
5.2.4


I have the following issue:

Activity crashes onStop with the following stacktrace:

2021-10-22 16:44:22.008 16229-16229/com.fundrise.android.debugStaging E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.fundrise.android.debugStaging, PID: 16229
    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.fundrise.android.debugStaging/com.fundrise.android.scene.home.MainActivity}: java.lang.IllegalArgumentException: attempt to remove OnFrameMetricsAvailableListener that was never added
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3632)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3784)
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83)
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2270)
        at android.os.Handler.dispatchMessage(Handler.java:107)
        at android.os.Looper.loop(Looper.java:237)
        at android.app.ActivityThread.main(ActivityThread.java:8125)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:496)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1100)
     Caused by: java.lang.IllegalArgumentException: attempt to remove OnFrameMetricsAvailableListener that was never added
        at android.view.View.removeFrameMetricsListener(View.java:7766)
        at android.view.Window.removeOnFrameMetricsAvailableListener(Window.java:898)
        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:67)
        at io.sentry.android.core.ActivityLifecycleIntegration.lambda$startTracing$0$ActivityLifecycleIntegration(ActivityLifecycleIntegration.java:152)
        at io.sentry.android.core.-$$Lambda$ActivityLifecycleIntegration$OZU_BVfUTV1Z-vCLPnw148HJdoA.execute(Unknown Source: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:392)
        at android.app.Activity.dispatchActivityCreated(Activity.java:1228)
        at android.app.Activity.onCreate(Activity.java:1505)
        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.fundrise.android.base.BaseActivity.onCreate(BaseActivity.kt:69)
        at com.fundrise.android.scene.home.MainActivity.onCreate(MainActivity.kt:139)
        at android.app.Activity.performCreate(Activity.java:7957)
        at android.app.Activity.performCreate(Activity.java:7946)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1307)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3607)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3784) 
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83) 
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135) 
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2270) 
        at android.os.Handler.dispatchMessage(Handler.java:107) 
        at android.os.Looper.loop(Looper.java:237) 
        at android.app.ActivityThread.main(ActivityThread.java:8125) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:496) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1100) 

Steps to reproduce:

  • Enable Sentry Performance sampling, even when you set it to 0.0.
  • Open the app, open/pause activity, close activity, get the crash.

Actual result:

  • Stack trace is posted above.

Expected result:

  • No runtime crash.
@marandaneto
Copy link
Contributor

@dmytroKarataiev thanks for reporting.

I cannot reproduce this, can you elaborate on your Sentry SDK init configuration and the exact steps to reproduce it? maybe a minimal reproducible example would be nice too, thanks

@marandaneto
Copy link
Contributor

@dmytroKarataiev I could not reproduce as said before but the stack trace looks legit so I've added a defense mechanism #1782
I'd still be interested on reproducing this, since I don't see how frameMetricsAggregator.remove(activity) can be called before frameMetricsAggregator.add(activity)

@barry-irvine
Copy link

I was also getting this issue with a "no display" activity in the Urban Airship SDK and the fix does indeed work.

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

3 participants