OneSignal-Android-SDK icon indicating copy to clipboard operation
OneSignal-Android-SDK copied to clipboard

com.onesignal.OneSignalDbHelper.getSQLiteDatabase crashes

Open fchicken opened this issue 3 years ago • 7 comments

Description:

Some crashes happen when com.onesignal.OneSignalDbHelper.getSQLiteDatabase is called.

Environment

OneSignal SDK: 3.15.3 Android SDK: Many versions have these crashes

Steps to Reproduce Issue:

I can't reproduce these issues, but I attach some stack traces from users below.

Stack Traces:

Fatal Exception: android.database.sqlite.SQLiteDiskIOException
Fatal Exception: android.database.sqlite.SQLiteDiskIOException: disk I/O error (code 4874 SQLITE_IOERR_SHMSIZE): , while compiling: PRAGMA journal_mode
       at android.database.sqlite.SQLiteConnection.nativePrepareStatement(SQLiteConnection.java)
       at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:903)
       at android.database.sqlite.SQLiteConnection.executeForString(SQLiteConnection.java:648)
       at android.database.sqlite.SQLiteConnection.setJournalMode(SQLiteConnection.java:333)
       at android.database.sqlite.SQLiteConnection.setWalModeFromConfiguration(SQLiteConnection.java:298)
       at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:217)
       at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:195)
       at android.database.sqlite.SQLiteConnectionPool.openConnectionLocked(SQLiteConnectionPool.java:503)
       at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:204)
       at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:196)
       at android.database.sqlite.SQLiteDatabase.openInner(SQLiteDatabase.java:880)
       at android.database.sqlite.SQLiteDatabase.open(SQLiteDatabase.java:865)
       at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:739)
       at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:729)
       at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:355)
       at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:298)
       at com.onesignal.OneSignalDbHelper.getSQLiteDatabase(OneSignalDbHelper.java:149)
       at com.onesignal.OneSignalDbHelper.getSQLiteDatabaseWithRetries(OneSignalDbHelper.java:173)
       at com.onesignal.OneSignalDbHelper.query$1749d206(OneSignalDbHelper.java:188)
       at com.onesignal.OSInAppMessageRepository.getCachedInAppMessages(OSInAppMessageRepository.java:45)
       at com.onesignal.OSInAppMessageController.initRedisplayData(OSInAppMessageController.java:133)
       at com.onesignal.OSInAppMessageController.<init>(OSInAppMessageController.java:121)
       at com.onesignal.OSInAppMessageController.getController(OSInAppMessageController.java:83)
       at com.onesignal.OneSignalCacheCleaner$2.run(OneSignalCacheCleaner.java:61)
       at java.lang.Thread.run(Thread.java:764)
Fatal Exception: android.database.sqlite.SQLiteException
Fatal Exception: android.database.sqlite.SQLiteException: Failed to change locale for db '/mnt/expand/95a59313-114c-496a-ae37-25b5bac550bc/user/0/live.free.tv_tw/databases/OneSignal.db' to 'zh_TW_#Hant'.
       at android.database.sqlite.SQLiteConnection.setLocaleFromConfiguration(SQLiteConnection.java:409)
       at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:223)
       at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:198)
       at android.database.sqlite.SQLiteConnectionPool.openConnectionLocked(SQLiteConnectionPool.java:463)
       at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:185)
       at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:177)
       at android.database.sqlite.SQLiteDatabase.openInner(SQLiteDatabase.java:843)
       at android.database.sqlite.SQLiteDatabase.open(SQLiteDatabase.java:828)
       at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:721)
       at android.app.ContextImpl.openOrCreateDatabase(ContextImpl.java:664)
       at android.content.ContextWrapper.openOrCreateDatabase(ContextWrapper.java:289)
       at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:223)
       at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:163)
       at com.onesignal.OneSignalDbHelper.getSQLiteDatabase(OneSignalDbHelper.java:149)
       at com.onesignal.OneSignalDbHelper.getSQLiteDatabaseWithRetries(OneSignalDbHelper.java:173)
       at com.onesignal.OneSignalDbHelper.query$1749d206(OneSignalDbHelper.java:188)
       at com.onesignal.outcomes.OSOutcomeEventsCache.getAllEventsToSend(OSOutcomeEventsCache.java:140)
       at com.onesignal.outcomes.OSOutcomeEventsRepository.getSavedOutcomeEvents(OSOutcomeEventsRepository.java:30)
       at com.onesignal.OSOutcomeEventsController$1.run(OSOutcomeEventsController.java:69)
       at java.lang.Thread.run(Thread.java:761)

