pointfreeco / swift-composable-architecture

A library for building applications in a consistent and understandable way, with composition, testing, and ergonomics in mind.
https://www.pointfree.co/collections/composable-architecture
MIT License
12.35k stars 1.44k forks source link

Observe method leak #2932

Closed juliensagot closed 7 months ago

juliensagot commented 7 months ago

Description

Hi folks πŸ‘‹ It appears that the observe method is leaking, even when self is properly weakified inside the trailing closure, unless I'm doing some silly things.


I've attached a sample macOS project where you can easily repro the issue: TCAPerceptionLeakSampleProject.zip

Checklist

Expected behavior

No response

Actual behavior

No response

Steps to reproduce

The Composable Architecture version information

1.9.2

Destination operating system

14.4 (23E214)

Xcode version information

Version 15.3 (15E204a)

Swift Compiler version information

swift-driver version: 1.90.11.1 Apple Swift version 5.10 (swiftlang-5.10.0.13 clang-1500.3.9.4)
Target: arm64-apple-macosx14.0
mbrandonw commented 7 months ago

Hi @juliensagot, this most likely will be fixed when this PR of swift-perception is merged.

Could you help us verify this by adding an explicit dependency on swift-perception to your project and pinning it to the explicit-animation branch?

juliensagot commented 7 months ago

@mbrandonw Done! Unfortunately, I'm experiencing the same leaks:

mbrandonw commented 7 months ago

Hi @juliensagot, how exactly can I reproduce the problem? I've run the app, increment the counter, and I don't see any leaks:

tmp

Also, are you sure you are running the leaks instrument in DEBUG? Because the object that is showing up in your screenshot, LockIsolated, is only used in DEBUG mode:

https://github.com/pointfreeco/swift-perception/blob/db087559dcc50eedebdc7df6a0fb0c1e188e4229/Sources/Perception/PerceptionRegistrar.swift#L18-L21

juliensagot commented 7 months ago

Oh no, you are right, I was somehow profiling the app in debug mode…
There are indeed no leaks! I'll close the issue, sorry πŸ˜