Reputation: 35953
I have this app of mine created for iPhone 4 when it was launched. Now, this app is not running on iPhone 4S.
I have identified the culprit section as a GCD part. Here it is:
dispatch_group_t my_group = dispatch_group_create();
dispatch_queue_t queue1 =
dispatch_queue_create("Queue 1", NULL);
dispatch_queue_t queue2 =
dispatch_queue_create("Queue 2", NULL);
dispatch_group_async(my_group, queue1, ^{
[self doStuff1];
});
dispatch_group_async(my_group, queue2, ^{
[self doStuff2];
});
dispatch_group_notify(my_group, dispatch_get_main_queue(), ^{
// this is block 3, this is to be executed after both queues end processing
// this is never executed on iPhone 4S, but is executed on iPhone4
// no error message, but execution never starts inside this block
});
the idea is this: two queues are created and a group. I fire tasks for both queues, asynchronously, using the group. When both are finished, the group fires another block of tasks.
This work wonderfully on iPhone 4, but the final block 3 is never reached.
Any reason for that? Any clues?
thanks.
Upvotes: 3
Views: 551
Reputation: 3266
The first thing I would do is change the code to dispatch_async everything on queue1; you won't get concurrency, obviously, but will instantly know if dostuff1 and dostuff2 are colliding somehow if the problem immediately goes away. On a single core machine, this is probably the execution behavior you were actually seeing before.
Upvotes: 2
Reputation: 57168
Perhaps doStuff1
and doStuff2
are deadlocking, or something else is blocking the main thread? The 4S has multiple cores, unlike the 4, so it could be that you're encountering some a multithreading lock issues you wouldn't have seen before.
Are you sure that both blocks are actually finishing, and that the main thread is available to run the resulting block? Perhaps some complete code (i.e. the bodies of doStuff1 and 2) would help?
Upvotes: 5