Skip to content
This repository has been archived by the owner on Nov 1, 2022. It is now read-only.

Prevent RecentlyClosedTabsStorage exceptions #12310

Closed
Mugurell opened this issue Jun 10, 2022 · 2 comments
Closed

Prevent RecentlyClosedTabsStorage exceptions #12310

Mugurell opened this issue Jun 10, 2022 · 2 comments
Assignees
Labels
b:crash <recentlyclosed> Components: feature-recentlyclosed

Comments

@Mugurell
Copy link
Contributor

Mugurell commented Jun 10, 2022

Saw in mozilla-mobile/fenix#25562 that apps may still crash when too much data was persisted in Room and then queried.

E/SQLiteQuery(14924): exception: Row too big to fit into CursorWindow requiredPos=1, totalRows=2; query: SELECT *
E/SQLiteQuery(14924):         FROM recently_closed_tabs
E/SQLiteQuery(14924):         ORDER BY created_at DESC
E/ExceptionHandler(14924): Uncaught exception handled:
E/ExceptionHandler(14924): android.database.sqlite.SQLiteBlobTooBigException: Row too big to fit into CursorWindow requiredPos=1, totalRows=2
E/ExceptionHandler(14924):   at android.database.sqlite.SQLiteConnection.nativeExecuteForCursorWindow(Native Method)
E/ExceptionHandler(14924):   at android.database.sqlite.SQLiteConnection.executeForCursorWindow(SQLiteConnection.java:1001)
E/ExceptionHandler(14924):   at android.database.sqlite.SQLiteSession.executeForCursorWindow(SQLiteSession.java:838)
E/ExceptionHandler(14924):   at android.database.sqlite.SQLiteQuery.fillWindow(SQLiteQuery.java:62)
E/ExceptionHandler(14924):   at android.database.sqlite.SQLiteCursor.fillWindow(SQLiteCursor.java:161)
E/ExceptionHandler(14924):   at android.database.sqlite.SQLiteCursor.onMove(SQLiteCursor.java:131)
E/ExceptionHandler(14924):   at android.database.AbstractCursor.moveToPosition(AbstractCursor.java:248)
E/ExceptionHandler(14924):   at android.database.AbstractCursor.moveToNext(AbstractCursor.java:280)
E/ExceptionHandler(14924):   at mozilla.components.feature.recentlyclosed.db.RecentlyClosedTabDao_Impl$4.call(RecentlyClosedTabDao_Impl.java:13)

This exception was intended to be suppressed with a try-catch but a try-catch would only work if we would also collect the stream.

To avoid the exception we should use the declarative way - the catch operator instead of the imperative way - a try-catch block.

┆Issue is synchronized with this Jira Task

@Mugurell Mugurell added <recentlyclosed> Components: feature-recentlyclosed b:crash labels Jun 10, 2022
@Mugurell Mugurell self-assigned this Jun 10, 2022
Mugurell added a commit to Mugurell/android-components that referenced this issue Jun 10, 2022
Using a UI test to validate the functionality was needed since the
SQLiteBlobTooBigException was not being thrown for an in-memory database used
in unit tests.
@jonalmeida
Copy link
Contributor

Nice find and example code. 🙂

mergify bot pushed a commit that referenced this issue Jun 14, 2022
Using a UI test to validate the functionality was needed since the
SQLiteBlobTooBigException was not being thrown for an in-memory database used
in unit tests.
@csadilek
Copy link
Contributor

Fixed by #12312.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
b:crash <recentlyclosed> Components: feature-recentlyclosed
Projects
None yet
Development

No branches or pull requests

3 participants