google / ExoPlayer

This project is deprecated and stale. The latest ExoPlayer code is available in https://github.com/androidx/media
https://developer.android.com/media/media3/exoplayer
Apache License 2.0
21.73k stars 6.03k forks source link

Certain devices crash with an SQLiteCantOpenDatabaseException when attempting to init the cache #9041

Open AChep opened 3 years ago

AChep commented 3 years ago
android.database.sqlite.SQLiteCantOpenDatabaseException: 
  at android.database.sqlite.SQLiteConnection.nativeOpen (Native Method)
  at android.database.sqlite.SQLiteConnection.open (SQLiteConnection.java:300)
  at android.database.sqlite.SQLiteConnection.open (SQLiteConnection.java:218)
  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:1386)
  at android.database.sqlite.SQLiteDatabase.open (SQLiteDatabase.java:1331)
  at android.database.sqlite.SQLiteDatabase.openDatabase (SQLiteDatabase.java:967)
  at android.database.sqlite.SQLiteDatabase.openDatabase (SQLiteDatabase.java:955)
  at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked (SQLiteOpenHelper.java:458)
  at android.database.sqlite.SQLiteOpenHelper.getReadableDatabase (SQLiteOpenHelper.java:415)
  at com.google.android.exoplayer2.upstream.cache.CachedContentIndex$DatabaseStorage.exists (CachedContentIndex.java:799)
  at com.google.android.exoplayer2.upstream.cache.CachedContentIndex.initialize (CachedContentIndex.java:202)
  at com.google.android.exoplayer2.upstream.cache.SimpleCache.initialize (SimpleCache.java:582)
  at com.google.android.exoplayer2.upstream.cache.SimpleCache.access$000 (SimpleCache.java:49)
  at com.google.android.exoplayer2.upstream.cache.SimpleCache$1.run (SimpleCache.java:268)

It has happened on these devices:

It seems to be related to the https://github.com/google/ExoPlayer/issues/8251 although I do not alter the configuration.

marcbaechinger commented 3 years ago

Can you reproroduce this with the ExoPlayer demo app as well?

If this happens only with your app can you add some details about the DatabaseProvider that you are using? Like where is the database supposed to be stored and does the app have permission to access it (eg. on external storage)?

AChep commented 3 years ago

I'm using the ExoDatabaseProvider with the default configuration. No, I'm unable to reproduce it and have never seen it on my test device.

ojw28 commented 3 years ago

How many occurrences of this issue are you actually seeing in production? If the volume of crashes is very low, then it's probably a platform issue related to some rarely occurring state, which would be much less worth investigating.

AChep commented 3 years ago

This does not happen frequently, the user has a chance of ~0.0007 to witness the crash by himself in 30 days.

chhatrasal01 commented 1 year ago

@ojw28 I am also getting similar crash. For me it crashed 944 times for 912 users in last 90 days, so this is blocker crash for the app.

Fatal Exception: android.database.sqlite.SQLiteDatabaseLockedException: database is locked (code 5 SQLITE_BUSY) at android.database.sqlite.SQLiteConnection.nativeExecuteForLong(SQLiteConnection.java) at android.database.sqlite.SQLiteConnection.executeForLong(SQLiteConnection.java:776) at android.database.sqlite.SQLiteSession.executeForLong(SQLiteSession.java:654) at android.database.sqlite.SQLiteStatement.simpleQueryForLong(SQLiteStatement.java:110) at android.database.DatabaseUtils.longForQuery(DatabaseUtils.java:1017) at android.database.DatabaseUtils.longForQuery(DatabaseUtils.java:1005) at android.database.sqlite.SQLiteDatabase.getVersion(SQLiteDatabase.java:1094) at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:389) at android.database.sqlite.SQLiteOpenHelper.getReadableDatabase(SQLiteOpenHelper.java:340) at com.google.android.exoplayer2.upstream.cache.CachedContentIndex$DatabaseStorage.exists(CachedContentIndex.java:798) at com.google.android.exoplayer2.upstream.cache.CachedContentIndex.initialize(CachedContentIndex.java:201) at com.google.android.exoplayer2.upstream.cache.SimpleCache.initialize(SimpleCache.java:582) at com.google.android.exoplayer2.upstream.cache.SimpleCache.access$000(SimpleCache.java:49) at com.google.android.exoplayer2.upstream.cache.SimpleCache$1.run(SimpleCache.java:268)

I am using Room as the local database and exoplyer2 for playing and downloading video. I checked on SO for solution and as per this https://stackoverflow.com/a/7930375/7322895, we can handle this by using only 1 instance of SQLiteOpenHelper. But when we use exoplanyer's DatabaseProvider it uses old android.database.sqlite.SQLiteOpenHelper class and Room uses latest androidx SQLite androidx.sqlite.db.SupportSQLiteOpenHelper class. Can we migrate to new androidx library for database access, so that we can provide room database to exoplayer's SimpleCache and there by creating only 1 instance of SQLIteOpenHelper in the app?

andrewlewis commented 1 year ago

@chhatrasal01 Maybe the fix in #10959 will help with this (the error looks the same).