fchicken avatar Nov 19 '20 10:11 fchicken

Hey @fchicken, thanks for reporting this, can you provide the device's information (android version, brand, etc) of the devices that are having this issue? Thanks!

Jeasmine avatar Nov 19 '20 14:11 Jeasmine

Hey @Jeasmine, here are some devices' information that encounter these crashes.

  • Fatal Exception: android.database.sqlite.SQLiteDiskIOException
    • moto e(5) cruise with Android 8.0.0
    • moto g(7) power with Android 9
    • moto g(7) optimo maxx(XT1955DL) with Android 9
    • UMX U693CL with Android 9
    • Samsung Galaxy Tab E 9.6 with Android 7.1.1
    • TINNO U304AA with Android 9
  • Fatal Exception: android.database.sqlite.SQLiteException
    • Acer Iconia Tab 10 with Android 7.0
    • Sony Xperia XA2 with Android 9

fchicken avatar Nov 24 '20 15:11 fchicken

I have the same issue on Samsung Galaxy A11 (Android 10). @Jeasmine any news?

WagesOfSin avatar Dec 21 '20 07:12 WagesOfSin

@fchicken @WagesOfSin Thanks for reporting, I have a few follow up comments and questions.

Question 1 - What are the number of crash reports for each of these?

Question 2 - Could you provide the full stack trace for each SQLiteException? This exceptions is generic so it could be a number of different errors.

Comment 1 - SQLiteDiskIOException This looks to be from the device running out of space. I would expect this to be quite rare but we will look into handing this as the SDK should be able to move on without it.

Comment 2 - SQLiteException: Failed to change locale for db "SQLiteException: Failed to change locale for db '/.../OneSignal.db' to 'zh_TW#Hant'."_ this looks to be from the system language changing. I wouldn't expect an exception from this but we can attempt to reproduce this by changing the device's language.

jkasten2 avatar Dec 28 '20 18:12 jkasten2

@jkasten2 Thanks for your comments. The following is the information of these two questions:

Question 1 - What are the number of crash reports for each of these? SQLiteDiskIOException reports approximately 1.8k in last 30 days SQLiteException reports approximately 2k in last 30 days

Question 2 - Could you provide the full stack trace for each SQLiteException? The stack traces is provided in the first post, but I can provide more here.

Fatal Exception: android.database.sqlite.SQLiteDiskIOException
Fatal Exception: android.database.sqlite.SQLiteDiskIOException: unknown error (code 10): Could not open database
       at android.database.sqlite.SQLiteConnection.nativeOpen(SQLiteConnection.java)
       at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:209)
       at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:193)
       at android.database.sqlite.SQLiteConnectionPool.openConnectionLocked(SQLiteConnectionPool.java:463)
       at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:185)
       at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:177)
       at android.database.sqlite.SQLiteDatabase.openInner(SQLiteDatabase.java:808)
       at android.database.sqlite.SQLiteDatabase.open(SQLiteDatabase.java:793)
       at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:696)
       at android.app.ContextImpl.openOrCreateDatabase(ContextImpl.java:652)
       at android.content.ContextWrapper.openOrCreateDatabase(ContextWrapper.java:289)
       at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:223)
       at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:163)
       at com.onesignal.OneSignalDbHelper.getSQLiteDatabase(OneSignalDbHelper.java:149)
       at com.onesignal.OneSignalDbHelper.getSQLiteDatabaseWithRetries(OneSignalDbHelper.java:173)
       at com.onesignal.OneSignalDbHelper.delete(OneSignalDbHelper.java:269)
       at com.onesignal.OneSignalCacheCleaner.cleanCachedNotifications(OneSignalCacheCleaner.java:82)
       at com.onesignal.OneSignalCacheCleaner.access$000(OneSignalCacheCleaner.java:11)
       at com.onesignal.OneSignalCacheCleaner$1.run(OneSignalCacheCleaner.java:40)
       at java.lang.Thread.run(Thread.java:761)
