Firebase freezes UI even when using DispatchQueue

时光毁灭记忆、已成空白 提交于 2020-01-02 18:03:51

问题


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()
      }
  })
}

来源:https://stackoverflow.com/questions/43106285/firebase-freezes-ui-even-when-using-dispatchqueue

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!