Skip to content

fix(iOS): app crashes because of an SVG image#6949

Draft
Rohit3523 wants to merge 2 commits intodevelopfrom
svg-crash-fix
Draft

fix(iOS): app crashes because of an SVG image#6949
Rohit3523 wants to merge 2 commits intodevelopfrom
svg-crash-fix

Conversation

@Rohit3523
Copy link
Contributor

@Rohit3523 Rohit3523 commented Jan 26, 2026

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

  1. Send an SVG image using the web application
  2. Open the same channel in the iOS mobile app
  3. Observe the app crash when the room loads

Screenshots

Types of changes

  • Bugfix (non-breaking change which fixes an issue)
  • Improvement (non-breaking change which improves a current function)
  • New feature (non-breaking change which adds functionality)
  • Documentation update (if none of the other choices apply)

Checklist

  • I have read the CONTRIBUTING doc
  • I have signed the CLA
  • Lint and unit tests pass locally with my changes
  • I have added tests that prove my fix is effective or that my feature works (if applicable)
  • I have added necessary documentation (if applicable)
  • Any dependent changes have been merged and published in downstream modules

Further comments

Took reference from expo/expo#38323

Summary by CodeRabbit

  • Bug Fixes
    • Applied size constraints to message image loading to improve stability when handling images.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 26, 2026

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

  • 🔍 Trigger a full review

Walkthrough

The 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

Cohort / File(s) Summary
Image loading constraints
app/containers/message/Components/Attachments/Image/Image.tsx
Added maxHeight: 1000 and maxWidth: 1000 options to Image.loadAsync call to constrain image dimensions during asynchronous loading

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Suggested reviewers

  • OtavioStasiak
  • diegolmello

Poem

🐰 An SVG came to cause us strife,
The iOS app lost its life!
But now with bounds of thousand-squared,
No more crashes to be feared! ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title clearly identifies the main change: fixing an iOS app crash caused by SVG images, which directly aligns with the changeset's image size limitation fix.
Linked Issues check ✅ Passed The changes directly address the core objective from issues #6947 and CORE-1764: preventing iOS app crashes when SVG images are present. The fix adds maxHeight and maxWidth constraints to image loading, which resolves the SVG-related crash issue.
Out of Scope Changes check ✅ Passed All changes are scoped to fixing the SVG crash issue. The modification to Image.loadAsync parameters is a targeted fix directly addressing the linked issues with no extraneous changes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch svg-crash-fix

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@Rohit3523 Rohit3523 changed the title Pass max height and width in load async fix: svg image cause app crash Jan 26, 2026
@Rohit3523 Rohit3523 had a problem deploying to official_android_build January 26, 2026 20:13 — with GitHub Actions Error
@Rohit3523 Rohit3523 had a problem deploying to experimental_android_build January 26, 2026 20:13 — with GitHub Actions Error
@Rohit3523 Rohit3523 had a problem deploying to experimental_ios_build January 26, 2026 20:13 — with GitHub Actions Error
@Rohit3523 Rohit3523 changed the title fix: svg image cause app crash fix(iOS): app crashes because of an SVG image Jan 26, 2026
@Rohit3523
Copy link
Contributor Author

@coderabbitai review

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 26, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 maxHeight and maxWidth options are correctly supported in expo-image@2.3.2 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]);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: iOS app crashes when .svg file is posted in any channel

2 participants