Skip to content

Handle preference stores corruption by clearing them #5086

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

Draft
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

jmartinesp
Copy link
Member

@jmartinesp jmartinesp commented Jul 28, 2025

Content

  • Use the centralised PreferenceDataStoreFactory instead of preferences by.
  • Add DefaultPreferencesCorruptionHandlerFactory.replaceWithEmpty to its create(name) method so all preference stores are cleared if they're corrupted.

Motivation and context

Fix crash loops as soon as the app uses something that relies on a corrupted data store, forcing them to clear the data/reinstall the app. (https://sentry.tools.element.io/organizations/element/issues/11202491/events/7de4ded2ec3f47fc9b46de9aec4ac231/)

Tests

It's not easy to test unless you manually modify a data store so it's malformed next time you try to use it.

Tested devices

  • Physical
  • Emulator
  • OS version(s):

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

- Use the centralised `PreferenceDataStoreFactory` instead of `preferences by`.
- Add `DefaultPreferencesCorruptionHandlerFactory.replaceWithEmpty` to its `create(name)` method so all preference stores are cleared if they're corrupted.
@ElementBot
Copy link
Collaborator

ElementBot commented Jul 28, 2025

Warnings
⚠️

gradle.properties#L43 - Newer version of lint available: 8.13.0-alpha02

Generated by 🚫 dangerJS against 0b0fb78

Copy link
Contributor

📱 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/JXdCke

Copy link

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.

2 participants