istornz / flutter_live_activities

A Flutter plugin to use iOS 16.1+ Live Activities ⛹️ & iPhone Dynamic Island 🏝️ features
https://dimitridessus.fr/
MIT License
161 stars 48 forks source link

LiveActivityImageFromUrl doesn't work #46

Closed RadwaAlaa closed 7 months ago

charlesRmajor commented 11 months ago

This is the error message I'm seeing:

[VERBOSE-2:dart_vm_initializer.cc(41)] Unhandled Exception: Unsupported operation: Infinity or NaN toInt
#0      double.toInt (dart:core-patch/double.dart)
#1      double.round (dart:core-patch/double.dart:193:34)
#2      AppGroupsImageService.sendImageToAppGroups (package:live_activities/services/app_groups_image_service.dart:65:72)
<asynchronous suspension>
#3      LiveActivities.createActivity (package:live_activities/live_activities.dart:32:5)
<asynchronous suspension>
charlesRmajor commented 10 months ago

Ah! I think it's only an issue if you're using the 'resizeFactor'. When I take that parameter out, it works.

istornz commented 10 months ago

Thanks for the explanation @charlesRmajor, Is it reproductible with any image links (can't test for now) or a specific link?

aumb commented 7 months ago

This is caused when using LiveActivityImageFromUrl with a resize factor < 1 because the compression package being used is unable to get the properties which leads to dividing by 0 on

(properties.height! * targetWidth / properties.width!).round(),

which yields infinity

PS the package being used for compression is discontinued

Edit: adding a picture that reproduces the issue

https://media.istockphoto.com/id/1505391132/photo/summer-joy.jpg?s=1024x1024&w=is&k=20&c=qX2kUiJXovswCTHVpxt9D7XlJFLRDGmfH7z2CxKxD_Q=