Change theme
Help
Press space for more information.
Show links for this issue (Shortcut: i, l)
Copy issue ID
Previous Issue (Shortcut: k)
Next Issue (Shortcut: j)
Sign in to use full features.
Vote: I am impacted
Notification menu
Refresh (Shortcut: Shift+r)
Go home (Shortcut: u)
Pending code changes (auto-populated)
View issue level access limits(Press Alt + Right arrow for more information)
Request for new functionality
View staffing
Description
Component used: Room.
Version used: 2.6.1.
Devices/Android versions reproduced on: Google Pixel 2 emulators with Android 10 and 11.
Steps to reproduce.
@Entity
with some property ofByteArray
type. This property is going to be turned by Room into an SQL table's column.@Dao
declaring only a couple of functions to write and read the entity [1] above.ByteArray
property filled by some random byte sequence of relatively big size - the issues start to appear when it is at least of about 1-2 MBs in its size.ByteArray
[3] is used there are usually no problems on this step.CursorWindow
, this data reading attempt will crash withSQLiteBlobTooBigException
.While it seems to be discouraged to keep large BLOBs in SQLite databases, I think it's better to provide an option for Room users to either get the crash in this case or just performance decrease with a corresponding warning in logcat.
Possible ways to avoid the crash.
CursorWindow
when buildingRoomDatabase
instances. Unsure if it can be easily done for all Android versions just by available public APIs.CursorWindow
. It can be done by querying thelength
of BLOB first and then reading it by chunks of, let's say, 1 MB by using another SQLite's function -substr
. There can be a config forandroidx.room.Room#databaseBuilder
to prefer such fallback reading for large BLOBs or just crash as it's done now.