-
Notifications
You must be signed in to change notification settings - Fork 211
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[CIS-2152] Add support for CDN v2 #2339
Conversation
Generated by 🚫 Danger |
LateResize was not doing any actual resize, loading the full bytes of the image.
…bility to just download
2247a33
to
90b67e1
Compare
📏 Size AnalysisTotal install size 10.5 MB | This change: ⬆️ +33.3 kB (+0.317%)🗂 See size breakdown
🔎 See the full size analysis (2459d11) merging into develop (f065659)
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work @nuno-vieira 👏
I've added some comments and I still need to do the manual QA. Also, please see why the checks are failing.
Additionally, let's revisit the breaking changes again.
Sources/StreamChatUI/ChatMessageList/Attachments/ChatMessageImageGallery+ImagePreview.swift
Show resolved
Hide resolved
c1f66d2
to
7183420
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM ✅ Also did some manual QA, everything works smoothly.
About the tuples thing, it's really up-to you, if you feel that's more intuitive, we can merge it like this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lovely to see this finally happening.
I just have one concern around braking changes and possible behavior changes.
Is there any way to keep the current APIs but with a deprecation warning instead of completely removing them? Also, is there any chance that the behavior changes for existing customers after these changes?
3d45409
to
1802b0b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
great work 👏 ready to be merged IMO.
Kudos, SonarCloud Quality Gate passed! |
Did a round of QA, LGTM 🚢 |
} | ||
|
||
/// The formula to calculate the new resolution is based on the max pixels and | ||
/// the original aspect ratio. To get the formula, a system of questions is needed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
System of equations 🙃 🤦♂️
🔗 Issue Links
CIS-2152
🎯 Goal
Use Stream's CDN v2 to improve the memory footprint of the application. Now, images are downloaded with a lower resolution instead of the original one.
📝 Summary
ImageLoading
APIImageCDN
with some needed breaking changesComposerVC.addAttachmentToContent()
has a newinfo
property (minor breaking change)CGSize.avatarThumbnailSize
and moves it toComponents.default
🛠 Implementation
ImageCDN
required breaking changes so that the API is more understandable but also more scalable. The breaking changes are also minimal and will be documented in the changelog.🎨 Showcase
Since we are reducing the resolution of the loaded images, the memory footprint reduces a lot. Doing a test with a message list with about 16 images that have high resolution, the memory footprint is reduced by ~6x times.
After exporting the memory graph and analysing with
VVMap
, we can see that especially the Image Raster data is much lower:The reason for these improvements is that for memory use the image resolution is the most important, not the file size. The memory is used by the decoding and decompression of the image which is dependent on the resolution.
For example, if we are talking about an image of 3300x4500, that will be 57MB! For only one image. Since each pixel takes up 4 bytes (if sRGB), we can calculate this with the following formula
3300 * 4500 * 4 / 1024 / 1024 = 56.6MB
.🧪 Manual Testing Notes
☑️ Contributor Checklist
🎁 Meme