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

iOS app crashes on td_json_client_destroy #594

Closed
Demetriy opened this issue Jun 13, 2019 · 5 comments
Closed

iOS app crashes on td_json_client_destroy #594

Demetriy opened this issue Jun 13, 2019 · 5 comments

Comments

@Demetriy
Copy link

I'm using modified example of this code https://github.com/tdlib/td/blob/master/example/swift/src/main.swift, previously in tdlib 1.3 when user drops app in background i destroyed client with td_json_client_destroy(client), but in 1.4 i'm started to get messages: �[1;31m[ 0][t 0][1560468306.749094009][Client.cpp:269] Check !is_locked failed

How can i properly close connection on app background and then create it again in 1.4?

@levlam
Copy link
Contributor

levlam commented Jun 14, 2019

This is a sanity check that td_json_client_receive is not run while the client is being destroyed. td_json_client_destroy completly destroys a client, so the client must not be used from other threads at that time. To properly close the client, you need to call close method and wait for updateAuthorizationState with authorizationStateClosed. After that you can stop to call td_json_client_receive and can destroy the client via td_json_client_destroy.

@Demetriy
Copy link
Author

Thanks! I solved my problem with your help :)

@chairus
Copy link

chairus commented Apr 30, 2020

@levlam Just a question. Telegram clients created in different threads are completely independent from one another right? i.e. one thread closing/destroying it's client doesn't affect other clients in different thread that were created independently.

@chairus
Copy link

chairus commented Apr 30, 2020

also if a file is currently being downloaded and the client is destroyed does it also result in that Check !is_locked error?

@levlam
Copy link
Contributor

levlam commented Apr 30, 2020

@chairus All TDLib clients are independent and doesn't affect each other, except competing for system resources. Client's thread doesn't matter.

Check !is_locked is always an application error, which tries to destroy the client while it is still being used in another thread. It doesn't matter whether some download file or other pending operation is in progress.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants