fix(iOS): app crashes because of an SVG image#6949
fix(iOS): app crashes because of an SVG image#6949
Conversation
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the
WalkthroughThe Image component's asynchronous loading now applies maximum dimension constraints of 1000×1000 pixels to loaded images, preventing excessive memory consumption that was causing iOS app crashes when SVG files were posted in channels. Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches🧪 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 |
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
app/containers/message/Components/Attachments/Image/Image.tsx (1)
26-38: Add a.catch()handler to prevent unhandled promise rejections.The
maxHeightandmaxWidthoptions are correctly supported inexpo-image@2.3.2and are the recommended approach for preventing memory exhaustion from large SVGs on iOS. However, the promise chain lacks a.catch()handler, which could result in unhandled promise rejections if image loading fails:Suggested improvement
useEffect(() => { if (status === 'downloaded') { Image.loadAsync(uri, { onError: e => { log(e); }, maxHeight: 1000, maxWidth: 1000 - }).then(image => { + }) + .then(image => { setImageDimensions({ width: image.width, height: image.height }); - }); + }) + .catch(e => { + log(e); + }); } }, [uri, status]);
Proposed changes
The iOS app was crashing when opening a room that contains an SVG image.
Issue(s)
Closes: #6947
https://rocketchat.atlassian.net/browse/CORE-1764
How to test or reproduce
Screenshots
Types of changes
Checklist
Further comments
Took reference from expo/expo#38323
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.