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

SignalCache can perform FileIO on the main thread. #137

Closed
Dean151 opened this issue Jan 28, 2024 · 2 comments · Fixed by #187
Closed

SignalCache can perform FileIO on the main thread. #137

Dean151 opened this issue Jan 28, 2024 · 2 comments · Fixed by #187
Assignees
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@Dean151
Copy link

Dean151 commented Jan 28, 2024

Related:
Capture d’écran 2024-01-28 à 19 40 46

Thankfully, Marcin helped out to understand:
https://mastodon.social/@krzyzanowskim/111835373363274251

Turns out that calling .sync will block the calling thread, so the fileIO is indeed blocking the main thread, because backupCache is called from either appWillTerminate or didEnterBackground methods.

@Jeehut
Copy link
Contributor

Jeehut commented Sep 21, 2024

@Dean151 Thank you for reporting this. Unfortunately the Mastodon link you've posted does not work, maybe the post was deleted? In any case, the main problem with this code is that we kinda want to block the main thread before the app gets killed by the system. Or to be more precise: We want to avoid that the app gets killed while the write is in progress. If we simply put the write into a background thread, this could lead to data loss.

But I think I found a solution to this. See #187.

@Dean151
Copy link
Author

Dean151 commented Sep 29, 2024

Not sure how to reproduce.
It was just a runtime warning I got some couple times when debugging from the simulator.
I trust your fix proposal :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants