diff --git a/java/src/org/futo/inputmethod/keyboard/KeyboardView.java b/java/src/org/futo/inputmethod/keyboard/KeyboardView.java index 8418830e6..7169e200c 100644 --- a/java/src/org/futo/inputmethod/keyboard/KeyboardView.java +++ b/java/src/org/futo/inputmethod/keyboard/KeyboardView.java @@ -291,6 +291,8 @@ public class KeyboardView extends View { } private void freeOffscreenBuffer() { + setLayerType(LAYER_TYPE_NONE, null); + mOffscreenCanvas.setBitmap(null); mOffscreenCanvas.setMatrix(null); if (mOffscreenBuffer != null) { diff --git a/java/src/org/futo/inputmethod/keyboard/internal/DrawingPreviewPlacerView.java b/java/src/org/futo/inputmethod/keyboard/internal/DrawingPreviewPlacerView.java index 41323a6b0..bc1a7a8bc 100644 --- a/java/src/org/futo/inputmethod/keyboard/internal/DrawingPreviewPlacerView.java +++ b/java/src/org/futo/inputmethod/keyboard/internal/DrawingPreviewPlacerView.java @@ -61,6 +61,8 @@ public final class DrawingPreviewPlacerView extends RelativeLayout { } public void deallocateMemory() { + setLayerType(LAYER_TYPE_NONE, null); + final int count = mPreviews.size(); for (int i = 0; i < count; i++) { mPreviews.get(i).onDeallocateMemory(); diff --git a/java/src/org/futo/inputmethod/latin/InputView.java b/java/src/org/futo/inputmethod/latin/InputView.java index 2a64b17df..b73c4cacd 100644 --- a/java/src/org/futo/inputmethod/latin/InputView.java +++ b/java/src/org/futo/inputmethod/latin/InputView.java @@ -221,4 +221,8 @@ public final class InputView extends FrameLayout { return false; } } + + public void deallocateMemory() { + mMainKeyboardView.deallocateMemory(); + } } diff --git a/java/src/org/futo/inputmethod/latin/LatinIME.kt b/java/src/org/futo/inputmethod/latin/LatinIME.kt index c59264ef2..917d50aae 100644 --- a/java/src/org/futo/inputmethod/latin/LatinIME.kt +++ b/java/src/org/futo/inputmethod/latin/LatinIME.kt @@ -126,7 +126,6 @@ class LatinIME : InputMethodService(), LifecycleOwner, ViewModelStoreOwner, Save private var lastEditorInfo: EditorInfo? = null - // TODO: Calling this repeatedly as the theme changes tends to slow everything to a crawl private fun recreateKeyboard() { latinIMELegacy.updateTheme() latinIMELegacy.mKeyboardSwitcher.mState.onLoadKeyboard(latinIMELegacy.currentAutoCapsState, latinIMELegacy.currentRecapitalizeState); @@ -327,7 +326,11 @@ class LatinIME : InputMethodService(), LifecycleOwner, ViewModelStoreOwner, Save key(legacyInputView) { AndroidView(factory = { legacyInputView!! - }, modifier = modifier) + }, modifier = modifier, onRelease = { + val view = it as InputView + view.deallocateMemory() + view.removeAllViews() + }) } }