compose: Resolve local attachment dimensions with EXIF orientation#6519
Conversation
PR checklist ✅All required conditions are satisfied:
🎉 Great job! This PR is ready for review. |
SDK Size Comparison 📏
|
c90fd87 to
c79725b
Compare
WalkthroughThe compose module now resolves local image and video attachment dimensions before returning attachments. A new utility reads bitmap bounds, EXIF orientation, and media metadata, and tests cover image and video rotation cases. ChangesLocal attachment dimension resolution
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In
`@stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/util/StorageHelperWrapper.kt`:
- Around line 92-100: `getSelectedAttachments()` and the attachment-building
flow in `StorageHelperWrapper` are doing blocking dimension resolution on the
caller thread. Move the work in
`getAttachmentsFromUris`/`getAttachmentsForUpload` and the
`LocalAttachmentDimensionsResolver.resolveDimensions(...)` call behind
`withContext(Dispatchers.Default)` or make the API suspend so
`AttachmentsPickerViewModel` does not run `BitmapFactory.decodeFile` /
`MediaMetadataRetriever` on Main. Keep the change localized around
`StorageHelperWrapper` and the helper methods that create `Attachment` objects.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: a3696281-1e04-4fa7-bd8c-cc0b555742bd
📒 Files selected for processing (6)
gradle/libs.versions.tomlstream-chat-android-compose/build.gradle.ktsstream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/util/LocalAttachmentDimensionsResolver.ktstream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/util/StorageHelperWrapper.ktstream-chat-android-compose/src/test/kotlin/io/getstream/chat/android/compose/ui/util/LocalAttachmentDimensionsResolverExifTest.ktstream-chat-android-compose/src/test/kotlin/io/getstream/chat/android/compose/ui/util/LocalAttachmentDimensionsResolverTest.kt
|


Goal
On v6, locally picked images/videos never get
Attachment.originalWidth/originalHeight, so they render as a square (1:1 fallback). The backend only backfills dimensions from Stream CloudFrontow/ohparams, so custom-CDN customers never get them. Fix has to be client-side.Backports the v7 client-side dimension resolution (with EXIF orientation) to v6.
Closes AND-1263
Implementation
LocalAttachmentDimensionsResolver(Compose): resolves dimensions from the local file when both are null, copies them onto theAttachment.BitmapFactorybounds, swapped for EXIF orientations that flip the ratio (ROTATE_90/270,TRANSPOSE,TRANSVERSE).MediaMetadataRetrieverwidth/height, swapped for 90/270 rotation.StorageHelperWrapper.getAttachmentsFromMetaData(already off the main thread). Adds theandroidx.exifinterfacedependency.No public API change. v6 has no
AttachmentStorageHelper, so only the Compose pick flow is touched (no XML changes).UI Changes
Screen_recording_20260625_103615.webm
Screen_recording_20260625_103451.webm
Testing
ow/ohin URL).Summary by CodeRabbit
New Features
Bug Fixes
Tests