Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zonedSchedule with larger image leads to TransactionTooLargeException #2291

Open
dkaschl opened this issue Apr 5, 2024 · 3 comments
Open

Comments

@dkaschl
Copy link

dkaschl commented Apr 5, 2024

Hi!
First of all, thank you for creating this simply amazing flutter plugin! Can't appreciate your work enough!
I have got a question though. I want to show detailed pictures within a notification. While it works great on immediate show, however when using the zonedSchedule I always get the TransactionTooLargeException unless I scale down the image to a level where it simply isn't detailed enough.
As far as I understood with my nearly non existing Android programming knowledge the underlying PendingIntent does not allow parcel sizes above 1MB or so.
Is there any other way to schedule notifications showing detailed pictures?

@GGGuenni
Copy link

GGGuenni commented Apr 23, 2024

Hi, we are having similar problems when scheduling notifications.
The issue is Andorid only for us.
flutter_local_notifications package at version 15.1.1
We schedule around 7 notifications with one image each. The images have a max size of 76KB but most of them are more around 30KB so we have no clue how that could end up with 1.2MB like in the following stacktrace.
Does the parcel size stack with each scheduled notification?
We do add the image bytes to the androidStyleInformation (BigPictureStyleInformation) and to the AndroidNotificationDetails directly using the largeIcon parameter so that could double the size per notification?

Stacktrace

Fatal Exception: java.lang.RuntimeException: Unable to start receiver com.dexterous.flutterlocalnotifications.ScheduledNotificationBootReceiver: java.lang.RuntimeException: android.os.TransactionTooLargeException: data parcel size 1211448 bytes
       at android.app.ActivityThread.handleReceiver(ActivityThread.java:4905)
       at android.app.ActivityThread.-$$Nest$mhandleReceiver()
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2498)
       at android.os.Handler.dispatchMessage(Handler.java:106)
       at android.os.Looper.loopOnce(Looper.java:230)
       at android.os.Looper.loop(Looper.java:319)
       at android.app.ActivityThread.main(ActivityThread.java:8893)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:608)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1103)

Caused by java.lang.RuntimeException: android.os.TransactionTooLargeException: data parcel size 1211448 bytes
       at android.app.PendingIntent.getBroadcastAsUser(PendingIntent.java:759)
       at android.app.PendingIntent.getBroadcast(PendingIntent.java:735)
       at com.dexterous.flutterlocalnotifications.FlutterLocalNotificationsPlugin.getBroadcastPendingIntent(:11)
       at com.dexterous.flutterlocalnotifications.FlutterLocalNotificationsPlugin.zonedScheduleNotification(:26)
       at com.dexterous.flutterlocalnotifications.FlutterLocalNotificationsPlugin.rescheduleNotifications(:36)
       at com.dexterous.flutterlocalnotifications.ScheduledNotificationBootReceiver.onReceive(:38)
       at android.app.ActivityThread.handleReceiver(ActivityThread.java:4896)
       at android.app.ActivityThread.-$$Nest$mhandleReceiver()
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2498)
       at android.os.Handler.dispatchMessage(Handler.java:106)
       at android.os.Looper.loopOnce(Looper.java:230)
       at android.os.Looper.loop(Looper.java:319)
       at android.app.ActivityThread.main(ActivityThread.java:8893)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:608)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1103)

Caused by android.os.TransactionTooLargeException: data parcel size 1211448 bytes
       at android.os.BinderProxy.transactNative(BinderProxy.java)
       at android.os.BinderProxy.transact(BinderProxy.java:662)
       at android.app.IActivityManager$Stub$Proxy.getIntentSenderWithFeature(IActivityManager.java:7020)
       at android.app.PendingIntent.getBroadcastAsUser(PendingIntent.java:752)
       at android.app.PendingIntent.getBroadcast(PendingIntent.java:735)
       at com.dexterous.flutterlocalnotifications.FlutterLocalNotificationsPlugin.getBroadcastPendingIntent(:11)
       at com.dexterous.flutterlocalnotifications.FlutterLocalNotificationsPlugin.zonedScheduleNotification(:26)
       at com.dexterous.flutterlocalnotifications.FlutterLocalNotificationsPlugin.rescheduleNotifications(:36)
       at com.dexterous.flutterlocalnotifications.ScheduledNotificationBootReceiver.onReceive(:38)
       at android.app.ActivityThread.handleReceiver(ActivityThread.java:4896)
       at android.app.ActivityThread.-$$Nest$mhandleReceiver()
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2498)
       at android.os.Handler.dispatchMessage(Handler.java:106)
       at android.os.Looper.loopOnce(Looper.java:230)
       at android.os.Looper.loop(Looper.java:319)
       at android.app.ActivityThread.main(ActivityThread.java:8893)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:608)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1103)

@dkaschl
Copy link
Author

dkaschl commented Apr 23, 2024

Hi! I am pretty sure that those large numbers are the size of the uncompressed picture. Therefore a small 70kb JPG could easily reach 1MB if it's a uncompressed image file.
My workaround for the moment is to create a really small version of the image (100px width or so - just play around) which still works for zonedSchedule and add it as a largeIcon. Once the user clicks on the image, the app opens with the specific page which leads to the large image.

I assume if you would develop your own Intent on Android you could manage to get this zonedSchedule notification with a large image working...

@MaikuB
Copy link
Owner

MaikuB commented May 17, 2024

I might not have answer on this but how are you specifying the largeIcon? That you're running into this would make me think you're using either FilePathAndroidBitmap or ByteArrayAndroidBitmap and then run into the issue. If so, if you're already resizing the image perhaps you could look at include it as a a drawable resource in your app that I believe would solve the issue?

The only other thought you might to consider having the image downloaded on the native side before the notification is shown. The current APIs are built such that if an image comes from a remote source, it's assumed that it's already been downloaded as this allows the app to indicate the app is busy doing so and avoid the delay in showing a scheduled notification due to downloading an image. Worst, it could fail to download due to connectivity issues and then fail to show. In such cases, this sounds like a case for a customised solution with your own native code or a fork

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants