Status Update
Comments
ki...@google.com <ki...@google.com> #2
1. Have you saw crash in real device or only in simulators?
2. Do you use dynamic feature for language ID?
ap...@google.com <ap...@google.com> #3
Tested on Android 12 Emulator with custom executor, but cannot repro this issue.
il...@google.com <il...@google.com> #4
-
Second crash in the description is from a real device. Experienced it myself on two different Xiaomi phones, plus lots of crashes from users in the Google Play console.
-
Dynamic features are not used in the application.
As a wild guess, I have downgraded build tools from 31.0.0 to 30.0.3, compileSdk from 31 to 30, and moved all work with Language ID to the service in a separate process (just to be sure that crash can kill secondary process instead of main). This combination is in beta for 2 days by now and I don't see any SIGSEGV crashes.
ap...@google.com <ap...@google.com> #5
Hmm, I feel the crash might be something related to separate/secondary process.
I also changed compileSdk and targetSDK to 31 but still cannot repro this issue.
Description
1. Add a menu to the activity
2. Override the onMenuOpened callback
3. Tap the overflow menu
Notice that callback was invoked with the null menu, despite the signature having a NonNull annotation
Kotlin apps might get a crash if they treated the platform type as non-null or a type-mismatch warning if the menu argument is declared as nullable and super.onMenuOpened is invoked.
10-17 10:37:16.152 E/AndroidRuntime( 843): Process: some.package, PID: 843
10-17 10:37:16.152 E/AndroidRuntime( 843): java.lang.IllegalArgumentException: Parameter specified as non-null is null: method kotlin.jvm.internal.Intrinsics.checkParameterIsNotNull, parameter menu
10-17 10:37:16.152 E/AndroidRuntime( 843): at some.activity.onMenuOpened(Unknown Source:2)
10-17 10:37:16.152 E/AndroidRuntime( 843): at androidx.appcompat.view.WindowCallbackWrapper.onMenuOpened(WindowCallbackWrapper.java:104)
10-17 10:37:16.152 E/AndroidRuntime( 843): at androidx.appcompat.app.AppCompatDelegateImpl$AppCompatWindowCallback.onMenuOpened(AppCompatDelegateImpl.java:2868)
10-17 10:37:16.152 E/AndroidRuntime( 843): at androidx.appcompat.view.WindowCallbackWrapper.onMenuOpened(WindowCallbackWrapper.java:104)
10-17 10:37:16.152 E/AndroidRuntime( 843): at androidx.appcompat.app.ToolbarActionBar$ActionMenuPresenterCallback.onOpenSubMenu(ToolbarActionBar.java:560)
10-17 10:37:16.152 E/AndroidRuntime( 843): at androidx.appcompat.view.menu.BaseMenuPresenter.onSubMenuSelected(BaseMenuPresenter.java:221)
10-17 10:37:16.152 E/AndroidRuntime( 843): at androidx.appcompat.widget.ActionMenuPresenter.showOverflowMenu(ActionMenuPresenter.java:345)
10-17 10:37:16.152 E/AndroidRuntime( 843): at androidx.appcompat.widget.ActionMenuPresenter$OverflowMenuButton.performClick(ActionMenuPresenter.java:681)
10-17 10:37:16.152 E/AndroidRuntime( 843): at android.view.View.performClickInternal(View.java:6574)
10-17 10:37:16.152 E/AndroidRuntime( 843): at android.view.View.access$3100(View.java:778)
10-17 10:37:16.152 E/AndroidRuntime( 843): at android.view.View$PerformClick.run(View.java:25885)
10-17 10:37:16.152 E/AndroidRuntime( 843): at android.os.Handler.handleCallback(Handler.java:873)
10-17 10:37:16.152 E/AndroidRuntime( 843): at android.os.Handler.dispatchMessage(Handler.java:99)
10-17 10:37:16.152 E/AndroidRuntime( 843): at android.os.Looper.loop(Looper.java:193)
10-17 10:37:16.152 E/AndroidRuntime( 843): at android.app.ActivityThread.main(ActivityThread.java:6669)
10-17 10:37:16.152 E/AndroidRuntime( 843): at java.lang.reflect.Method.invoke(Native Method)
10-17 10:37:16.152 E/AndroidRuntime( 843): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
10-17 10:37:16.152 E/AndroidRuntime( 843): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Upon investigation it appears the ActionMenuPresenter invokes the callback with the null menu to indicate that the menu is opening:
// ActionMenuPresenter uses null as a callback argument here
// to indicate overflow is opening.
super.onSubMenuSelected(null);