Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion ios/RNMBX/Offline/RNMBXOfflineModule.swift
Original file line number Diff line number Diff line change
Expand Up @@ -424,9 +424,17 @@ class RNMBXOfflineModule: RCTEventEmitter {
}
}

taskGroup.notify(queue: .main) {
// `threadedOfflineManager` is function-local, and neither the closures above
// nor `cancelables` (which holds the tasks, not the manager) retain it. Left
// alone it would be deinitialized as soon as `startLoading` returns, while
// the style pack load and the tileset descriptor it vended are still in
// flight, which aborts with "object deallocated with non-zero retain count".
// The task group already marks the point where both are done, so hold the
// manager until then.
taskGroup.notify(queue: .main) { [threadedOfflineManager] in
self.tileRegionPacks[id]!.cancelables = []
self.tileRegionPacks[id]!.state = downloadError ? .inactive : .complete
withExtendedLifetime(threadedOfflineManager) {}
}

self.tileRegionPacks[id]!.cancelables = [task, stylePackTask]
Expand Down