fix: prevent SVG crash on iOS and enable rendering on Android#6949
fix: prevent SVG crash on iOS and enable rendering on Android#6949
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:
WalkthroughWhen message image status is Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 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 in[email protected]and 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]);
OtavioStasiak
left a comment
There was a problem hiding this comment.
Looks good to me!
Run e2e tests and you can merge it :)
Proposed changes
This pull request fixes issues related to SVG image handling in channel messages.
iOS app crashed when a room contained an SVG image, and Android failed to render SVG images altogether. This update ensures consistent and stable behavior across both platforms by preventing the crash on iOS and enabling proper SVG rendering on Android.
Issue(s)
Closes: #6947
https://rocketchat.atlassian.net/browse/CORE-1764
https://rocketchat.atlassian.net/browse/CORE-1812
How to test or reproduce
Screenshots
SVG image is not crashing iOS App and rendering without any issue

Types of changes
Checklist
Further comments
Took reference from expo/expo#38323
Summary by CodeRabbit