Skip to content

Limit the text length in the 'in reply to' preview #4491

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

Merged
merged 3 commits into from
Mar 27, 2025

Conversation

jmartinesp
Copy link
Member

Content

What the title says.

Motivation and context

Otherwise, very long texts with no line breaks can cause a Compose crash.

Fixes #3772

Screenshots / GIFs

There shouldn't be any visual change, unless you have a huge screen that can display in reply to previews of > 512 chars.

Tests

  • Generate a very long text, > 20k characters, maybe using a lorem ipsum and make sure there are no line breaks.
  • Send the text.
  • Try to reply to the message.

If the app doesn't crash, we worked around the Compose bug.

Tested devices

  • Physical
  • Emulator
  • OS version(s): 14

Checklist

  • Changes have been tested on an Android device or Android emulator with API 24
  • UI change has been tested on both light and dark themes
  • Accessibility has been taken into account. See https://github.com/element-hq/element-x-android/blob/develop/CONTRIBUTING.md#accessibility
  • Pull request is based on the develop branch
  • Pull request title will be used in the release note, it clearly define what will change for the user
  • Pull request includes screenshots or videos if containing UI changes
  • You've made a self review of your PR

Otherwise, very long texts with no line breaks can cause a Compose crash
@jmartinesp jmartinesp added the PR-Bugfix For bug fix label Mar 27, 2025
@jmartinesp jmartinesp requested a review from a team as a code owner March 27, 2025 11:53
@jmartinesp jmartinesp requested review from bmarty and removed request for a team March 27, 2025 11:53
Copy link
Contributor

github-actions bot commented Mar 27, 2025

📱 Scan the QR code below to install the build (arm64 only) for this PR.
QR code
If you can't scan the QR code you can install the build via this link: https://i.diawi.com/zzHqED

Copy link
Member

@bmarty bmarty left a comment

Choose a reason for hiding this comment

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

Thanks!

// Add a limit to the text length to avoid a crash in Compose
is InReplyToMetadata.Text -> metadata.text.ellipsize(512)
// Add a limit to the text length to avoid a crash in Compose
is InReplyToMetadata.Thumbnail -> metadata.text.ellipsize(512)
Copy link
Member

Choose a reason for hiding this comment

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

I remember that we already have a similar fix (limiting the size of text to avoid a Compose crash), but I can find it. Maybe I dreamt it?
Else maybe create a const for this 512 (not a big deal)?

Copy link
Member Author

@jmartinesp jmartinesp Mar 27, 2025

Choose a reason for hiding this comment

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

I had the same issue, I know it's there, I just don't know where 😅 .

EDIT: found it

Copy link
Member Author

Choose a reason for hiding this comment

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

I've tried unifying both in an extension function in a new commit.

Copy link
Member

Choose a reason for hiding this comment

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

I've tried unifying both in an extension function in a new commit.

That's also why I wanted to find where it was done before. Thanks for the update!

Copy link

codecov bot commented Mar 27, 2025

Codecov Report

Attention: Patch coverage is 66.66667% with 1 line in your changes missing coverage. Please review.

Project coverage is 80.08%. Comparing base (6123650) to head (d910ea1).
Report is 4 commits behind head on develop.

Files with missing lines Patch % Lines
...ibraries/matrix/ui/messages/reply/InReplyToView.kt 50.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #4491   +/-   ##
========================================
  Coverage    80.08%   80.08%           
========================================
  Files         2077     2077           
  Lines        55588    55588           
  Branches      6802     6802           
========================================
  Hits         44519    44519           
  Misses        8733     8733           
  Partials      2336     2336           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link

@jmartinesp jmartinesp requested a review from bmarty March 27, 2025 13:10
@jmartinesp jmartinesp merged commit 058d8f2 into develop Mar 27, 2025
30 of 31 checks passed
@jmartinesp jmartinesp deleted the fix/replying-to-long-message-causes-crash branch March 27, 2025 13:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR-Bugfix For bug fix
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Replying to a very long message crashes the app
2 participants