flutter_local_notifications icon indicating copy to clipboard operation
flutter_local_notifications copied to clipboard

Trying to cancel set notifications using isolate, still blocks the main UI

Open abdimussa87 opened this issue 1 year ago • 3 comments

Describe the bug So I was trying to cancel around 295 notifications set using the cancelAll() method. I noticed an issue in performance and decided to use an isolate so that the main thread won't get blocked. However, even when using isolates, I'm experiencing the same issue where the UI freezes when the cancelAll() method executes.

To Reproduce

Here's a simple, reproducible step:

  1. Clone the forked repo provided below, and add Google Maps Api key inside the AndroidManifest.xml
  2. Click schedule notifications which first cancels all notifications(if set), then schedules 295 notifications.
  3. Then click on cancel all notifications and observe the UI being unresponsive when dragging the map around for some seconds.

Expected behavior The UI doesn't freeze

Sample code to reproduce the problem Fork of the repo that contains updated code in the main.dart

abdimussa87 avatar Jan 07 '24 13:01 abdimussa87

Same here, the cancel functions are blocking the UI thread and taking long time for some reason.

naamapps avatar Jan 19 '24 16:01 naamapps

Do we have any updates on this @MaikuB? I've had issues on some devices, like in Samsung Flip 3 with Android 14 One UI 6, when the app cancels all alarms and creates 500 new alarms the app freezes and shows not responding.

image

Lzyct avatar Feb 21 '24 07:02 Lzyct

This is something the community will need to contribute a solution for that would ideally avoid adding an API for that involves a batch of notifications. There had been contributions in the pass but they ended up causing problems so was reverted to the current state.

Should also mention iOS has a limit of 64 notifications that is mentioned in the readme. Mentioning this as presumably developers here are targeting iOS as well and given the numbers mentioned, it may mean that this fact has been missed and could lead to inconsistent behaviour on both Android and iOS

MaikuB avatar Feb 21 '24 07:02 MaikuB