Ok, I've been able to narrow down the issue and I have a workaround.
I'd love to have more detail about the changes that necessitated this in iOS 18.3, but seem to have been reverted in iOS 18.4.
The main fix is adding a new WidgetImage function which downsizes an image like so:
func WidgetImage(_ name: String, size: CGFloat) -> Image {
guard let uiImage = UIImage(named: name) else {
Logger.error("WidgetImage missing \(name)")
return Image(systemName: "exclamationmark.triangle")
}
let thumbnailSize = CGSize(width: size, height: size)
guard let thumbnail = uiImage.preparingThumbnail(of: thumbnailSize) else {
Logger.error("WidgetImage thumbnail error \(name)")
return Image(systemName: "exclamationmark.triangle")
}
return Image(uiImage: thumbnail)
}
Usage example, where previously we would have:
Image(icon)
.resizable()
.widgetAccentedRenderingMode(.accented)
.scaledToFit()
.frame(width: 58.0, height: 58.0)
...we update to use WidgetImage:
WidgetImage(icon, size: 58.0)
.resizable()
.widgetAccentedRenderingMode(.accented)
.scaledToFit()
.frame(width: 58.0, height: 58.0)
Please let me know if there's a better way to handle this, or any other suggestions.
Note that we did downsize our images to the 58x58 size, but even resizing them down to 20x20 as we use in some places causes issues.
Note also that this workaround fails for images with different light/dark appearance modes. For those cases, we continue using Image() and try to keep the images as small as possible to stay under the memory limit.
Thanks!
Topic:
App & System Services
SubTopic:
Widgets & Live Activities