Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix FakedComposeView memory leak #1760

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class ScriptRunnerOverlay @Inject constructor(
private val scriptComponentBuilder: ScriptComponentBuilder
) {
private val layout: ComposeView
private val fakeView: FakedComposeView

private val scriptCtrlBtnLayoutParams = WindowManager.LayoutParams().apply {
type = overlayType
Expand All @@ -53,7 +54,7 @@ class ScriptRunnerOverlay @Inject constructor(
init {
require(service is ScriptRunnerService)

layout = FakedComposeView(service) {
fakeView = FakedComposeView(service) {
ScriptRunnerUI(
state = uiStateHolder.uiState,
prefsCore = prefsCore,
Expand All @@ -62,7 +63,8 @@ class ScriptRunnerOverlay @Inject constructor(
enabled = uiStateHolder.isPlayButtonEnabled,
onDrag = { x, y -> onDrag(x, y) }
)
}.view
}
layout = fakeView.view

// By default put the button on bottom-left corner
val m = display.metrics
Expand Down Expand Up @@ -117,6 +119,7 @@ class ScriptRunnerOverlay @Inject constructor(
if (shown && Settings.canDrawOverlays(service)) {
savePlayButtonLocation()

fakeView.close()
windowManager.removeView(layout)
highlightManager.hide()

Expand Down