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

fix: stop reporting storage access exceptions to acrarium #17470

Merged

Conversation

mikehardy
Copy link
Member

@mikehardy mikehardy commented Nov 21, 2024

Purpose / Description

these no longer generate useful reports

Fixes

Approach

This stops reporting one specific error in coroutine handler and in startup

How Has This Been Tested?

Ran it manually and watched logcat, using the test-trigger-patch from linked issue


11-20 20:21:36.137 15236 15236 D DeckPicker: handleStartup: Continuing after permission granted
11-20 20:21:36.143  1595  9078 E MediaProvider: Creating or writing to a non-default top level directory is not allowed!
11-20 20:21:36.144  1595 12530 E MediaProvider: Creating or writing to a non-default top level directory is not allowed!
11-20 20:21:36.146 15236 15236 W InitialActivity: com.ichi2.anki.exception.StorageAccessException: Failed to create AnkiDroid directory /storage/emulated/0/AnkiDroid
11-20 20:21:36.146 15236 15236 W InitialActivity: 	at com.ichi2.anki.CollectionHelper.initializeAnkiDroidDirectory(CollectionHelper.kt:88)
11-20 20:21:36.146 15236 15236 W InitialActivity: 	at com.ichi2.anki.CollectionManager.collectionPathInValidFolder(CollectionManager.kt:264)
11-20 20:21:36.146 15236 15236 W InitialActivity: 	at com.ichi2.anki.CollectionManager.ensureOpenInner(CollectionManager.kt:243)
11-20 20:21:36.146 15236 15236 W InitialActivity: 	at com.ichi2.anki.CollectionManager.getColUnsafe$lambda$11$lambda$10(CollectionManager.kt:299)
11-20 20:21:36.146 15236 15236 W InitialActivity: 	at com.ichi2.anki.CollectionManager.$r8$lambda$1xvLXT2AdUAF2dT9vOLsddKVcWo(Unknown Source:0)
11-20 20:21:36.146 15236 15236 W InitialActivity: 	at com.ichi2.anki.CollectionManager$$ExternalSyntheticLambda2.invoke(D8$$SyntheticClass:0)
11-20 20:21:36.146 15236 15236 W InitialActivity: 	at com.ichi2.anki.CollectionManager$withQueue$3.invokeSuspend(CollectionManager.kt:103)
11-20 20:21:36.146 15236 15236 W InitialActivity: 	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
11-20 20:21:36.146 15236 15236 W InitialActivity: 	at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:104)
11-20 20:21:36.146 15236 15236 W InitialActivity: 	at kotlinx.coroutines.internal.LimitedDispatcher$Worker.run(LimitedDispatcher.kt:111)
11-20 20:21:36.146 15236 15236 W InitialActivity: 	at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:99)
11-20 20:21:36.146 15236 15236 W InitialActivity: 	at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:584)
11-20 20:21:36.146 15236 15236 W InitialActivity: 	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:811)
11-20 20:21:36.146 15236 15236 W InitialActivity: 	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:715)
11-20 20:21:36.146 15236 15236 W InitialActivity: 	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:702)
11-20 20:21:36.148  1595  8611 E MediaProvider: Creating or writing to a non-default top level directory is not allowed!
11-20 20:21:36.150  1595  9078 E MediaProvider: Creating or writing to a non-default top level directory is not allowed!
11-20 20:21:36.151 15236 15236 W CollectionHelper: com.ichi2.anki.exception.StorageAccessException: Failed to create AnkiDroid directory /storage/emulated/0/AnkiDroid
11-20 20:21:36.151 15236 15236 W CollectionHelper: 	at com.ichi2.anki.CollectionHelper.initializeAnkiDroidDirectory(CollectionHelper.kt:88)
11-20 20:21:36.151 15236 15236 W CollectionHelper: 	at com.ichi2.anki.CollectionHelper.isCurrentAnkiDroidDirAccessible(CollectionHelper.kt:111)
11-20 20:21:36.151 15236 15236 W CollectionHelper: 	at com.ichi2.anki.InitialActivity.getStartupFailureType(InitialActivity.kt:85)
11-20 20:21:36.151 15236 15236 W CollectionHelper: 	at com.ichi2.anki.DeckPicker.handleStartup(DeckPicker.kt:717)
11-20 20:21:36.151 15236 15236 W CollectionHelper: 	at com.ichi2.anki.DeckPicker.onCreate(DeckPicker.kt:497)
11-20 20:21:36.151 15236 15236 W CollectionHelper: 	at android.app.Activity.performCreate(Activity.java:8595)
11-20 20:21:36.151 15236 15236 W CollectionHelper: 	at android.app.Activity.performCreate(Activity.java:8573)
11-20 20:21:36.151 15236 15236 W CollectionHelper: 	at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1456)
11-20 20:21:36.151 15236 15236 W CollectionHelper: 	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3764)
11-20 20:21:36.151 15236 15236 W CollectionHelper: 	at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3922)
11-20 20:21:36.151 15236 15236 W CollectionHelper: 	at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:103)
11-20 20:21:36.151 15236 15236 W CollectionHelper: 	at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:139)
11-20 20:21:36.151 15236 15236 W CollectionHelper: 	at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:96)
11-20 20:21:36.151 15236 15236 W CollectionHelper: 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2443)
11-20 20:21:36.151 15236 15236 W CollectionHelper: 	at android.os.Handler.dispatchMessage(Handler.java:106)
11-20 20:21:36.151 15236 15236 W CollectionHelper: 	at android.os.Looper.loopOnce(Looper.java:205)
11-20 20:21:36.151 15236 15236 W CollectionHelper: 	at android.os.Looper.loop(Looper.java:294)
11-20 20:21:36.151 15236 15236 W CollectionHelper: 	at android.app.ActivityThread.main(ActivityThread.java:8177)
11-20 20:21:36.151 15236 15236 W CollectionHelper: 	at java.lang.reflect.Method.invoke(Native Method)
11-20 20:21:36.151 15236 15236 W CollectionHelper: 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552)
11-20 20:21:36.151 15236 15236 W CollectionHelper: 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:971)
11-20 20:21:36.151 15236 15236 I DeckPicker: AnkiDroid directory inaccessible
11-20 20:21:36.154   798   941 D EGL_emulation: app_time_stats: avg=4366.66ms min=4366.66ms max=4366.66ms count=1
11-20 20:21:36.161 15236 15236 I FragmentLifecycleLogger: DeckPicker::DatabaseErrorDialog::onAttach
11-20 20:21:36.162 15236 15236 I FragmentLifecycleLogger: DeckPicker::DatabaseErrorDialog::onCreate
11-20 20:21:36.169 15236 15236 I ScopedStorageService: isLegacyStorage(): current dir: /storage/emulated/0/AnkiDroid
11-20 20:21:36.169 15236 15236 I ScopedStorageService: scoped external dirs: /storage/emulated/0/Android/data/com.ichi2.anki.debug/files
11-20 20:21:36.169 15236 15236 I ScopedStorageService: scoped internal dir: /data/user/0/com.ichi2.anki.debug/files
11-20 20:21:36.170 15236 15236 I ScopedStorageService: isLegacyStorage(): true
11-20 20:21:36.171 15236 15236 W NavigationDrawerActivity$Companion: No storage access, not enabling shortcuts
11-20 20:21:36.173 15236 15236 D DeckPicker: No DeckPicker background preference
11-20 20:21:36.174 15236 15236 D InitialActivity: WebView is up to date. com.google.android.webview: 113.0.5672.136(567263634)
11-20 20:21:36.176 15236 15236 I AnkiDroidApp$onCreate: DeckPicker::onStart
11-20 20:21:36.211 15236 15236 W WindowOnBackDispatcher: OnBackInvokedCallback is not enabled for the application.
11-20 20:21:36.211 15236 15236 W WindowOnBackDispatcher: Set 'android:enableOnBackInvokedCallback="true"' in the application manifest.
11-20 20:21:36.211 15236 15236 I FragmentLifecycleLogger: DeckPicker::DatabaseErrorDialog::onStart
11-20 20:21:36.215 15236 15236 I AnkiDroidApp$onCreate: DeckPicker::onResume
11-20 20:21:36.216 15236 15236 D UsageAnalytics: sendAnalyticsScreenView(): DeckPicker
11-20 20:21:36.216 15236 15236 D UsageAnalytics: getOptIn() status: false
11-20 20:21:36.223 15236 15236 D UsageAnalytics: sendAnalyticsScreenView(): DatabaseErrorDialog
11-20 20:21:36.223 15236 15236 D UsageAnalytics: getOptIn() status: false
11-20 20:21:36.223 15236 15236 I FragmentLifecycleLogger: DeckPicker::DatabaseErrorDialog::onResume

