Skip to content
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

fix: crash when saving bottom sheet state for message with reply [WPB-14433] #3689

Merged

Conversation

saleniuk
Copy link
Contributor

@saleniuk saleniuk commented Nov 29, 2024

BugWPB-14433 [Android] Crash after longtapping on a conversation and putting phone to sleep


PR Submission Checklist for internal contributors

  • The PR Title

    • conforms to the style of semantic commits messages¹ supported in Wire's Github Workflow²
    • contains a reference JIRA issue number like SQPIT-764
    • answers the question: If merged, this PR will: ... ³
  • The PR Description

    • is free of optional paragraphs and you have filled the relevant parts to the best of your ability

What's new in this PR?

Issues

After fixing bottom sheet crashes with this PR: #3670, still bottom sheet for message with a reply crashes.

Causes (Optional)

Android Studio had some problems highlighting all models that need to be serialized so previous PR missed out some of them. Also, turns out that using multiple serializer types can lead to some problems (in this case it was Json and Bundlizer).

Solutions

Make all classes used by UIMessage serializable, to be 100% sure.
Replace Any primitive type serializer that uses Json with a more custom one that does it via surrogate.
Wrap serialization in try-catch so that if it fails, the app doesn't crash and only the bottom sheet is hidden as there's no saved state for it.

Update: after the discussion, it was decided to drop saving the state for now and come up with some solution to not store too much, especially for conversations and messages to not keep such data unencrypted anywhere, so in the future when there's time to do that we could slim down the models for the bottom sheets to save only required data and not any sensitive ones. For now rememberSaveable is replaced with regular remember so the bottom sheet won't be rebuilt and the only drawback would be that the user would need to open it again.

Testing

Test Coverage (Optional)

  • I have added automated test to this contribution

How to Test

Open conversation, long-click on a message with a reply to open the bottom sheet and put the app into background.


PR Post Submission Checklist for internal contributors (Optional)

  • Wire's Github Workflow has automatically linked the PR to a JIRA issue

PR Post Merge Checklist for internal contributors

  • If any soft of configuration variable was introduced by this PR, it has been added to the relevant documents and the CI jobs have been updated.

References
  1. https://sparkbox.com/foundry/semantic_commit_messages
  2. https://github.com/wireapp/.github#usage
  3. E.g. feat(conversation-list): Sort conversations by most emojis in the title #SQPIT-764.

@echoes-hq echoes-hq bot added the echoes: unplanned Any work item that isn’t part of the product or technical roadmap. label Nov 29, 2024
@codecov-commenter
Copy link

codecov-commenter commented Nov 29, 2024

Codecov Report

Attention: Patch coverage is 29.72973% with 26 lines in your changes missing coverage. Please review.

Project coverage is 44.91%. Comparing base (aed7ea8) to head (ecdfb0b).
Report is 3 commits behind head on release/candidate.

Files with missing lines Patch % Lines
...ire/android/util/AnyPrimitiveAsStringSerializer.kt 8.69% 21 Missing ⚠️
...oid/ui/home/conversations/model/UIQuotedMessage.kt 50.00% 4 Missing ⚠️
...e/android/ui/home/conversations/model/UIMessage.kt 66.66% 1 Missing ⚠️
Additional details and impacted files
@@                  Coverage Diff                  @@
##           release/candidate    #3689      +/-   ##
=====================================================
- Coverage              44.94%   44.91%   -0.04%     
=====================================================
  Files                    471      472       +1     
  Lines                  15725    15757      +32     
  Branches                2686     2694       +8     
=====================================================
+ Hits                    7068     7077       +9     
- Misses                  7901     7924      +23     
  Partials                 756      756              
Files with missing lines Coverage Δ
...c/main/kotlin/com/wire/android/model/ImageAsset.kt 84.00% <100.00%> (+0.66%) ⬆️
...src/main/kotlin/com/wire/android/util/ui/UIText.kt 38.46% <100.00%> (ø)
...e/android/ui/home/conversations/model/UIMessage.kt 40.32% <66.66%> (+0.48%) ⬆️
...oid/ui/home/conversations/model/UIQuotedMessage.kt 36.58% <50.00%> (+5.15%) ⬆️
...ire/android/util/AnyPrimitiveAsStringSerializer.kt 8.69% <8.69%> (ø)

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update aed7ea8...ecdfb0b. Read the comment docs.

Copy link
Contributor

Built wire-android-staging-compat-pr-3689.apk is available for download

@saleniuk saleniuk requested review from a team, typfel, m-zagorski, alexandreferris, MohamadJaara and damian-kaczmarek and removed request for a team December 2, 2024 08:28
Copy link

sonarqubecloud bot commented Dec 2, 2024

Copy link
Contributor

github-actions bot commented Dec 2, 2024

Built wire-android-staging-compat-pr-3689.apk is available for download

@MohamadJaara MohamadJaara added this pull request to the merge queue Dec 2, 2024
Merged via the queue into release/candidate with commit ec33458 Dec 2, 2024
15 checks passed
@MohamadJaara MohamadJaara deleted the fix/crash-bottom-sheet-save-state-reply-msg branch December 2, 2024 14:19
@yamilmedina yamilmedina mentioned this pull request Dec 3, 2024
7 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
echoes: unplanned Any work item that isn’t part of the product or technical roadmap. size/S
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants