a24 bugs out when opening any deck, a23 does not. (Android 10 / API 29)
logcat:
I AnkiDroid: AbstractFlashcardViewer:: Question successfully shown for card id 1538154383446
D OnePlusJankManager: Chor uploadMDM JANK_TYPE_ONCE mViewTitle = com.ichi2.anki/com.ichi2.anki.Reviewer--- jank level = 2
I /vendor/bin/hw/[email protected]: bindService is called for service : com.ichi2.anki/org.chromium.content.app.SandboxedProcessService1:0 and for client com.ichi2.anki
I /vendor/bin/hw/[email protected]: total connections for service : com.ichi2.anki/org.chromium.content.app.SandboxedProcessService1:0are :1
I /vendor/bin/hw/[email protected]: total connections for client : com.ichi2.ankiare :3
D AndroidRuntime: Shutting down VM
I GoogleInputMethodService: GoogleInputMethodService.onFinishInput():3160
E AndroidRuntime: FATAL EXCEPTION: main
E AndroidRuntime: Process: com.ichi2.anki, PID: 31026
E AndroidRuntime: java.lang.ClassCastException: android.widget.FrameLayout cannot be cast to android.widget.LinearLayout
E AndroidRuntime: at com.ichi2.compat.CompatV19$1.onSystemUiVisibilityChange(CompatV19.java:2)
E AndroidRuntime: at android.view.View.dispatchSystemUiVisibilityChanged(View.java:25442)
E AndroidRuntime: at android.view.ViewGroup.dispatchSystemUiVisibilityChanged(ViewGroup.java:1889)
E AndroidRuntime: at android.view.ViewRootImpl.handleDispatchSystemUiVisibilityChanged(ViewRootImpl.java:7230)
E AndroidRuntime: at android.view.ViewRootImpl$ViewRootHandler.handleMessage(ViewRootImpl.java:4929)
E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:107)
E AndroidRuntime: at android.os.Looper.loop(Looper.java:214)
E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:7707)
E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
E AndroidRuntime: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:516)
E AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950)
I GoogleInputMethodService: GoogleInputMethodService.onStartInput():1829
E ACRA : ACRA caught a ClassCastException for com.ichi2.anki
E ACRA : java.lang.ClassCastException: android.widget.FrameLayout cannot be cast to android.widget.LinearLayout
E ACRA : at com.ichi2.compat.CompatV19$1.onSystemUiVisibilityChange(CompatV19.java:2)
E ACRA : at android.view.View.dispatchSystemUiVisibilityChanged(View.java:25442)
E ACRA : at android.view.ViewGroup.dispatchSystemUiVisibilityChanged(ViewGroup.java:1889)
E ACRA : at android.view.ViewRootImpl.handleDispatchSystemUiVisibilityChanged(ViewRootImpl.java:7230)
E ACRA : at android.view.ViewRootImpl$ViewRootHandler.handleMessage(ViewRootImpl.java:4929)
E ACRA : at android.os.Handler.dispatchMessage(Handler.java:107)
E ACRA : at android.os.Looper.loop(Looper.java:214)
E ACRA : at android.app.ActivityThread.main(ActivityThread.java:7707)
E ACRA : at java.lang.reflect.Method.invoke(Native Method)
E ACRA : at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:516)
E ACRA : at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950)
(Are these reports actually useful given you probably already get traces via ACRA?)
Very useful! And "oh no", thanks for logging this
@unusualstranger ? This may have just been fixed already with the last PR there #6975
Hmmmmmmm that might be a new one because I've changed previewer buttons layout view from LinearLayout to FrameLayout. I don't have any problems opening my decks from my commit though 馃 lemme test the previous ones
If it's executing the code in that stack trace, I think you'd need an API19 emulator to detect it and/or to toggle full screen mode https://github.com/ankidroid/Anki-Android/blob/master/AnkiDroid/src/main/java/com/ichi2/compat/CompatV19.java#L49
Hard type casting, ugh!
Ohhh well, that's where tests would have been useful! Lemme run an emulator
I suppose the proximate cause is that in the reviewer test, full screen UI is never toggled - none of that stuff is exercised. Still a ways to go with our test harness / coverage https://github.com/ankidroid/Anki-Android/blob/master/AnkiDroid/src/test/java/com/ichi2/anki/ReviewerTest.java
That issue is present on API 28 too, just checked it on my phone. I wonder if I should just replace it with View instead of SomethingLayout to prevent these silly bugs in the future?
If there is a valid super class, sure!
Thanks for the bug report!
When fixing this, could a commit be added to lint.gradle to make WrongViewCast break the build:
This has been tested: https://travis-ci.com/github/david-allison-1/Anki-Android/builds/181689031 and will fail the lint release step. This is the only occurrence of the error.
Lint Error
> Task :AnkiDroid:lintRelease FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':AnkiDroid:lintRelease'.
> Lint found errors in the project; aborting build.
Fix the issues identified by lint, or add the following to your build script to proceed with errors:
...
android {
lintOptions {
abortOnError false
}
}
...
Errors found:
/home/travis/build/david-allison-1/Anki-Android/AnkiDroid/src/main/java/com/ichi2/compat/CompatV19.java:49: Error: Unexpected cast to LinearLayout: layout tag was FrameLayout [WrongViewCast]
final LinearLayout answerButtons = (LinearLayout) a.findViewById(R.id.answer_options_layout);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Seeing the fix requires time, could you please push an alpha with reverts? Seeing those on the alpha channel (however few we are) can't use AnkiDroid otherwise.
(Apart from manually downgrading via pm, which is a hassle on the console only for the Playstore to again auto-update a few hours later.)
I generate parallel releases on every single build, so you can easily do a side-by-side install of whatever version you like, in case your main install is not working for you
https://github.com/ankidroid/Anki-Android/releases/tag/v2.13alpha23
You will want: https://github.com/ankidroid/Anki-Android/releases/download/v2.13alpha23/AnkiDroid-2.13alpha23.parallel.A.apk
Most helpful comment
Thanks for the bug report!
When fixing this, could a commit be added to
lint.gradleto makeWrongViewCastbreak the build:https://github.com/david-allison-1/Anki-Android/blob/b3bdb630c621048a8ef4beb7f14678c24074ca30/lint.gradle#L7
This has been tested: https://travis-ci.com/github/david-allison-1/Anki-Android/builds/181689031 and will fail the lint release step. This is the only occurrence of the error.
Lint Error