Skip to content

Fix clip sharing memory leak #3223

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

Merged
merged 4 commits into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ subprojects {
}

// Set Gradle property 'au.com.shiftyjelly.pocketcasts.leakcanary=true' to enable Leak Canary.
// You can do this using the local.properties file or any other avaialable Gradle mechanism.
// You can do this using the gradle.properties file or any other available Gradle mechanism.
// See: https://docs.gradle.org/current/userguide/build_environment.html#sec:project_properties
if (properties["au.com.shiftyjelly.pocketcasts.leakcanary"]?.toString().toBoolean()) {
dependencies {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ class ShareClipViewModel @AssistedInject constructor(
-> {
clipAnalytics.clipShared(clipRange, ClipShareType.Video, cardType)
createBackgroundAsset(cardType).map { asset ->
videoClipReequest(podcast, episode, clipRange, platform, cardType, asset, sourceView)
videoClipRequest(podcast, episode, clipRange, platform, cardType, asset, sourceView)
}
}
}
Expand Down Expand Up @@ -257,7 +257,7 @@ class ShareClipViewModel @AssistedInject constructor(
.build()
}

private fun videoClipReequest(
private fun videoClipRequest(
podcast: Podcast,
episode: PodcastEpisode,
clipRange: Clip.Range,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import au.com.shiftyjelly.pocketcasts.sharing.MediaService
import au.com.shiftyjelly.pocketcasts.sharing.VisualCardType
import au.com.shiftyjelly.pocketcasts.utils.toSecondsWithSingleMilli
import com.arthenica.ffmpegkit.FFmpegKit
import com.arthenica.ffmpegkit.FFmpegKitConfig
import com.arthenica.ffmpegkit.FFmpegSession
import com.arthenica.ffmpegkit.FFmpegSessionCompleteCallback
import com.arthenica.ffmpegkit.ReturnCode
Expand Down Expand Up @@ -150,6 +151,7 @@ internal class FFmpegMediaService(
command,
object : FFmpegSessionCompleteCallback {
override fun apply(session: FFmpegSession) {
FFmpegKitConfig.clearSessions()
when {
ReturnCode.isSuccess(session.returnCode) -> {
continuation.resume(Result.success(Unit))
Expand All @@ -166,7 +168,10 @@ internal class FFmpegMediaService(
}
},
)
continuation.invokeOnCancellation { session.cancel() }
continuation.invokeOnCancellation {
FFmpegKitConfig.clearSessions()
session.cancel()
}
}

private companion object {
Expand Down