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() {
|
private void freeOffscreenBuffer() {
|
||||||
|
setLayerType(LAYER_TYPE_NONE, null);
|
||||||
|
|
||||||
mOffscreenCanvas.setBitmap(null);
|
mOffscreenCanvas.setBitmap(null);
|
||||||
mOffscreenCanvas.setMatrix(null);
|
mOffscreenCanvas.setMatrix(null);
|
||||||
if (mOffscreenBuffer != null) {
|
if (mOffscreenBuffer != null) {
|
||||||
|
@ -61,6 +61,8 @@ public final class DrawingPreviewPlacerView extends RelativeLayout {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void deallocateMemory() {
|
public void deallocateMemory() {
|
||||||
|
setLayerType(LAYER_TYPE_NONE, null);
|
||||||
|
|
||||||
final int count = mPreviews.size();
|
final int count = mPreviews.size();
|
||||||
for (int i = 0; i < count; i++) {
|
for (int i = 0; i < count; i++) {
|
||||||
mPreviews.get(i).onDeallocateMemory();
|
mPreviews.get(i).onDeallocateMemory();
|
||||||
|
@ -221,4 +221,8 @@ public final class InputView extends FrameLayout {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void deallocateMemory() {
|
||||||
|
mMainKeyboardView.deallocateMemory();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -126,7 +126,6 @@ class LatinIME : InputMethodService(), LifecycleOwner, ViewModelStoreOwner, Save
|
|||||||
|
|
||||||
private var lastEditorInfo: EditorInfo? = null
|
private var lastEditorInfo: EditorInfo? = null
|
||||||
|
|
||||||
// TODO: Calling this repeatedly as the theme changes tends to slow everything to a crawl
|
|
||||||
private fun recreateKeyboard() {
|
private fun recreateKeyboard() {
|
||||||
latinIMELegacy.updateTheme()
|
latinIMELegacy.updateTheme()
|
||||||
latinIMELegacy.mKeyboardSwitcher.mState.onLoadKeyboard(latinIMELegacy.currentAutoCapsState, latinIMELegacy.currentRecapitalizeState);
|
latinIMELegacy.mKeyboardSwitcher.mState.onLoadKeyboard(latinIMELegacy.currentAutoCapsState, latinIMELegacy.currentRecapitalizeState);
|
||||||
@ -327,7 +326,11 @@ class LatinIME : InputMethodService(), LifecycleOwner, ViewModelStoreOwner, Save
|
|||||||
key(legacyInputView) {
|
key(legacyInputView) {
|
||||||
AndroidView(factory = {
|
AndroidView(factory = {
|
||||||
legacyInputView!!
|
legacyInputView!!
|
||||||
}, modifier = modifier)
|
}, modifier = modifier, onRelease = {
|
||||||
|
val view = it as InputView
|
||||||
|
view.deallocateMemory()
|
||||||
|
view.removeAllViews()
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user