OhKanghoon/RxDataSources-Texture

RxASTableSectionedAnimatedDataSource Deadlock issue

GeekTree0101 opened this issue · 0 comments

public func tableNode(_ tableNode: ASTableNode, observedEvent: Event<[S]>) {
        Binder(self) { dataSource, newSections in
            #if DEBUG
            self._dataSourceBound = true
            #endif
            if !self.dataSet {
                self.dataSet = true
                dataSource.setSections(newSections)
                tableNode.reloadData()
            }
            else {
                DispatchQueue.main.async { // <- HERE
                    let oldSections = dataSource.sectionModels
                    do {
                        let differences = try Diff.differencesForSectionedView(initialSections: oldSections, finalSections: newSections)
                        
                        switch self.decideNodeTransition(self, tableNode, differences) {
                        case .animated:
                            for difference in differences {
                                dataSource.setSections(difference.finalSections)
                                
                                tableNode.performBatchUpdates(difference, animationConfiguration: self.animationConfiguration)
                            }
                        case .reload:
                            self.setSections(newSections)
                            tableNode.reloadData()
                            return
                        }
                    }
                    catch let e {
                        rxDebugFatalError(e)
                        self.setSections(newSections)
                        tableNode.reloadData()
                    }
                }
            }
            }.on(observedEvent)
    }

I guess, In subscribe step, Observer will lock as internal RecursiveLock. but i saw use DispatchQueue.main.async in binding step with locked status.