Reputation: 1183
I have an app where I read data from input stream and visualize it to user. When I set up input stream, I set it up in background run loop, open it and then run a background loop. But sometimes my app breaks unexpectedly. I can't repeat this crash so I don't even know where to start to fix it.
The crash I get looks like this:
And the method where it crashes looks like this:
It says that it is Enqueued from background queue (Thread 3)
. And Thread 3
looks like that:
What could be the reason of this? Where should I start to fix it?
And the strange thing is that in Thread 17
, where it crashes variable bg_queue
is nil, and anyway it passes the if condition where i do
if (bg_queue != nil)
But in Thread 3 it is not nil:
Upvotes: 0
Views: 71
Reputation: 52546
If you create a second runloop, you are more courageous than I am. I would never dare doing that, because I would be just sure that it leads to problems that are too hard for me to fix. As you are finding out.
If you are sure that you are a much more clever developer than I am, then sorry, you're on your own. If you are not sure, then DON'T DO THAT! Stay away from secondary run loops!
Upvotes: 1
Reputation: 19116
It seems, you create a run loop from a secondary thread managed by GCD. You should not obtain a run loop from a thread that is managed by GCD!
Create your own dedicated thread or use the main thread to obtain a run loop.
Upvotes: 2