Skip to content
Snippets Groups Projects
Commit 740bd08e authored by Aleksandras Kostarevas's avatar Aleksandras Kostarevas
Browse files

Fix problem where wrong autocorrection is used during stress

parent 21800d37
No related branches found
No related tags found
No related merge requests found
......@@ -1502,12 +1502,12 @@ public final class InputLogic {
}
}
private void ensureSuggestionStripCompleted(final SettingsValues settingsValues,
private boolean ensureSuggestionStripCompleted(final SettingsValues settingsValues,
final String separator, final LatinIMELegacy.UIHandler handler) {
LanguageModelFacilitator facilitator = handler.getLanguageModelFacilitator();
if(!facilitator.shouldPassThroughToLegacy()) {
if(facilitator.hasPendingUpdate()) {
facilitator.blockUntilComplete();
return facilitator.blockUntilComplete();
}
} else {
if (handler.hasPendingUpdateSuggestions()) {
......@@ -1523,6 +1523,8 @@ public final class InputLogic {
performUpdateSuggestionStripSync(settingsValues, SuggestedWords.INPUT_STYLE_TYPING);
}
}
return true;
}
public void performUpdateSuggestionStripSync(final SettingsValues settingsValues,
......@@ -2177,7 +2179,8 @@ public final class InputLogic {
private void commitCurrentAutoCorrection(final SettingsValues settingsValues,
final String separator, final LatinIMELegacy.UIHandler handler) {
// Complete any pending suggestions query first
ensureSuggestionStripCompleted(settingsValues, separator, handler);
if(!ensureSuggestionStripCompleted(settingsValues, separator, handler)) return;
final SuggestedWordInfo autoCorrectionOrNull = mWordComposer.getAutoCorrectionOrNull();
final String typedWord = mWordComposer.getTypedWord();
final String stringToCommit = (autoCorrectionOrNull != null)
......
......@@ -136,10 +136,10 @@ public class LanguageModelFacilitator(
private var numConsecutiveTimeouts = 0
private var transformerDisabled = false
public fun blockUntilComplete() {
public fun blockUntilComplete(): Boolean {
runBlocking {
try {
withTimeout(1000L) {
withTimeout(700L) {
computationSemaphore.acquire()
computationSemaphore.release()
try {
......@@ -150,14 +150,16 @@ public class LanguageModelFacilitator(
}
numConsecutiveTimeouts = 0
} catch(e: TimeoutCancellationException) {
Log.d("LanguageModelFacilitator", "Failed to complete prediction within 1000ms!")
Log.d("LanguageModelFacilitator", "Failed to complete prediction within the time!")
numConsecutiveTimeouts += 1
if(numConsecutiveTimeouts > 5) {
transformerDisabled = true
Log.w("LanguageModelFacilitator", "Temporarily disabling transformer due to continuous timeouts")
}
return@runBlocking false
}
}
return true
}
private fun getEmojiCandidate(word: String): SuggestedWordInfo? {
......@@ -232,6 +234,8 @@ public class LanguageModelFacilitator(
computationSemaphore.acquire()
inputLogic.mWordComposer.setAutoCorrection(null)
try {
var transformerWeight = context.getSetting(BinaryDictTransformerWeightSetting)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment