syt0r / Kanji-Dojo

A multi-platform application for memorizing Japanese language
GNU General Public License v3.0
245 stars 7 forks source link

Weird crash on app startup after adding backup feature #119

Closed syt0r closed 5 months ago

syt0r commented 8 months ago

There is a strange crash that usually happens when the app is in background during startup. It says that context is null even though I'm using instance of Application there injected through Koin

Fatal Exception: java.lang.NullPointerException: Parameter specified as non-null is null: method app.cash.sqldelight.driver.android.AndroidSqliteDriver.<init>, parameter context
       at app.cash.sqldelight.driver.android.AndroidSqliteDriver.<init>(AndroidSqliteDriver.java:3)
       at app.cash.sqldelight.driver.android.AndroidSqliteDriver.<init>(AndroidSqliteDriver.java:3)
       at ua.syt0r.kanji.core.user_data.UserDataDatabaseManagerAndroid.createDatabaseConnection(UserDataDatabaseManagerAndroid.java:60)

This crash didn't occur before this update with backup feature so I assume android might have issues after manually overwriting one of the databases

It's unclear whether or not it allows to enter the app after restart so it might be quite critical but I can't find a way to reproduce it

Maybe I could try deleting database via Android's API before the replacement logic happens and see if it will fix it in the next version

Terrance commented 8 months ago

For what it's worth, I've had a few of these logged too, also whilst the app is in the background:

FATAL EXCEPTION: DefaultDispatcher-worker-2
Process: ua.syt0r.kanji.fdroid, PID: 25649
java.lang.NullPointerException: Parameter specified as non-null is null: method app.cash.sqldelight.driver.android.AndroidSqliteDriver.<init>, parameter context
    at app.cash.sqldelight.driver.android.AndroidSqliteDriver.<init>(SourceFile:3)
    at ua.syt0r.kanji.core.user_data.UserDataDatabaseManagerAndroid.createDatabaseConnection(Unknown Source:60)
    at ua.syt0r.kanji.core.user_data.BaseUserDataDatabaseManager$1.invokeSuspend(Unknown Source:34)
    at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(Unknown Source:8)
    at kotlinx.coroutines.DispatchedTask.run(Unknown Source:109)
    at androidx.work.Worker$2.run(Unknown Source:14)
    at kotlinx.coroutines.scheduling.TaskImpl.run(Unknown Source:2)
    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(Unknown Source:93)
    Suppressed: kotlinx.coroutines.internal.DiagnosticCoroutineContextException: [StandaloneCoroutine{Cancelling}@d51332e, Dispatchers.IO]
syt0r commented 8 months ago

@Terrance thanks for letting me know. That's exactly the same crash I'm seeing in analytics. I have several questions:

  1. Do you remember doing anything specific in the Kanji Dojo right before it happened?
  2. Did you use restore from backup?
  3. Can you still enter into the app after it happened?
  4. Do you use reminder notification?
Terrance commented 8 months ago
  1. Looks like I've had a crash about once every other day since 2.0.2. I'm only brushing up on Hiragana and Katakana for now, the practice time varies but doesn't seem to affect the crash time the following morning (see 4).
  2. I took an initial backup when I first spotted it in the changelog, but haven't tried restoring yet.
  3. As far as I can tell, no functionality is impaired -- the app starts normally (but presumably a cold boot) after a crash, and I can practice as normal.
  4. Interestingly all these crashes have happened around 7:30am when I've woken up. Reminder notification is enabled and set to 6am (so that it sits in notifications until I do my practice but effectively doesn't alert), but it's plausibly delayed until my phone wakes from deep sleep, so that could be related.
Terrance commented 8 months ago

Actually, on 4. I can see it crashed again this morning and I also didn't get a notification (nothing in Android's Notification history, so it was likely never created).

Terrance commented 5 months ago

Just realised I never reported back here: I've not seen these crashes for a while now (last was 12th April), so hopefully this has been resolved by the commit referenced above. 🙂

syt0r commented 5 months ago

Yes, I'm not seeing it in the crashlytics as well for the latest version, but now there's this issue with infinite loading when using notifications... I still can't figure out the reason behind all of this, but since this crash is not happening anymore I'll close this issue