Firebase freezes UI even when using DispatchQueue

2019-07-13 17:58发布

问题:

From my understanding, Firebase performs operations off the main thread and shouldn't pause the UI while doing so.

The code below is a simplified example, but everywhere in my code, where I have a Firebase observer with code that updates the UI, the UI freezes while Firebase downloads data.

I've tried writing the same code in a new, clean project, and then the problem no longer exist. Could the problem be the installation of Firebase through pods? I'm also using GeoFire, could that affect in any way?

I have also tried to put the observer inside of a DispatchQueue.global().async block. I've tried removing any DispatchQueue code completely, but it is all the same.

func observe() {
  firebaseReference.observe(.value, with: { (snapshot) in
      DispatchQueue.main.async {
        self.collectionView?.reloadData()
      }
  })
}