notes-android icon indicating copy to clipboard operation
notes-android copied to clipboard

SingleNoteWidget performs synchronous Room DB queries on main thread (may cause ANR/jank)

Open nbd-boss opened this issue 3 weeks ago • 0 comments

This issue respects the following points:

Describe the bug

Description

In SingleNoteWidget.kt, it performs synchronous Room database queries on the main thread. This happens inside the onReceive()updateAppWidget()getSingleNoteWidgetData() call chain.

Where the issue occurs

onReceive() runs on the main/UI thread. onReceive() calls updateAppWidget, and inside updateAppWidget it calls getSingleNoteWidgetData. getSingleNoteWidgetData() is a blocking Room query, and since it is executed directly in onReceive(), it blocks the main thread.

What Android recommends

According to official guidelines:

Disk I/O and DB queries must not run on the main thread. BroadcastReceiver should do only lightweight work. Heavy work should be moved to a background thread (Executor / Coroutine / WorkManager).

Expected behavior

Move the database read into a background thread.

Notes Android version

4.5.2

Notes server version

4.5.2

Nextcloud Android version

4.5.2

Nextcloud version

4.5.2

Device

Android Emulator

Android Version

Android Version: 13 (API 33)

App Store

  • [ ] Google Play Store
  • [x] F-Droid
  • [ ] Huawei App Gallery

Stacktrace

No response

nbd-boss avatar Nov 28 '25 07:11 nbd-boss