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

The getData call for RTDB completion handler is not called on the main thread #8245

Closed
puf opened this issue Jun 11, 2021 · 2 comments
Closed

Comments

@puf
Copy link

puf commented Jun 11, 2021

[REQUIRED] Step 1: Describe your environment

  • Xcode version: _____
  • Firebase SDK version: _____
  • Installation method: CocoaPods | Carthage | Zip file | Swift Package Manager (select one)
  • Firebase Component: Realtime Database

[REQUIRED] Step 2: Describe the problem

See https://stackoverflow.com/q/67941742 for the original report.

Steps to reproduce:

While the Firebase SDK performs its network and other I/O on a background thread, it actually calls your callback on the main thread.

But it seems that getData does not do that here. See below for relevant code. 👇

Relevant Code:

This works

databaseReference.observe(.value) { [weak self] snapshot in
        guard let self = self else { return }
        self.tableView.reloadData()
}

This throws an error UICollectionView.reloadData() must used from main thread only:
databaseReference.getData { [weak self] error, snapshot in
guard let self = self else { return }
self.tableView.reloadData()
}

@google-oss-bot
Copy link

I found a few problems with this issue:

  • I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.
  • This issue does not seem to follow the issue template. Make sure you provide all the required information.

@paulb777
Copy link
Member

Fixed by #8247 and merged for 8.5.0 release

@firebase firebase locked and limited conversation to collaborators Aug 16, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants