WidgetKit timeline crashes with EXC_RESOURCE (memory limit=30MB) when generating entries from a large photo album

Environment: Xcode 15/16, iOS 17/18, WidgetKit (IntentTimelineProvider)

Issue: I have a photo widget that lets users pick an album and rotate through its photos on a timer (configurable refresh interval). When the selected album is large, the widget extension is Jetsam-killed with:

Thread X: EXC_RESOURCE (RESOURCE_TYPE_MEMORY: high watermark memory limit exceeded) (limit=30 MB)

After this happens, the widget stops refreshing entirely and stays on a stale/placeholder image until the app is relaunched.

What I've tried:

  • Downsampling with CGImageSourceCreateThumbnailAtIndex + kCGImageSourceThumbnailMaxPixelSize before building entries
  • Reducing entry count and using policy .after(nextDate) instead of pre-building a full day of entries
  • Still seeing intermittent Jetsams on albums with several hundred photos

Questions:

  1. Is there a recommended max total archived timeline size WidgetKit expects developers to stay under, beyond "keep it small"?
  2. For a "large photo album" use case specifically, is the recommended pattern to pre-generate and cache small thumbnails in the App Group container ahead of time, rather than downsampling on demand inside getTimeline()?
  3. Is there guidance on how many timeline entries is "too many" before WidgetKit itself starts struggling to archive/deliver them, independent of image size?

useful than a forum thread — let me know what info would help most.

WidgetKit timeline crashes with EXC_RESOURCE (memory limit=30MB) when generating entries from a large photo album
 
 
Q