Skip to content

Conversation

@ParaskP7
Copy link
Contributor

@ParaskP7 ParaskP7 commented Oct 7, 2025

Closes: AINFRA-1281


Description

This PR updates automattic-encryptedlogging to 1.1.1.

FYI: This update resolves a long standing OutOfMemory (OOM) error when using this library alongside logs that are of large size.

PS: This change also resolved a regression that was caused because of #14407, which brought-in some app logs improvements (9892c31). For more info see (internal discussion): p1759832867149029-slack-CGPNUU63E (See also: EL#29)


Testing information

  1. Using App Inspection from AS find the encrypted-log.db and its sole EncryptedLogEntity table. Notice that the table is empty, there are no log to be sent.
  2. Prepare the app for a crash. Navigate to Menu -> Settings -> Privacy settings and then switch-on the Report Crashes option.
  3. Using the patch below, make the app crash. You could navigate to Menu -> Settings -> Developer Options and then click Crash The App.
patch
Subject: [PATCH] Build: Remove unnecessary encrypted logging proguard rules

The 'automattic-logging' library defines these Proguard rules already,
via its 'consumer-rules.pro' file, and thus those are automatically 
applies to any module that uses this dependency.

consumer-rules.pro: https://github.com/Automattic/EncryptedLogging/blob/
trunk/encryptedlogging/consumer-rules.pro
---
Index: WooCommerce/src/main/kotlin/com/woocommerce/android/ui/prefs/developer/DeveloperOptionsViewModel.kt
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/prefs/developer/DeveloperOptionsViewModel.kt b/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/prefs/developer/DeveloperOptionsViewModel.kt
--- a/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/prefs/developer/DeveloperOptionsViewModel.kt	(revision 2b8d77c042fff8f0df4629edf9a0e84e1961b97f)
+++ b/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/prefs/developer/DeveloperOptionsViewModel.kt	(date 1752838777405)
@@ -90,12 +90,25 @@
         )
     )
 
+    private val crashTheApp = flowOf(
+        NonToggleableListItem(
+            icon = R.drawable.ic_cancel,
+            iconTint = R.color.color_primary,
+            label = UiString.UiStringText("Crash The App"),
+            isEnabled = true,
+            onClick = {
+                throw Exception("Developer caused a crash!")
+            }
+        )
+    )
+
     val viewState = combine(
         simulatedCardReaderFlow,
         readerUpdateFrequencyFlow,
         interacPaymentEnabledFlow,
         savedPrivacySettingsOnDialogFlow,
-        apiFakerFlow
+        apiFakerFlow,
+        crashTheApp
     ) { items ->
         DeveloperOptionsViewState(
             rows = items.filterNotNull()
  1. You might now notice a new db entry within App Inspection from AS on that DETACHED app (or not, it depends). Now, switch to the ATTACHED app and notice the db empty. This is because this db entry/log has been already sent to Sentry already, on app start and after the app crashed. To really notice the entry, trying crashing the app again, this time put the device on offline mode first. Doing that you'll be able to see the entry on the db, even when switching to the newly created ATTACHED app.
  2. Open Sentry and navigate to Issues. Find woocommerce-android and check the latest debug exceptions. You could search for Developer caused a crash! and check the latest crash. Now navigate at the bottom and check the uuid. Verify it is the same UUID that you saw on that db entry before.
  3. Open Read Encrypted Logs, copy-paste that UUID into Log UUID, click View and make sure you can read the newly uploaded and now decrypted log.
  4. Finally, you could inspect Logcat and notice/verify the below entries:
    • Success: Successfully uploaded encrypted log with uuid: <UUID>
    • Failure: Failed to upload encrypted log with uuid: <UUID> [Reason: <ERROR>]

Tip

FYI: If you want to be thorough about testing this, you could follow the "extra" testing instructions on EL#28. The testing instruction in there focus on how to replicate an OOM, filling the logs and asserting that this fix works no matter how big (in size) the to-be encrypted/uploaded log file ends-up being.


  • I have considered if this change warrants release notes and have added them to RELEASE-NOTES.txt if necessary. Use the "[Internal]" label for non-user-facing changes.

FYI: This is done because we've identified a regression where the actual
encrypted log, although seen as sent, is not actually ending-up being
uploaded into our systems. Thus, when someone then tries to browse it,
based on it UUID, they will get: "Log File Not Found.Invalid Log File"

For more info see: p1759832867149029-slack-CGPNUU63E

PS: The PR that introduced this regression is #14407, which brought-in
some app logs improvements.
Release Notes: https://github.com/Automattic/EncryptedLogging/releases/
tag/1.1.1

FYI: This update resolves a long standing OutOfMemory (OOM) error when
using this library alongside logs that are of large size.
@ParaskP7 ParaskP7 added this to the 23.5 milestone Oct 7, 2025
@ParaskP7 ParaskP7 requested a review from Copilot October 7, 2025 11:37
@ParaskP7 ParaskP7 added category: tooling Anything that involves building & maintaining the project, including scripts, `Fastfile`, etc. type: technical debt Represents or solves tech debt of the project. dependency update Core labels Oct 7, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR updates the automattic-encryptedlogging dependency from version 1.0.0 to 1.1.1 to resolve OutOfMemory (OOM) errors when handling large log files.

  • Updated dependency version in gradle configuration
  • Refactored coroutine usage to use runBlocking instead of launching in app coroutine scope
  • Removed unnecessary dependency injection for AppCoroutineScope

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
gradle/libs.versions.toml Updates automattic-encryptedlogging version from 1.0.0 to 1.1.1
WooCommerce/src/main/kotlin/com/woocommerce/android/util/crashlogging/EnqueueSendingEncryptedLogs.kt Refactors coroutine handling and removes AppCoroutineScope dependency

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@wpmobilebot
Copy link
Collaborator

Project dependencies changes

list
! Upgraded Dependencies
com.automattic:encryptedlogging:1.1.1, (changed from 1.0.0)
tree
-\--- com.automattic:encryptedlogging:1.0.0
+\--- com.automattic:encryptedlogging:1.1.1

@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Oct 7, 2025

📲 You can test the changes from this Pull Request in WooCommerce-Wear Android by scanning the QR code below to install the corresponding build.
App Name WooCommerce-Wear Android
Platform⌚️ Wear OS
FlavorJalapeno
Build TypeDebug
Commitaf5a975
Direct Downloadwoocommerce-wear-prototype-build-pr14711-af5a975.apk

@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Oct 7, 2025

📲 You can test the changes from this Pull Request in WooCommerce Android by scanning the QR code below to install the corresponding build.

App Name WooCommerce Android
Platform📱 Mobile
FlavorJalapeno
Build TypeDebug
Commitaf5a975
Direct Downloadwoocommerce-prototype-build-pr14711-af5a975.apk

@codecov-commenter
Copy link

codecov-commenter commented Oct 7, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 38.37%. Comparing base (55e165a) to head (af5a975).
⚠️ Report is 13 commits behind head on trunk.

Additional details and impacted files
@@             Coverage Diff              @@
##              trunk   #14711      +/-   ##
============================================
- Coverage     38.37%   38.37%   -0.01%     
+ Complexity     9855     9854       -1     
============================================
  Files          2098     2098              
  Lines        117018   117024       +6     
  Branches      15656    15655       -1     
============================================
+ Hits          44904    44906       +2     
- Misses        67949    67951       +2     
- Partials       4165     4167       +2     

☔ 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.

FYI: After some discussions we agreed on enqueuing the logs on the
'main' thread for 'FATAL' error, else do this off the 'main' thread.
@ParaskP7 ParaskP7 requested a review from Copilot October 7, 2025 13:47
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@ParaskP7 ParaskP7 marked this pull request as ready for review October 7, 2025 13:50
@ParaskP7 ParaskP7 requested a review from a team as a code owner October 7, 2025 13:50
@ParaskP7 ParaskP7 requested review from hichamboushaba and wzieba and removed request for a team October 7, 2025 13:50
@ParaskP7
Copy link
Contributor Author

ParaskP7 commented Oct 9, 2025

A friendly remind on this folks! 🙏 Cc @wzieba @hichamboushaba

FYI: We are on a meetup next week, then sabbatical, so it would be great to merge this by the end of this week. 🤞

Copy link
Member

@hichamboushaba hichamboushaba left a comment

Choose a reason for hiding this comment

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

Works as expected, nice work @ParaskP7, thanks for the additional improvements too 🙏

Just a FYI, I deleted the test crash reports in Sentry.

@ParaskP7
Copy link
Contributor Author

ParaskP7 commented Oct 9, 2025

Awesome, thanks for much @hichamboushaba ! 🙇 ❤️ 🚀

@ParaskP7 ParaskP7 merged commit 57b06eb into trunk Oct 9, 2025
17 checks passed
@ParaskP7 ParaskP7 deleted the deps/update-automattic-enryptedlogging-to-1.1.1 branch October 9, 2025 11:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

category: tooling Anything that involves building & maintaining the project, including scripts, `Fastfile`, etc. Core dependency update type: technical debt Represents or solves tech debt of the project.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants