ExoPlayer icon indicating copy to clipboard operation
ExoPlayer copied to clipboard

Certain Devices are crashing with SQLiteException when using DownloadManager

Open vaibhav-sharechat opened this issue 4 years ago • 11 comments

StackTrace

Fatal Exception: android.database.sqlite.SQLiteException: unknown error (code 0 SQLITE_OK): Native could not read blob slot
       at android.database.CursorWindow.nativeGetBlob(CursorWindow.java)
       at android.database.CursorWindow.getBlob(CursorWindow.java:434)
       at android.database.AbstractWindowedCursor.getBlob(AbstractWindowedCursor.java:47)
       at com.google.android.exoplayer2.offline.DefaultDownloadIndex.getDownloadForCurrentRow(DefaultDownloadIndex.java:441)
       at com.google.android.exoplayer2.offline.DefaultDownloadIndex.access$100(DefaultDownloadIndex.java:39)
       at com.google.android.exoplayer2.offline.DefaultDownloadIndex$DownloadCursorImpl.getDownload(DefaultDownloadIndex.java:550)
       at com.google.android.exoplayer2.offline.DownloadManager$InternalHandler.initialize(DownloadManager.java:804)
       at com.google.android.exoplayer2.offline.DownloadManager$InternalHandler.handleMessage(DownloadManager.java:737)
       at android.os.Handler.dispatchMessage(Handler.java:107)
       at android.os.Looper.loop(Looper.java:226)
       at android.os.HandlerThread.run(HandlerThread.java:67)

ExoPlayer Version Used

2.14.0

42% crashes are on Vivo device Any help with the issue would be great. Thanks

vaibhav-sharechat avatar Jul 23 '21 07:07 vaibhav-sharechat

Thanks for reporting.

The problem originates from DefaultDownloadIndex.getDownloadForCurrentRow():441 when we call cursor.getBlob() for that the javadoc says The result and whether this method throws an exception when the column value is null or the column type is not a blob type is implementation-defined. The error message comes from native sqllite code and it looks like its about an empty value read.

We try to read keySetId (added with 2.12.0) and from what DefaultDownloadIndex does, it looks that we would expect that both conditions from the javadoc quote above are taken care of. The field is defined and we always set a value. Although the value we set when keySetId is null is an empty byte array. Then again, we do that for other blob fields in the same way and we did so before 2.12.0.

These things together with you saying it's happening on some devices makes me think we should look some closer into this.

Some questions so we can make this actionable for us:

I assume you can't repro yourself but only see this in the crash reporting tool. Can you give me some more detailed information on which devices you see this? Like exact model numbers and the OS version? We probably need such a device for proper testing in any case.

Is your content protected or not? Or in other words: am I correct with my assumption that keySetId is null for your download which means unprotected content?

Do you store custom data with your download like with DownloadHelper.getDownloadRequest(@Nullable byte[] data) or DownloadRequest.Builder.setData(byte[] data)?

Have you recently upgraded ExoPlayer in your application like for example from a version before 2.12.0 to a version after 2.12.0? Can you correlate these errors with that upgrade?

marcbaechinger avatar Jul 23 '21 23:07 marcbaechinger

@marcbaechinger Thanks for looking into it. Yes we are not able to reproduce it. We got this from firebase crash reporting. Some of the devices according to firebase are

  • Vivo 1820
  • Vivo 1906
  • Xiaomi Redmi 8A Dual
  • Xiaomi Redmi 8A
  • Xiaomi Redmi 9

36% of crashes are in Android 10, 20% in Android 9 and 8 so I am assuming it's not Android version related. 30% of crashes are in background if it helps in debugging.

No out content is not protected.

No we don't store custom data along with out. We use DownloadRequest.Builder(key, uri) .build()

Yes we updated our app from 2.11.7 to 2.14.0

vaibhav-sharechat avatar Jul 25 '21 22:07 vaibhav-sharechat

Hi @marcbaechinger any update on this one ?

vaibhav-sharechat avatar Aug 17 '21 09:08 vaibhav-sharechat

Not yet I'm afraid.

Can you let me know how many percent of your users are affected by this?

marcbaechinger avatar Aug 18 '21 13:08 marcbaechinger

Hey @vaibhav-sharechat. We need more information to resolve this issue but there hasn't been an update in 14 weekdays. I'm marking the issue as stale and if there are no new updates in the next 7 days I will close it automatically.

If you have more information that will help us get to the bottom of this, just add a comment!

google-oss-bot avatar Sep 07 '21 01:09 google-oss-bot

Since there haven't been any recent updates here, I am going to close this issue.

@vaibhav-sharechat if you're still experiencing this problem and want to continue the discussion just leave a comment here and we are happy to re-open this.

google-oss-bot avatar Sep 16 '21 01:09 google-oss-bot

Re-opening with extra info from #10686 from @0xera:

I have absolutely same problem on these devices with android 9/10/11

  • Honor/Huawei:
    • 8.63% HONOR 10 LITE (ANDROID 10)
    • 6.98% HONOR 20S (ANDROID 10)
    • 6.07% HONOR 9X LITE (ANDROID 10)
    • 5.48% HUAWEI NOVA 5T (ANDROID 10)
    • 5.36% HUAWEI P SMART Z (ANDROID 10)
    • 83.34% ANDROID 10
    • 14.13% ANDROID 9
  • Xiaomi:
    • 7% Redmi Note 9 (ANDROID 11)
    • 5% Redmi Note 8T (ANDROID 11)
    • 5% Redmi 9 (ANDROID 11)
    • 4% Redmi Note 8 (ANDROID 11)
    • 4% Redmi Note 9S (ANDROID 11)
    • 100% ANDROID 11

icbaker avatar Oct 13 '22 09:10 icbaker

So I think this maybe happen because some vendor do something with sqlite for optimization. Maybe for fix add to exoplayer opportunity to use other databases or sqlite from Jetpack?

0xera avatar Oct 13 '22 13:10 0xera

@vaibhav-sharechat did you fix this?

0xera avatar Nov 04 '22 12:11 0xera

any news?

0xera avatar Dec 01 '22 18:12 0xera

Hello!

Let me revive this issue with some new info. We are also experiencing this crash on certain devices:

  • Samsung Galaxy Note9 / OS Android 10
  • Huawei P Smart Z / OS Android 10

We are using ExoPlayer version v2.19.1., and we are setting custom data via DownloadRequest.Builder.setData(byte[] data). Custom data is simple data object with two strings (one for some name, and the other for some id) and we convert it to byte array via Gson. Could this be the root cause of the issue?

Thanks!

icutvaric avatar Dec 18 '24 09:12 icutvaric