Fix share extension crash on HD photos#409
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughShareIncomingPayload image loading now prefers URL-based ImageIO downsampling, falls back to Data-based downsampling, and removes the previous in-memory UIImage loading/downscaling path. Adds three private helpers to produce downsampled JPEG data from URL, Data, or CGImageSource; filename derives from URL when present. Changes
Sequence Diagram(s)sequenceDiagram
participant Provider as ItemProvider
participant FS as FileURL
participant Downsampler as DownsampleHelpers
participant Caller as ShareIncomingPayload.loadImage
Caller->>Provider: request image item
alt Provider supplies a file URL
Provider->>FS: deliver file URL
FS->>Downsampler: downsample from URL (ImageIO)
Downsampler->>Caller: return JPEG data + filename(from URL)
else Provider supplies raw Data
Provider->>Downsampler: deliver Data
Downsampler->>Caller: downsample via CGImageSource -> JPEG data + provider name
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Use ImageIO (CGImageSource) to downsample images instead of loading the full bitmap into memory. A 48MP photo is ~185MB uncompressed, which exceeds the ~120MB memory limit for app extensions. The image loading now uses a tiered approach: 1. loadFileRepresentation — gets a temp file URL, downsamples via ImageIO without ever decoding the full bitmap (preferred path). 2. loadItem URL/Data fallback — same ImageIO downsampling. 3. loadItem UIImage fallback — provider already decoded the bitmap, so serialize to JPEG (minimal extra allocation) then downsample. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Summary
CGImageSourceto downsample directly from file URLs instead of loading the full bitmap into memoryTest plan
🤖 Generated with Claude Code
Summary by CodeRabbit