From 6c1719e365070a0d73c945461b801ba173f99a75 Mon Sep 17 00:00:00 2001 From: waylon531 Date: Thu, 16 Apr 2020 02:37:12 -0700 Subject: [PATCH 1/2] Use a bigger thread pool This patch makes RiotX use an unbounded thread pool to handle connections. The default thread pool for the android WorkManager has a fairly anemic number of threads and I suspect this was causing performance issues especially because of all the long-running jobs that happen whenever you sync. I tested this out on my phone and all of the sluggishness appears to have gone away. I tested both the debug and release builds to make sure it wasn't just some release optimization. RiotX is so much snappier now! This fixes #1221 Signed-off-by: Waylon Cude --- .../src/main/java/im/vector/matrix/android/api/Matrix.kt | 3 ++- vector/src/main/java/im/vector/riotx/VectorApplication.kt | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/Matrix.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/Matrix.kt index 22ac0324cf..4c6e3ea3bd 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/Matrix.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/Matrix.kt @@ -33,6 +33,7 @@ import im.vector.matrix.android.internal.util.BackgroundDetectionObserver import org.matrix.olm.OlmManager import java.io.InputStream import java.util.concurrent.atomic.AtomicBoolean +import java.util.concurrent.Executors import javax.inject.Inject data class MatrixConfiguration( @@ -61,7 +62,7 @@ class Matrix private constructor(context: Context, matrixConfiguration: MatrixCo Monarchy.init(context) DaggerMatrixComponent.factory().create(context, matrixConfiguration).inject(this) if (context.applicationContext !is Configuration.Provider) { - WorkManager.initialize(context, Configuration.Builder().build()) + WorkManager.initialize(context, Configuration.Builder().setExecutor(Executors.newCachedThreadPool()).build()) } ProcessLifecycleOwner.get().lifecycle.addObserver(backgroundDetectionObserver) } diff --git a/vector/src/main/java/im/vector/riotx/VectorApplication.kt b/vector/src/main/java/im/vector/riotx/VectorApplication.kt index 680550e818..2bceb38b75 100644 --- a/vector/src/main/java/im/vector/riotx/VectorApplication.kt +++ b/vector/src/main/java/im/vector/riotx/VectorApplication.kt @@ -56,6 +56,7 @@ import im.vector.riotx.features.version.VersionProvider import im.vector.riotx.push.fcm.FcmHelper import timber.log.Timber import java.text.SimpleDateFormat +import java.util.concurrent.Executors import java.util.Date import java.util.Locale import javax.inject.Inject @@ -146,7 +147,7 @@ class VectorApplication : Application(), HasVectorInjector, MatrixConfiguration. override fun providesMatrixConfiguration() = MatrixConfiguration(BuildConfig.FLAVOR_DESCRIPTION) - override fun getWorkManagerConfiguration() = androidx.work.Configuration.Builder().build() + override fun getWorkManagerConfiguration() = androidx.work.Configuration.Builder().setExecutor(Executors.newCachedThreadPool()).build() override fun injector(): VectorComponent { return vectorComponent From ec4458e84a8454a0afbd8ef1f8fec232fe70142c Mon Sep 17 00:00:00 2001 From: Waylon Cude Date: Thu, 16 Apr 2020 02:50:58 -0700 Subject: [PATCH 2/2] Updated CHANGES.md Signed-off-by: Waylon Cude --- CHANGES.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES.md b/CHANGES.md index 4ca393ab73..52f728d2c5 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -31,6 +31,7 @@ Bugfix 🐛: - Cross-Signing | web <-> riotX After QR code scan, gossiping fails (#1210) - Fix crash when trying to download file without internet connection (#1229) - Local echo are not updated in timeline (for failed & encrypted states) + - RiotX now uses as many threads as it needs to do work and send messages (#1221) Translations 🗣: -