wwt / SwiftCurrent

A library for managing complex workflows in Swift
https://wwt.github.io/SwiftCurrent/
Apache License 2.0
307 stars 19 forks source link

Fixes an issue where holding self weakly is causing a memory leak when calling workflow.abandon #190

Closed nickkaczmarek closed 2 years ago

nickkaczmarek commented 2 years ago

Abstract

There was an issue where calling workflow.abandon in the onFinish completion handler of a launched workflow could fail to be called because the workflow had already been deallocated. This caused ViewControllers to remain allocated. This issue did not occur when the workflow was abandoned within the workflow, but did reliably occur when trying to clean up when finishing.

By making this a strong reference, we can see in the memory graph that the ViewControllers are being reliably deallocated. I attached a video of me doing just this. Starting with the current code and showing all of the ViewControllers still in memory and then re-running with the strong reference showing all of the ViewControllers no longer in memory.

Video

video showing memory graph debugging

Linked Issue: Closes #41

Checklist:

codecov-commenter commented 2 years ago

Codecov Report

Merging #190 (caca894) into main (edaedd0) will not change coverage. The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##             main     #190   +/-   ##
=======================================
  Coverage   91.28%   91.28%           
=======================================
  Files          92       92           
  Lines        2375     2375           
=======================================
  Hits         2168     2168           
  Misses        207      207           
Impacted Files Coverage Δ
...rent_UIKit/Extensions/WorkflowUIKitAdditions.swift 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update a6b7b22...caca894. Read the comment docs.