Skip to content

Commit

Permalink
Watch Zipline instances for leak after stop (#2266)
Browse files Browse the repository at this point in the history
  • Loading branch information
JakeWharton authored Aug 27, 2024
1 parent e64f319 commit 1c4f0ca
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

New:
- Source-based schema parser is now the default. The `useFir` Gradle property has been removed.
- `TreehouseAppFactory` accepts a `LeakDetector` which can be used to notify you of reference leaks for native UI nodes, Zipline instances, Redwood's own internal wrappers, and more.
- Introduce a `LoadingStrategy` interface to manage `LazyList` preloading.
- Optimize encoding modifiers in Kotlin/JS.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ internal class RealTreehouseApp<A : AppService> private constructor(
appService = appService,
zipline = zipline,
appScope = appScope,
leakDetector = leakDetector,
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package app.cash.redwood.treehouse

import app.cash.redwood.leaks.LeakDetector
import app.cash.redwood.protocol.RedwoodVersion
import app.cash.zipline.Zipline
import app.cash.zipline.ZiplineApiMismatchException
Expand All @@ -31,6 +32,7 @@ internal class ZiplineCodeSession<A : AppService>(
appService: A,
private val frameClockFactory: FrameClock.Factory,
val zipline: Zipline,
private val leakDetector: LeakDetector,
) : CodeSession<A>(
dispatchers = dispatchers,
eventPublisher = eventPublisher,
Expand Down Expand Up @@ -72,6 +74,7 @@ internal class ZiplineCodeSession<A : AppService>(
override fun ziplineStop() {
ziplineScope.close()
zipline.close()
leakDetector.watchReference(zipline, "code session stopped")
}

override fun newServiceScope(): ServiceScope<A> {
Expand Down

0 comments on commit 1c4f0ca

Please sign in to comment.