mirror of
https://gitlab.futo.org/keyboard/latinime.git
synced 2024-09-28 14:54:30 +01:00
Fix graphics memory leak when keyboard recreated
This commit is contained in:
parent
9e0dc28848
commit
d62b733412
@ -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) {
|
||||
|
@ -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();
|
||||
|
@ -221,4 +221,8 @@ public final class InputView extends FrameLayout {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void deallocateMemory() {
|
||||
mMainKeyboardView.deallocateMemory();
|
||||
}
|
||||
}
|
||||
|
@ -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()
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user