Fatal Exception: android.database.sqlite.SQLiteDiskIOException
Fatal Exception: android.database.sqlite.SQLiteDiskIOException: disk I/O error (code 1034 SQLITE_IOERR_FSYNC)
       at android.database.sqlite.SQLiteConnection.nativeExecute(SQLiteConnection.java)
       at android.database.sqlite.SQLiteConnection.execute(SQLiteConnection.java:648)
       at android.database.sqlite.SQLiteConnection.setLocaleFromConfiguration(SQLiteConnection.java:450)
       at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:227)
       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:149)
       at com.onesignal.OneSignalDbHelper.getSQLiteDatabaseWithRetries(OneSignalDbHelper.java:173)
       at com.onesignal.OneSignalDbHelper.query(OneSignalDbHelper.java:188)
       at com.onesignal.OSInAppMessageRepository.getCachedInAppMessages(OSInAppMessageRepository.java:45)
       at com.onesignal.OSInAppMessageController.initRedisplayData(OSInAppMessageController.java:133)
       at com.onesignal.OSInAppMessageController.<init>(OSInAppMessageController.java:121)
       at com.onesignal.OSInAppMessageController.getController(OSInAppMessageController.java:83)
       at com.onesignal.OneSignalCacheCleaner$2.run(OneSignalCacheCleaner.java:61)
       at java.lang.Thread.run(Thread.java:919)
Fatal Exception: android.database.sqlite.SQLiteDatabaseLockedException
Fatal Exception: android.database.sqlite.SQLiteDatabaseLockedException: database is locked (code 5): , while compiling: PRAGMA journal_mode
       at android.database.sqlite.SQLiteConnection.nativePrepareStatement(SQLiteConnection.java)
       at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:1093)
       at android.database.sqlite.SQLiteConnection.executeForString(SQLiteConnection.java:804)
       at android.database.sqlite.SQLiteConnection.setJournalMode(SQLiteConnection.java:490)
       at android.database.sqlite.SQLiteConnection.setWalModeFromConfiguration(SQLiteConnection.java:464)
       at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:363)
       at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:228)
       at android.database.sqlite.SQLiteConnectionPool.openConnectionLocked(SQLiteConnectionPool.java:512)
       at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:206)
       at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:178)
       at android.database.sqlite.SQLiteDatabase.openInner(SQLiteDatabase.java:894)
       at android.database.sqlite.SQLiteDatabase.open(SQLiteDatabase.java:864)
       at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:699)
       at android.app.ContextImpl.openOrCreateDatabase(ContextImpl.java:1520)
       at android.content.ContextWrapper.openOrCreateDatabase(ContextWrapper.java:282)
       at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:223)
       at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:163)
       at com.onesignal.OneSignalDbHelper.getSQLiteDatabase(OneSignalDbHelper.java:149)
       at com.onesignal.OneSignalDbHelper.getSQLiteDatabaseWithRetries(OneSignalDbHelper.java:173)
       at com.onesignal.OneSignalDbHelper.delete(OneSignalDbHelper.java:269)
       at com.onesignal.OneSignalCacheCleaner.cleanCachedNotifications(OneSignalCacheCleaner.java:82)
       at com.onesignal.OneSignalCacheCleaner.access$000(OneSignalCacheCleaner.java:11)
       at com.onesignal.OneSignalCacheCleaner$1.run(OneSignalCacheCleaner.java:40)
       at java.lang.Thread.run(Thread.java:818)
Fatal Exception: android.database.sqlite.SQLiteException
Fatal Exception: android.database.sqlite.SQLiteException: Failed to change locale for db '/mnt/expand/95a59313-114c-496a-ae37-25b5bac550bc/user/0/live.free.tv_tw/databases/OneSignal.db' to 'zh_TW_#Hant'.
       at android.database.sqlite.SQLiteConnection.setLocaleFromConfiguration(SQLiteConnection.java:409)
       at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:223)
       at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:198)
       at android.database.sqlite.SQLiteConnectionPool.openConnectionLocked(SQLiteConnectionPool.java:463)
       at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:185)
       at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:177)
       at android.database.sqlite.SQLiteDatabase.openInner(SQLiteDatabase.java:843)
       at android.database.sqlite.SQLiteDatabase.open(SQLiteDatabase.java:828)
       at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:721)
       at android.app.ContextImpl.openOrCreateDatabase(ContextImpl.java:664)
       at android.content.ContextWrapper.openOrCreateDatabase(ContextWrapper.java:289)
       at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:223)
       at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:163)
       at com.onesignal.OneSignalDbHelper.getSQLiteDatabase(OneSignalDbHelper.java:149)
       at com.onesignal.OneSignalDbHelper.getSQLiteDatabaseWithRetries(OneSignalDbHelper.java:173)
       at com.onesignal.OneSignalDbHelper.delete(OneSignalDbHelper.java:269)
       at com.onesignal.OneSignalCacheCleaner.cleanCachedNotifications(OneSignalCacheCleaner.java:82)
       at com.onesignal.OneSignalCacheCleaner.access$000(OneSignalCacheCleaner.java:11)
       at com.onesignal.OneSignalCacheCleaner$1.run(OneSignalCacheCleaner.java:40)
       at java.lang.Thread.run(Thread.java:761)
Caused by android.database.sqlite.SQLiteDatabaseCorruptException: database disk image is malformed (code 11)
       at android.database.sqlite.SQLiteConnection.nativeExecuteForString(SQLiteConnection.java)
       at android.database.sqlite.SQLiteConnection.executeForString(SQLiteConnection.java:657)
       at android.database.sqlite.SQLiteConnection.setLocaleFromConfiguration(SQLiteConnection.java:386)
       at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:223)
       at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:198)
       at android.database.sqlite.SQLiteConnectionPool.openConnectionLocked(SQLiteConnectionPool.java:463)
       at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:185)
       at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:177)
       at android.database.sqlite.SQLiteDatabase.openInner(SQLiteDatabase.java:843)
       at android.database.sqlite.SQLiteDatabase.open(SQLiteDatabase.java:828)
       at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:721)
       at android.app.ContextImpl.openOrCreateDatabase(ContextImpl.java:664)
       at android.content.ContextWrapper.openOrCreateDatabase(ContextWrapper.java:289)
       at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:223)
       at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:163)
       at com.onesignal.OneSignalDbHelper.getSQLiteDatabase(OneSignalDbHelper.java:149)
       at com.onesignal.OneSignalDbHelper.getSQLiteDatabaseWithRetries(OneSignalDbHelper.java:173)
       at com.onesignal.OneSignalDbHelper.delete(OneSignalDbHelper.java:269)
       at com.onesignal.OneSignalCacheCleaner.cleanCachedNotifications(OneSignalCacheCleaner.java:82)
       at com.onesignal.OneSignalCacheCleaner.access$000(OneSignalCacheCleaner.java:11)
       at com.onesignal.OneSignalCacheCleaner$1.run(OneSignalCacheCleaner.java:40)
       at java.lang.Thread.run(Thread.java:761)

fchicken avatar Jan 13 '21 07:01 fchicken

Hi @fchicken and @WagesOfSin,

I am sorry it has been so long. I am checking in on this issue: we have updated the SDK to major release 4.x.x since these reports. Are you still on 3.x.x and seeing these crashes?

nan-li avatar Apr 05 '22 20:04 nan-li

@nan-li same stuff

SDK version -> 4.8.6

Device Info -> Brand: Asus Model: ZenFone Max Pro M1 (ZB602KL) (WW) / Max Pro M1 (ZB601KL) (IN) Version: Android 9

Fatal Exception: android.database.sqlite.SQLiteDiskIOException
Fatal Exception: android.database.sqlite.SQLiteDiskIOException: disk I/O error (code 4874 SQLITE_IOERR_SHMSIZE): , while compiling: PRAGMA journal_mode
       at android.database.sqlite.SQLiteConnection.nativePrepareStatement(SQLiteConnection.java)
       at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:903)
       at android.database.sqlite.SQLiteConnection.executeForString(SQLiteConnection.java:648)
       at android.database.sqlite.SQLiteConnection.setJournalMode(SQLiteConnection.java:333)
       at android.database.sqlite.SQLiteConnection.setWalModeFromConfiguration(SQLiteConnection.java:298)
       at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:217)
       at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:195)
       at android.database.sqlite.SQLiteConnectionPool.openConnectionLocked(SQLiteConnectionPool.java:503)
       at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:204)
       at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:196)
       at android.database.sqlite.SQLiteDatabase.openInner(SQLiteDatabase.java:880)
       at android.database.sqlite.SQLiteDatabase.open(SQLiteDatabase.java:865)
       at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:739)
       at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:729)
       at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:355)
       at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:298)
       at com.onesignal.OneSignalDbHelper.getSQLiteDatabase(OneSignalDbHelper.java:150)
       at com.onesignal.OneSignalDbHelper.getSQLiteDatabaseWithRetries(OneSignalDbHelper.java:177)
       at com.onesignal.OneSignalDbHelper.delete(OneSignalDbHelper.java:295)
       at com.onesignal.OSNotificationDataController$1.run(OSNotificationDataController.java:57)
       at java.lang.Thread.run(Thread.java:764)

GvinPin47 avatar Aug 03 '23 09:08 GvinPin47