No more exception report

Learning (optional, can help others)

Our startup logic is a tangle!
Our coroutine error handling logic is a tangle!

Checklist

Please, go through these checks before submitting the PR.

  • You have a descriptive commit message with a short title (first line, max 50 chars).
  • You have commented your code, particularly in hard-to-understand areas
  • You have performed a self-review of your own code
  • UI changes: include screenshots of all affected screens (in particular showing any new or changed strings)
  • UI Changes: You have tested your change using the Google Accessibility Scanner

these no longer generate useful reports
@BrayanDSO
Copy link
Member

David knows way more than me about storage issues, so he should have a firmer opinion than I. The fix here looks alright, but I'm not sure if this error occur in new play installations. Theoretically, it shouldn't, but I wouldn't be surprised if there is some kind of platform bug somewhere

Copy link
Member

@lukstbit lukstbit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes seem fine and if David is ok with silencing the exception report I'm also ok with silencing it.

@lukstbit lukstbit added the Needs Second Approval Has one approval, one more approval to merge label Nov 24, 2024
Copy link
Member

@david-allison david-allison left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At a later date we should handle this lower down in the crash reporting mechanism. This only blocks the exception in launchCatchingTask

If it's been tested, let's get it in

@david-allison david-allison added this pull request to the merge queue Nov 25, 2024
Merged via the queue into ankidroid:main with commit ed407bb Nov 26, 2024
12 checks passed
@github-actions github-actions bot modified the milestones: 2.19.3 release, 2.20 Release Nov 26, 2024
@github-actions github-actions bot removed Review High Priority Request for high priority review Needs Second Approval Has one approval, one more approval to merge labels Nov 26, 2024
@mikehardy mikehardy deleted the quiet-storage-access-exceptions branch November 26, 2024 00:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants