feat: trying upgrade DB for perf and reducing retry interval to congest threads

This commit is contained in:
Harris 2021-07-29 08:56:34 +10:00
parent 18d8261e33
commit 9d9f543c3b
5 changed files with 20 additions and 20 deletions

View File

@ -96,7 +96,7 @@ dependencies {
}
implementation 'com.codewaves.stickyheadergrid:stickyheadergrid:0.9.4'
implementation 'com.github.dmytrodanylyk.circular-progress-button:library:1.1.3-S2'
implementation 'org.signal:android-database-sqlcipher:3.5.9-S3'
implementation 'net.zetetic:android-database-sqlcipher:4.4.3'
implementation ('com.googlecode.ez-vcard:ez-vcard:0.9.11') {
exclude group: 'com.fasterxml.jackson.core'
exclude group: 'org.freemarker'
@ -214,6 +214,7 @@ android {
buildTypes {
release {
debuggable true
minifyEnabled false
}
debug {

View File

@ -143,11 +143,10 @@ public class SQLCipherOpenHelper extends SQLiteOpenHelper {
}
@Override
public void onConfigure(SQLiteDatabase db) {
super.onConfigure(db);
public void onOpen(SQLiteDatabase db) {
super.onOpen(db);
// Loki - Enable write ahead logging mode and increase the cache size.
// This should be disabled if we ever run into serious race condition bugs.
db.enableWriteAheadLogging();
db.execSQL("PRAGMA cache_size = 10000");
}

View File

@ -116,19 +116,6 @@ class HomeActivity : PassphraseRequiredActionBarActivity(), ConversationClickLis
})
// Set up new conversation button set
newConversationButtonSet.delegate = this
// Set up typing observer
ApplicationContext.getInstance(this).typingStatusRepository.typingThreads.observe(this, Observer<Set<Long>> { threadIDs ->
val adapter = recyclerView.adapter as HomeAdapter
adapter.typingThreadIDs = threadIDs ?: setOf()
})
// Set up remaining components if needed
val application = ApplicationContext.getInstance(this)
val userPublicKey = TextSecurePreferences.getLocalNumber(this)
if (userPublicKey != null) {
OpenGroupManager.startPolling()
JobQueue.shared.resumePendingJobs()
}
application.registerForFCMIfNeeded(false)
// Observe blocked contacts changed events
val broadcastReceiver = object : BroadcastReceiver() {
@ -138,8 +125,21 @@ class HomeActivity : PassphraseRequiredActionBarActivity(), ConversationClickLis
}
this.broadcastReceiver = broadcastReceiver
LocalBroadcastManager.getInstance(this).registerReceiver(broadcastReceiver, IntentFilter("blockedContactsChanged"))
lifecycleScope.launch {
lifecycleScope.launchWhenResumed {
// update things based on TextSecurePrefs (profile info etc)
// Set up typing observer
ApplicationContext.getInstance(this@HomeActivity).typingStatusRepository.typingThreads.observe(this@HomeActivity, Observer<Set<Long>> { threadIDs ->
val adapter = recyclerView.adapter as HomeAdapter
adapter.typingThreadIDs = threadIDs ?: setOf()
})
// Set up remaining components if needed
val application = ApplicationContext.getInstance(this@HomeActivity)
application.registerForFCMIfNeeded(false)
val userPublicKey = TextSecurePreferences.getLocalNumber(this@HomeActivity)
if (userPublicKey != null) {
OpenGroupManager.startPolling()
JobQueue.shared.resumePendingJobs()
}
updateProfileButton()
IP2Country.configureIfNeeded(this@HomeActivity)
TextSecurePreferences.events.filter { it == TextSecurePreferences.PROFILE_NAME_PREF }.collect {

View File

@ -9,7 +9,7 @@ import org.thoughtcrime.securesms.database.DatabaseFactory
import org.thoughtcrime.securesms.database.model.ThreadRecord
import org.thoughtcrime.securesms.mms.GlideRequests
class HomeAdapter(context: Context, cursor: Cursor) : CursorRecyclerViewAdapter<HomeAdapter.ViewHolder>(context, cursor) {
class HomeAdapter(context: Context, cursor: Cursor?) : CursorRecyclerViewAdapter<HomeAdapter.ViewHolder>(context, cursor) {
private val threadDatabase = DatabaseFactory.getThreadDatabase(context)
lateinit var glide: GlideRequests
var typingThreadIDs = setOf<Long>()

View File

@ -22,7 +22,7 @@ class Poller {
// region Settings
companion object {
private val retryInterval: Long = 1 * 1000
private val retryInterval: Long = 3 * 1000
}
// endregion