Skip to content

fix: make saving state logs to a file on Android more performant#31595

Merged
joaoloureirop merged 1 commit into
mainfrom
fix/24359-android-download-state-logs
Jun 15, 2026
Merged

fix: make saving state logs to a file on Android more performant#31595
joaoloureirop merged 1 commit into
mainfrom
fix/24359-android-download-state-logs

Conversation

@joaoloureirop

@joaoloureirop joaoloureirop commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Description

On Android, Settings → Advanced → Download State Logs was slow to respond, and when the share window finally appeared it only offered "send to" targets (email/messaging/apps) with no way to actually save or download the logs file.

The cause was that Android shared the logs as a base64 data:text/plain URL via Share.open. Encoding the entire state to base64 was slow for large states, and the result was a text-only share intent with no file to save.

This PR makes state logs a real file download on both platforms:

  • The logs are written to a file (as iOS already did) and shared by their plain path with a filename and application/json MIME type. react-native-share copies the file into its own FileProvider and shares a content:// URI, so Android's share sheet now offers "Save to Files"/Drive. (A raw file:// URI is intentionally avoided — it would crash Android with FileUriExposedException.)
  • Dropping the base64 encoding step also removes the delay that prompted the report.

iOS behavior is unchanged in practice (it already wrote and shared the file); the share path is now unified across platforms.

Changelog

CHANGELOG entry: Fixed Download State Logs on Android so the logs can be saved/downloaded as a file, and removed the delay before the share sheet appears

Related issues

Fixes: #24359

Manual testing steps

Feature: Download state logs on Android

  Scenario: User downloads and saves state logs
    Given I am on an Android device with the wallet unlocked
    And I navigate to Settings > Advanced

    When I tap "Download state logs"
    Then the share sheet appears promptly
    And it offers an option to save/download the file (e.g. "Save to Files"/Drive)

  Scenario: User saves the file
    Given the share sheet is open
    When I choose "Save to Files" (or Drive) and confirm
    Then a "state-logs-v<version>-(<build>).json" file is saved and can be reopened

Screenshots/Recordings

Before

Not applicable

After

Not applicable

Pre-merge author checklist

Performance checks (if applicable)

  • I've tested on Android
    • Ideally on a mid-range device; emulator is acceptable
  • I've tested with a power user scenario
    • Use these power-user SRPs to import wallets with many accounts and tokens
  • I've instrumented key operations with Sentry traces for production performance metrics

For performance guidelines and tooling, see the Performance Guide.

Pre-merge reviewer checklist

  • I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed).
  • I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.

@joaoloureirop joaoloureirop requested a review from a team as a code owner June 11, 2026 21:00
@github-actions

Copy link
Copy Markdown
Contributor

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

@mm-token-exchange-service mm-token-exchange-service Bot added the team-mobile-platform Mobile Platform team label Jun 11, 2026
@joaoloureirop joaoloureirop force-pushed the fix/24359-android-download-state-logs branch from 911f223 to b8189e9 Compare June 11, 2026 21:02
@github-actions github-actions Bot added the risk:medium AI analysis: medium risk label Jun 11, 2026
@joaoloureirop joaoloureirop changed the title Fix/24359 android download state logs fix: allow saving state logs to a file on Android with a cancelable loading overlay Jun 11, 2026
@joaoloureirop joaoloureirop added the skip-sonar-cloud Only used for bypassing sonar cloud when failures are not relevant to the changes. label Jun 11, 2026
@github-actions github-actions Bot added risk:low AI analysis: low risk and removed risk:medium AI analysis: medium risk labels Jun 11, 2026
Android shared state logs as a base64 data:text/plain URL via Share.open,
which was slow to encode for large states and produced a text-only share
intent with no way to save the file. Write the logs to a real file on
both platforms and share it with a filename and application/json type
(plain path, so react-native-share serves a content:// URI via its
FileProvider). Faster, and Android now offers Save to Files/Drive.
@joaoloureirop joaoloureirop force-pushed the fix/24359-android-download-state-logs branch from 303cf6a to ca71c39 Compare June 11, 2026 22:37
@github-actions

Copy link
Copy Markdown
Contributor

🔍 Smart E2E Test Selection

  • Selected E2E tags: None (no tests recommended)
  • Selected Performance tags: None (no tests recommended)
  • Risk Level: low
  • AI Confidence: 97%
click to see 🤖 AI reasoning details

E2E Test Selection:
The PR modifies only two files: app/util/logs/index.ts and its test file app/util/logs/index.test.ts. The changes refactor the downloadStateLogs utility function to write state logs to a real file on both iOS and Android (previously Android used a base64 data URL), and share the file path instead. Additional share options (filename, type: 'application/json', failOnCancel: false) are added. The Buffer and Device imports are removed as they are no longer needed. This is a diagnostic/developer utility triggered only by a long-press on the Login screen — it is not part of any core wallet flow (accounts, transactions, networks, swaps, etc.). No E2E tests cover this specific feature. The changes are fully covered by updated unit tests. No shared components (navigation, modals, confirmations, controllers) are affected. Zero E2E tags are warranted.

Performance Test Selection:
The changes are limited to the state logs download utility function. This is a diagnostic feature triggered by a long-press gesture on the login screen and has no impact on any performance-measured flows (app launch, login, onboarding, swaps, asset loading, account list, etc.). No performance tests are warranted.

View GitHub Actions results

@joaoloureirop joaoloureirop removed the request for review from a team June 12, 2026 15:30
@joaoloureirop joaoloureirop changed the title fix: allow saving state logs to a file on Android with a cancelable loading overlay fix: make saving state logs to a file on Android more performant Jun 12, 2026
@joaoloureirop joaoloureirop added this pull request to the merge queue Jun 15, 2026
Merged via the queue into main with commit 9e93046 Jun 15, 2026
69 of 71 checks passed
@joaoloureirop joaoloureirop deleted the fix/24359-android-download-state-logs branch June 15, 2026 16:58
@github-actions github-actions Bot locked and limited conversation to collaborators Jun 15, 2026
@metamaskbotv2 metamaskbotv2 Bot added the release-7.83.0 Issue or pull request that will be included in release 7.83.0 label Jun 15, 2026
@tommasini tommasini added release-8.0.0 Issue or pull request that will be included in release 8.0.0 and removed release-7.83.0 Issue or pull request that will be included in release 7.83.0 labels Jun 18, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

release-8.0.0 Issue or pull request that will be included in release 8.0.0 risk:low AI analysis: low risk size-M skip-sonar-cloud Only used for bypassing sonar cloud when failures are not relevant to the changes. team-mobile-platform Mobile Platform team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Downloading State Logs on Android

2 participants