smartlook / smartlook-android-sdk

5 stars 1 forks source link

LeakCanary menu crash #21

Closed Pitel closed 5 years ago

Pitel commented 5 years ago

Using version 1.0.0 of your SDK

We have LeakCanary 2.0 in our app, and sometimes (not always), when we click on the menu in LeakCanary's activity, the app crashes in your code.

2019-07-19 16:20:59.296 29270-29270 E/AndroidRuntime: FATAL EXCEPTION: main
    Process: cz.masterapp.annie2, PID: 29270
    java.lang.IllegalArgumentException: Parameter specified as non-null is null: method kotlin.jvm.internal.Intrinsics.checkParameterIsNotNull, parameter menu
        at com.smartlook.sdk.smartlook.analytics.c.g.b.a.onMenuOpened(Unknown Source:2)
        at com.android.internal.policy.PhoneWindow$ActionMenuPresenterCallback.onOpenSubMenu(PhoneWindow.java:2276)
        at com.android.internal.view.menu.BaseMenuPresenter.onSubMenuSelected(BaseMenuPresenter.java:211)
        at android.widget.ActionMenuPresenter.showOverflowMenu(ActionMenuPresenter.java:558)
        at android.widget.ActionMenuPresenter$OverflowMenuButton.performClick(ActionMenuPresenter.java:887)
        at android.view.View$PerformClick.run(View.java:24770)
        at android.os.Handler.handleCallback(Handler.java:790)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:164)
        at android.app.ActivityThread.main(ActivityThread.java:6494)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:440)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
SenNeonoveNoci commented 5 years ago

@Pitel

This one is tricky. The SDK crashes on this Window.Callback callback method:

public abstract boolean onMenuOpened (int featureId, Menu menu)

The documentation for this method says:

Menu: The menu that is opened. This value must never be null.

But LeakCanary 2.0 is apparently setting it to null. Our SDK is in correlation with official documentation. Not sure if we should fix this "error".

We are going to discous it internally and will let you know.

SenNeonoveNoci commented 5 years ago

Ok, we gonna fix it. look forward to next minor release.

Pitel commented 5 years ago

Well, it's FOSS, you can see their code here (in the activity and navigation) packages.

On first sight, I didn't noticed anything unusual, except they are generating the menu in code, using some Kotlin lambdas.