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

Main Thread Checker: UI API called on background thread. #3129

Closed
Ruckt opened this issue Dec 22, 2017 · 6 comments
Closed

Main Thread Checker: UI API called on background thread. #3129

Ruckt opened this issue Dec 22, 2017 · 6 comments

Comments

@Ruckt
Copy link

Ruckt commented Dec 22, 2017

I got the following console log warning from using your chart. When I wrap it in a block to be executed on the main thread, I no longer get that warning. Would you be able to fix it on your end so I don't have to fork it?

screen shot 2017-12-22 at 11 31 17 am

@liuxuan30
Copy link
Member

I don't think that what we need to fix. Any UI related task must be executed on main thread is a must know thing.

@Ruckt
Copy link
Author

Ruckt commented Dec 23, 2017

Well, if its a known thing that all UI tasks must be executed on the main thread, why are you not making sure its all on there in your pod? It's a known thing that when a problem arises in code, you go through the due diligence to find the cause to prevent it from happening again.

@liuxuan30
Copy link
Member

Well, that will make the library have code that's not its concern.
If what you said correct, that's apple's duty to check all UI tasks on main thread, not ours. But as you see, Apple just warns you instead of do the work for you.
I will admit if that can be done, things will be lot of easier.

@Ruckt
Copy link
Author

Ruckt commented Dec 26, 2017

Apple is warning for a reason - because something is not up to its expectations. Or its not perfect and needs help - it only discovers its on the background thread after execution. That's where you come in to fix it.

@jjatie
Copy link
Collaborator

jjatie commented Dec 28, 2017

Looking at Thread 12 in your screenshot, it looks like you are receiving information on a background thread and trying to update your chart from there. It is your responsibility to ensure that you're calling methods that update the visual representation of the Chart on the main thread, just as it's your responsibility to ensure all other UI calls are done on the main thread.

If you feel this is not the case, you should file a bug report with Apple as almost none, if not none, of their UI calls are automatically rerouted to the main thread.

@Ruckt
Copy link
Author

Ruckt commented Dec 29, 2017

Thank you @jjatie for helping me find the problem. I was too busy distracted by the code and not the threads on the left, which display the method being called that triggers the warning.... Was able to put that on the main thread to eliminate the warning. It was the clear method I was calling on the background while the graph was being drawn on the main.

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