Closed rbrauwers closed 2 years ago
Anyone?
2 months passed without any feedback...
We (Audiomack) are also experiencing this crash, and the number is growing by the day with the new user acquisition. However, this crash will undoubtedly have an impact on the performance of our application. Please address this crash as soon as possible so that we can release a new version that does not contain such a crash.
onesignalVersion = "4.6.3"
OneSignalDbHelper.java line 150 (com.onesignal.OneSignalDbHelper.getSQLiteDatabase)
Fatal Exception: android.database.sqlite.SQLiteCantOpenDatabaseException: unknown error (code 14): Could not open database
at android.database.sqlite.SQLiteConnection.nativeOpen(SQLiteConnection.java)
at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:210)
at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:194)
at android.database.sqlite.SQLiteConnectionPool.openConnectionLocked(SQLiteConnectionPool.java:493)
at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:200)
at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:192)
at android.database.sqlite.SQLiteDatabase.openInner(SQLiteDatabase.java:864)
at android.database.sqlite.SQLiteDatabase.open(SQLiteDatabase.java:849)
at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:724)
at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:714)
at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:295)
at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:238)
at com.onesignal.OneSignalDbHelper.getSQLiteDatabase(OneSignalDbHelper.java:150)
at com.onesignal.OneSignalDbHelper.getSQLiteDatabaseWithRetries(OneSignalDbHelper.java:174)
at com.onesignal.OneSignalDbHelper.delete(OneSignalDbHelper.java:289)
at com.onesignal.OSNotificationDataController$1.run(OSNotificationDataController.java:57)
at java.lang.Thread.run(Thread.java:764)
same crash
Fatal Exception: android.database.sqlite.SQLiteCantOpenDatabaseException: Cannot open database '/data/user/0/com.interfocusllc.patpat/databases/OneSignal.db': File /data/user/0/com.interfocusllc.patpat/databases/OneSignal.db doesn't exist
at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:252)
at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:205)
at android.database.sqlite.SQLiteConnectionPool.openConnectionLocked(SQLiteConnectionPool.java:505)
at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:206)
at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:198)
at android.database.sqlite.SQLiteDatabase.openInner(SQLiteDatabase.java:918)
at android.database.sqlite.SQLiteDatabase.open(SQLiteDatabase.java:898)
at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:762)
at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:751)
at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:373)
at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:316)
at com.onesignal.OneSignalDbHelper.getSQLiteDatabase(OneSignalDbHelper.java:150)
at com.onesignal.OneSignalDbHelper.getSQLiteDatabaseWithRetries(OneSignalDbHelper.java:174)
at com.onesignal.OneSignalDbHelper.delete(OneSignalDbHelper.java:289)
at com.onesignal.OSNotificationDataController$1.run(OSNotificationDataController.java:57)
at java.lang.Thread.run(Thread.java:923)
Caused by android.database.sqlite.SQLiteCantOpenDatabaseException: unknown error (code 14 SQLITE_CANTOPEN): Could not open database
at android.database.sqlite.SQLiteConnection.nativeOpen(SQLiteConnection.java)
at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:224)
at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:205)
at android.database.sqlite.SQLiteConnectionPool.openConnectionLocked(SQLiteConnectionPool.java:505)
at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:206)
at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:198)
at android.database.sqlite.SQLiteDatabase.openInner(SQLiteDatabase.java:918)
at android.database.sqlite.SQLiteDatabase.open(SQLiteDatabase.java:898)
at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:762)
at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:751)
at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:373)
at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:316)
at com.onesignal.OneSignalDbHelper.getSQLiteDatabase(OneSignalDbHelper.java:150)
at com.onesignal.OneSignalDbHelper.getSQLiteDatabaseWithRetries(OneSignalDbHelper.java:174)
at com.onesignal.OneSignalDbHelper.delete(OneSignalDbHelper.java:289)
at com.onesignal.OSNotificationDataController$1.run(OSNotificationDataController.java:57)
at java.lang.Thread.run(Thread.java:923)
@rbrauwers @raghav2945 @CharlieZheng Thanks for reporting the issue with the fullstack trace and reason messages. We are looking for some additional information to narrow down when the issue happens. Please see the "Questions" section below and reply with those details.
It seems all these occurrences are from a lower level issue where the OneSignal.db
database can't be opened due to it being corrupted or missing. Potentially the database is being used by another OneSignal thread which could create odd errors like this. Getting some more details from the "Questions" section below will help us confirm if this issue the root of the issue.
All of these occurrences noted here come through OSNotificationDataController.cleanNotificationCache()
which happens when the app starts up. All these stacktrace maybe the same as this is most likely the first database access.
All OneSignal.db
access is encapsulated in OneSignalDbHelper.java
and it uses synchronized
to ensure only one thread runs an operation at a time. However I do see some missing locks which is most likely creating a race condition. Such as onCreate
missing a lock and internalOnUpgrade
using a different lock. The cleanup cleanNotificationCache
does run on it's own thread which make this more likely.
There is also getSQLiteDatabaseWithRetries() which is most likely help mitigating most race conditions, however if there is a lot of I/O which mean another thread could be taking a while then there may still be a timeout and would result in throwing.
OneSignal.db
database migration is in play here.java.lang.IllegalStateException:
at androidx.work.impl.utils.ForceStopRunnable.run (ForceStopRunnable.java:128)
at androidx.work.impl.utils.SerialExecutor$Task.run (SerialExecutor.java:91)
at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:641)
at java.lang.Thread.run (Thread.java:923)
Caused by: android.database.sqlite.SQLiteCantOpenDatabaseException:
at android.database.sqlite.SQLiteConnection.open (SQLiteConnection.java:365)
at android.database.sqlite.SQLiteConnection.open (SQLiteConnection.java:226)
at android.database.sqlite.SQLiteConnectionPool.openConnectionLocked (SQLiteConnectionPool.java:737)
at android.database.sqlite.SQLiteConnectionPool.open (SQLiteConnectionPool.java:284)
at android.database.sqlite.SQLiteConnectionPool.open (SQLiteConnectionPool.java:251)
at android.database.sqlite.SQLiteDatabase.openInner (SQLiteDatabase.java:1392)
at android.database.sqlite.SQLiteDatabase.open (SQLiteDatabase.java:1337)
at android.database.sqlite.SQLiteDatabase.openDatabase (SQLiteDatabase.java:980)
at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked (SQLiteOpenHelper.java:444)
at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase (SQLiteOpenHelper.java:387)
at androidx.sqlite.db.framework.FrameworkSQLiteOpenHelper$OpenHelper.getWritableSupportDatabase (FrameworkSQLiteOpenHelper.java:145)
at androidx.sqlite.db.framework.FrameworkSQLiteOpenHelper.getWritableDatabase (FrameworkSQLiteOpenHelper.java:106)
at androidx.room.RoomDatabase.inTransaction (RoomDatabase.java:476)
at androidx.room.RoomDatabase.assertNotSuspendingTransaction (RoomDatabase.java:281)
at androidx.work.impl.model.SystemIdInfoDao_Impl.getWorkSpecIds (SystemIdInfoDao_Impl.java:120)
at androidx.work.impl.background.systemjob.SystemJobScheduler.reconcileJobs (SystemJobScheduler.java:298)
at androidx.work.impl.utils.ForceStopRunnable.cleanUp (ForceStopRunnable.java:249)
at androidx.work.impl.utils.ForceStopRunnable.forceStopRunnable (ForceStopRunnable.java:215)
at androidx.work.impl.utils.ForceStopRunnable.run (ForceStopRunnable.java:110)
Caused by: android.database.sqlite.SQLiteCantOpenDatabaseException:
at android.database.sqlite.SQLiteConnection.nativeOpen (Native Method)
at android.database.sqlite.SQLiteConnection.open (SQLiteConnection.java:337)
Note I'm just initialization OneSignal in the Application class onCreate method
`OneSignal.initWithContext(MyApplication.this)
OneSignal.setAppId(ONESIGNAL_APP_ID);`
@thefaisalurrehman Thanks for reporting, however OneSignal is not in the stack trace and isn't related the to other reports here. These are coming from the AndroidX WorkManager library as they start with androidx.work.impl
in your stack trace.
There are a lot of reports of this issue on apps that don't even use OneSignal.
There is an issue created for this already https://github.com/OneSignal/OneSignal-Android-SDK/issues/1280. It is closed, but I just added some more detail on making sure you have the latest 2.7.1 version. Please reply in #1280 issue if you have more detail and we can attempt to help there.
@thefaisalurrehman Thanks for reporting, however OneSignal is not in the stack trace and isn't related the the other reports here. These are coming from the AndroidX WorkManager library as they start with
androidx.work.impl
in your stack trace.There are a lot of reports of this issue on apps that don't even use OneSignal.
- https://stackoverflow.com/questions/68660648/illegalstateexception-the-file-system-on-the-device-is-in-a-bad-state-workmana
- https://stackoverflow.com/questions/59366438/crash-in-firebase-no-clue
- https://issuetracker.google.com/issues/186443045
- https://issuetracker.google.com/issues/160625831
There is an issue created for this already #1280. It is closed, but I just added some more detail on making sure you have the latest 2.7.1 version. Please reply in #1280 issue if you have more detail and we can attempt to help there.
Thanks for response. I check this
@rbrauwers @raghav2945 @CharlieZheng Thanks for reporting the issue with the fullstack trace and reason messages. We are looking for some additional information to narrow down when the issue happens. Please see the "Questions" section below and reply with those details.
Issue
Summary
It seems all these occurrences are from a lower level issue where the
OneSignal.db
database can't be opened due to it being corrupted or missing. Potentially the database is being used by another OneSignal thread which could create odd errors like this. Getting some more details from the "Questions" section below will help us confirm if this issue the root of the issue.Details
All of these occurrences noted here come through
OSNotificationDataController.cleanNotificationCache()
which happens when the app starts up. All these stacktrace maybe the same as this is most likely the first database access.All
OneSignal.db
access is encapsulated inOneSignalDbHelper.java
and it usessynchronized
to ensure only one thread runs an operation at a time. However I do see some missing locks which is most likely creating a race condition. Such asonCreate
missing a lock andinternalOnUpgrade
using a different lock. The cleanupcleanNotificationCache
does run on it's own thread which make this more likely.There is also getSQLiteDatabaseWithRetries() which is most likely help mitigating most race conditions, however if there is a lot of I/O which mean another thread could be taking a while then there may still be a timeout and would result in throwing.
Questions
- Can you reproduce the issue? If so please provide steps on doing so. If not consistently please provide those details as well.
- Does the issue happen repeatedly for the same devices? Or does it happen once and the app consistently starts successfully after that.
Was your app released with an older version of the OneSignal SDK? If so please provide the versions you know about.
- Most importantly want to know if you came a OneSignal version pre-3.14.0 to 3.14.0 or later. Looking to rule out if a
OneSignal.db
database migration is in play here.
Thank you @jkasten2 for providing such a thorough analysis and update on the issue. It's useful to understand what's causing the problem. Please find below the answers to your questions based on our current observations.
One more update: with the most recent crash, we can clearly see in the logs that the OneSignal.db does not exist. Which I suspect you must handle more gracefully in certain positions. I'm including the stack trace for your convenience.
Fatal Exception: android.database.sqlite.SQLiteCantOpenDatabaseException: Cannot open database '/data/user/0/com.audiomack/databases/OneSignal.db': File /data/user/0/com.audiomack/databases/OneSignal.db doesn't exist
at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:252)
at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:205)
at android.database.sqlite.SQLiteConnectionPool.openConnectionLocked(SQLiteConnectionPool.java:505)
at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:206)
at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:198)
at android.database.sqlite.SQLiteDatabase.openInner(SQLiteDatabase.java:918)
at android.database.sqlite.SQLiteDatabase.open(SQLiteDatabase.java:898)
at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:762)
at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:751)
at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:373)
at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:316)
at com.onesignal.OneSignalDbHelper.getSQLiteDatabase(OneSignalDbHelper.java:150)
at com.onesignal.OneSignalDbHelper.getSQLiteDatabaseWithRetries(OneSignalDbHelper.java:174)
at com.onesignal.OneSignalDbHelper.delete(OneSignalDbHelper.java:289)
at com.onesignal.OSNotificationDataController$1.run(OSNotificationDataController.java:57)
at java.lang.Thread.run(Thread.java:923)
Caused by android.database.sqlite.SQLiteCantOpenDatabaseException: unknown error (code 14 SQLITE_CANTOPEN): Could not open database
at android.database.sqlite.SQLiteConnection.nativeOpen(SQLiteConnection.java)
at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:224)
at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:205)
at android.database.sqlite.SQLiteConnectionPool.openConnectionLocked(SQLiteConnectionPool.java:505)
at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:206)
at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:198)
at android.database.sqlite.SQLiteDatabase.openInner(SQLiteDatabase.java:918)
at android.database.sqlite.SQLiteDatabase.open(SQLiteDatabase.java:898)
at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:762)
at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:751)
at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:373)
at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:316)
at com.onesignal.OneSignalDbHelper.getSQLiteDatabase(OneSignalDbHelper.java:150)
at com.onesignal.OneSignalDbHelper.getSQLiteDatabaseWithRetries(OneSignalDbHelper.java:174)
at com.onesignal.OneSignalDbHelper.delete(OneSignalDbHelper.java:289)
at com.onesignal.OSNotificationDataController$1.run(OSNotificationDataController.java:57)
at java.lang.Thread.run(Thread.java:923)
Right after adding OneSignal to our native Android (no Unity) app and since publishing to our users we are starting to see this as well, but with OneSignal in the stack trace:
Fatal Exception: android.database.sqlite.SQLiteCantOpenDatabaseException: unknown error (code 14 SQLITE_CANTOPEN): Could not open database
at android.database.sqlite.SQLiteConnection.nativeOpen(SQLiteConnection.java)
at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:215)
at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:197)
at android.database.sqlite.SQLiteConnectionPool.openConnectionLocked(SQLiteConnectionPool.java:505)
at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:206)
at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:198)
at android.database.sqlite.SQLiteDatabase.openInner(SQLiteDatabase.java:915)
at android.database.sqlite.SQLiteDatabase.open(SQLiteDatabase.java:895)
at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:759)
at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:748)
at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:374)
at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:317)
at com.onesignal.OneSignalDbHelper.getSQLiteDatabase(OneSignalDbHelper.java:150)
at com.onesignal.OneSignalDbHelper.getSQLiteDatabaseWithRetries(OneSignalDbHelper.java:174)
at com.onesignal.OneSignalDbHelper.delete(OneSignalDbHelper.java:289)
at com.onesignal.outcomes.data.OSOutcomeEventsCache.cleanCachedUniqueOutcomeEventNotifications(OSOutcomeEventsCache.java:327)
at com.onesignal.outcomes.data.OSOutcomeEventsRepository.cleanCachedUniqueOutcomeEventNotifications(OSOutcomeEventsRepository.kt:46)
at com.onesignal.OSOutcomeEventsController$1.run(OSOutcomeEventsController.java:71)
at java.lang.Thread.run(Thread.java:919)
According to Crashlytics user has enough storage space, so that's not what's causing it. Happens in foreground and in background.
It happened only to one user so far, but for them 39(!) times within just a few minutes - until today it happened over 2000 times in total for this user. The user's device is a Motorola One with Android 10.
We also have our own database in the app and that one is working just fine, no crashes there - so it seems to be an issue specific to OneSignal and how the SDK accesses the DB.
We are using version 4.7.0 of the SDK.
We released version 4.7.2 that has a speculative fix for the crashes here. Also the root cause exception may be reported better if the thread locking changes we made did not address the problem, so please report the new stacktraces if you continue seeing crashes. See PR #1567 for more details on what changed.
@ubuntudroid @raghav2945 @thefaisalurrehman @rbrauwers @CharlieZheng Just checking in to see if the OneSignal 4.7.2 release fixed this issue for you?
@ubuntudroid @raghav2945 @thefaisalurrehman @rbrauwers @CharlieZheng Just checking in to see if the OneSignal 4.7.2 release fixed this issue for you?
I think it's fixed. because after update I have no appear this type of crash
Same here, doesn't seem to happen anymore. Thanks for fixing this! 🙏
Awesome, that is good to hear! Thanks for letting us know.
Please accept my apologies for the delay in responding.
However, because the count was slightly increasing, we had to temporarily halt the use of Onesignal. Anyway, thanks for the update, and hopefully the problem has been resolved by the new update.
@jkasten2 Hi, is the issue from the title resolved as well? SQLiteDatabaseCorruptException on Android 10 devices? @rbrauwers is it working for you after the update?
Description
App crashes with android.database.sqlite.SQLiteDatabaseCorruptException. It seems only occurs on Samsung devices running Android 10. Currently this crash is by far the most relevant issue on our app.
Environment
Compile SDK: 30 OneSignal SDK: 4.4.2 OneSignal plugin: 0.13.4 Using Maven: yes
Stacktrace