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 strong reference cycle between RoomProxy and RoomTimelineProvider #217

Closed
wants to merge 1 commit into from

Conversation

Johennes
Copy link
Contributor

Fixes: #216

Pull Request Checklist

UI changes have been tested with:

  • iPhone and iPad simulators in portrait and landscape orientations.
  • Dark mode enabled and disabled.
  • Various sizes of dynamic type.
  • Voiceover enabled.

@sonarcloud
Copy link

sonarcloud bot commented Sep 27, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@github-actions
Copy link

📱 Scan the QR code below to install the build for this PR.
🔒 This build is for internal testing purpose. Only devices listed in the ad-hoc provisioning profile can install Element Alpha.

QR code

If you can't scan the QR code you can install the build via this link: https://i.diawi.com/kXztLH

@codecov
Copy link

codecov bot commented Sep 27, 2022

Codecov Report

Base: 11.79% // Head: 11.79% // No change to project coverage 👍

Coverage data is based on head (fe37775) compared to base (98de776).
Patch has no changes to coverable lines.

Additional details and impacted files
@@           Coverage Diff            @@
##           develop     #217   +/-   ##
========================================
  Coverage    11.79%   11.79%           
========================================
  Files          213      213           
  Lines        14359    14359           
  Branches      6974     6974           
========================================
  Hits          1693     1693           
  Misses       12623    12623           
  Partials        43       43           
Impacted Files Coverage Δ
ElementX/Sources/Services/Room/MockRoomProxy.swift 0.00% <ø> (ø)
...entX/Sources/Services/Room/RoomProxyProtocol.swift 0.00% <ø> (ø)
...urces/Services/Timeline/RoomTimelineProvider.swift 0.00% <ø> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@Johennes Johennes requested review from a team and ismailgulek and removed request for a team September 27, 2022 19:22
Copy link
Member

@stefanceriu stefanceriu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not quite sure I follow this one: the roomProxy is a direct dependency of the TimelineProvider and should be strongly retained by it. If there's a cycle it should be handled another way.

LE: I had a closer look at it, we need to take the timelineProvider out of the roomProxy and create it when needed in the AppCoordinatorUserSessionFlowCoordinator. The timelineProvider can register itself as a listener on its own roomProxy dependency.

@Johennes
Copy link
Contributor Author

I'm not quite sure I follow this one: the roomProxy is a direct dependency of the TimelineProvider and should be strongly retained by it. If there's a cycle it should be handled another way.

Johannes tries to get weird retain cycle context from last night back into his head. 😅

I think they're mutual dependencies, right? The reason I made the reference in RoomTimelineProvider the weak one is that RoomTimelineProvider seems to only ever be created (and retained) in RoomProxy. RommProxy, on the other hand, is created and returned in ClientProxy so I assumed this was the object the caller would retain.

LE: I had a closer look at it, we need to take the timelineProvider out of the roomProxy and create it when needed in the AppCoordinatorUserSessionFlowCoordinator. The timelineProvider can register itself as a listener on its own roomProxy dependency.

That might be a better solution altogether. I'll have to return to this after hours.

@stefanceriu
Copy link
Member

Yeah, the RoomProxy used to create the timelineProvider and retain it itself. I fixed it here if you want to have a look /pull/220

@Johennes
Copy link
Contributor Author

Discarding this over #220.

@Johennes Johennes closed this Sep 28, 2022
@stefanceriu stefanceriu deleted the johannes/room-proxy-leak branch September 29, 2022 05:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Memory leak in RoomProxy
2 participants