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

ASNodeController (post-NSLocking) is causing deadlock in 2.8 #1342

Closed
stephensilber opened this issue Feb 15, 2019 · 3 comments
Closed

ASNodeController (post-NSLocking) is causing deadlock in 2.8 #1342

stephensilber opened this issue Feb 15, 2019 · 3 comments

Comments

@stephensilber
Copy link

stephensilber commented Feb 15, 2019

We use ASNodeController throughout our app, and after upgrading to 2.8, I'm seeing a deadlock in one of our node controllers. It seems to have started after this pull request was merged in:
#1179

It looks like @appleguy may have brought this up as a potential problem in the #1179 PR review.
https://github.com/TextureGroup/Texture/pull/1179/files/83696de05cc03e6ced2a76780b8a03f1442b0b92#diff-201f20cb04a043f825170266014a5b25R42

Here's my node controller:


class HoldingsNodeController: ASNodeController<ASCollectionNode> {
    var securitySelected: ((_ securityId: Int, _ holdingId: Int) -> Void)?
    
    lazy var flowLayout = UICollectionViewFlowLayout()

    
    private var holdingsSubscription: StateSubscription<HoldingsViewModelState>?
    private let holdingsViewModel: HoldingsViewModel
    private let collectionController = CollectionController()
    
    init(holdingsViewModel: HoldingsViewModel) {
        self.holdingsViewModel = holdingsViewModel
        super.init()
        holdingsViewModel.fetchHoldings()
    }
    
    override func didExitPreloadState() {
        super.didExitPreloadState()
        holdingsViewModel.unsubscribe(from: self)
    }
    
    override func didEnterPreloadState() {
        super.didEnterPreloadState()
        holdingsViewModel.subscribe(from: self)
    }
    
    override func createNode() -> ASCollectionNode {
        return ASCollectionNode(collectionViewLayout: flowLayout)
    }
    
    override func nodeDidLoad() {
        super.nodeDidLoad()
        node.backgroundColor = .white
        node.alwaysBounceVertical = true
        node.dataSource = collectionController
        node.delegate = collectionController
        node.view.delaysContentTouches = false
    }
    
    // MARK: StatefulView

    typealias State = HoldingsViewModelState
    
    var renderPolicy: RenderPolicy {
        return .possible
    }
    
    func render(state: HoldingsViewModelState) {
        reload()
    }
}

Things I have tried:

  • Commenting out the ASLockScopeSelf in ASNodeController implementation file does fix the issue
  • Removing a reference to flowLayout and instead just passing UICollectionViewLayout() in the collection initialization
  • moving some of the node configuration out of createNode and into nodeDidLoad
@stephensilber stephensilber changed the title ASNodeController (post-NSLocking) is causing deadlock ASNodeController (post-NSLocking) is causing deadlock in 2.8 Feb 15, 2019
@stephensilber
Copy link
Author

It looks like this was addressed (at least temporarily) here: 6428077

But maybe @Adlai-Holler can confirm before I close this?

@maicki
Copy link
Contributor

maicki commented Feb 25, 2019

@stephensilber Yes this should be addressed with 6428077. Can you please try out master if this fixes your problem? Thanks!

@stephensilber
Copy link
Author

@maicki Master seems to be working. Thanks!

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

No branches or pull requests

2 participants