Skip to content

[FLW-Mobile-App] Perf: Move synchronous File I/O and image compression to Dispatchers.IO to prevent ANRs #157

@vibhutomer

Description

@vibhutomer

Description:
Currently, heavy file manipulation tasks—such as decoding Base64 strings, copying URIs to temporary files, and writing to the cache directory—are executing on the Main/UI thread in several repository modules. This blocks the main thread, causing the UI to freeze and significantly increasing the risk of Application Not Responding (ANR) crashes, particularly on lower-end devices used by field workers.

Affected Files (in FLW-Mobile-App):

  • SaasBahuSammelanRepo.kt
  • VLFRepo.kt
  • UwinRepo.kt
  • MaaMeetingRepo.kt

Expected Behavior:
All disk read/write operations, decoding, and file compressions should be offloaded to a background coroutine dispatcher to ensure the UI remains responsive during data saves.

Suggested Fix:
Wrap the synchronous file manipulation and I/O blocks inside a coroutine scope using withContext(Dispatchers.IO) { ... }.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions