From 67705c31b1959f5714de4c42b27110787e995e1f Mon Sep 17 00:00:00 2001 From: Chace Daniels Date: Mon, 18 Aug 2025 11:01:15 -0400 Subject: [PATCH] fix: make MLKit scanner initialization lazy to prevent memory consumption overload --- CHANGELOG.md | 6 +++++- pom.xml | 2 +- .../barcode/controller/helper/OSBARCMLKitHelper.kt | 11 +++++++---- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 93a26b5..4723e9d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 The changes documented here do not include those from the original repository. -## [Unreleased] +## [1.2.1] + +### 20205-08-18 + +- Make MLKit scanner initialization lazy to prevent memory consumption overload (https://outsystemsrd.atlassian.net/browse/RMET-3481) ### 2025-06-24 diff --git a/pom.xml b/pom.xml index 596ea77..4d0a0cd 100644 --- a/pom.xml +++ b/pom.xml @@ -7,5 +7,5 @@ 4.0.0 io.ionic.libs ionbarcode-android - 1.2.0 + 1.2.1 diff --git a/src/main/kotlin/com/outsystems/plugins/barcode/controller/helper/OSBARCMLKitHelper.kt b/src/main/kotlin/com/outsystems/plugins/barcode/controller/helper/OSBARCMLKitHelper.kt index e86212a..6287665 100644 --- a/src/main/kotlin/com/outsystems/plugins/barcode/controller/helper/OSBARCMLKitHelper.kt +++ b/src/main/kotlin/com/outsystems/plugins/barcode/controller/helper/OSBARCMLKitHelper.kt @@ -18,6 +18,13 @@ class OSBARCMLKitHelper: OSBARCMLKitHelperInterface { private const val LOG_TAG = "OSBARCMLKitHelper" } + private val scanner by lazy { + val options = BarcodeScannerOptions.Builder() + .enableAllPotentialBarcodes() + .build() + BarcodeScanning.getClient(options) + } + /** * Scans an image looking for barcodes, using the ML Kit library. * @param imageProxy - ImageProxy object that represents the image to be analyzed. @@ -31,10 +38,6 @@ class OSBARCMLKitHelper: OSBARCMLKitHelperInterface { onSuccess: (MutableList) -> Unit, onError: () -> Unit ) { - val options = BarcodeScannerOptions.Builder() - .enableAllPotentialBarcodes() - .build() - val scanner = BarcodeScanning.getClient(options) val image = InputImage.fromBitmap( imageBitmap, imageProxy.imageInfo.rotationDegrees