4

There are a number of questions regarding the "wait_fences: failed to receive reply" on this forum already, but none of the proposed solutions work for me (although they did help me to mitigate it).

When my app starts up, I do a reachability check, and if I can't reach the host I'm looking for, I pop up a UIAlertView. Initially I was doing this before I even set up the view controller, but then I learned one of the causes of the "wait_fences" problem is that the responder chain isn't properly set up if you haven't displayed a view yet - so I moved everything down into -viewDidAppear. Basically, this is what I have:

- (void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];

    // Figure out what the reflections name is, then check to see if it can find it online;
    // If it can't, -informUserSiteIsNotReachable is called, below
    [self retrieveReflectionByName:self.todaysReflectionName];

    [self displayReflectionByName:self.todaysReflectionName];
}

- (void)informUserSiteIsNotReachable 
{
    SEL messageSelector;

    if (NO == [self internetIsReachable]) {
        messageSelector = @selector(internetNotAccessible);
    } else {
        messageSelector = @selector(reflectionsSiteNotAccessible);
    }
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:[Strings alertViewTitleWhenSiteIsUnreachable] message:[Strings performSelector:messageSelector]  delegate:self cancelButtonTitle:@"OK" otherButtonTitles:NULL];
    [alert show];
    [alert release];
}

I can't seem to get rid of the wait_fences problem: any suggestions?

JoBu1324
  • 7,751
  • 6
  • 44
  • 61
  • No one has any suggestions, or even suggested readings for me? I'll do anything to get rid of this message (well, almost anything). – JoBu1324 Jul 08 '10 at 22:48
  • hi JoBu 1324, did u get any answer for your question. I am also facing the same issuce while rotating my app. Can you please help me on this. – CKT Aug 14 '10 at 09:57
  • No I didn't; the best I've been able to do is minimize the wait it causes by moving the alert into -viewDidAppear as I mentioned. Let me know if you discover anything! – JoBu1324 Aug 24 '10 at 22:16
  • You can surely solve this problem as I answered for the same as below. You just need to use one Timer to delay the AlertView. – AppAspect Jul 02 '11 at 08:12

1 Answers1

0

Here I also faced the same problem in my projects and I solved the issue which is "wait_fences".

Here you can do one change in your code as follows:

- (void)informUserSiteIsNotReachable 
{
    SEL messageSelector;

    if (NO == [self internetIsReachable]) {
        messageSelector = @selector(internetNotAccessible);
    } else {
        messageSelector = @selector(reflectionsSiteNotAccessible);
    }

    [NSTimer scheduledTimerWithTimeInterval:0.001 target:self selector:@selector(Show_AlertMessage) userInfo:nil repeats:NO];
}

- (void) Show_AlertMessage
{
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:[Strings alertViewTitleWhenSiteIsUnreachable] message:[Strings performSelector:messageSelector]  delegate:self cancelButtonTitle:@"OK" otherButtonTitles:NULL];
    [alert show];
    [alert release];
}

This works for me. Hope you get rid of this wait_fences issue soon. Let me know if you still have the problem.

AppAspect
  • 4,461
  • 2
  • 30
  • 46
  • That would work, but I don't like the tradeoff between reliability and response time. I'm looking an answer with less guess work (i.e. no timer) and more "best practice" – JoBu1324 Jul 02 '11 at 21:00
  • Hello, The timer is in mili seconds. Here if you don't want timer then the alternative you go with the NSThread. You can just try once. I like to solve this problem. – AppAspect Jul 03 '11 at 05:20
  • A timer would work better than NSThread, since you can set up the timer with enough time to allow the responder chain to get set up. When I wrote this question, I was looking for a way to know when the responder chain finishes getting set up - something I ultimately never found out. – JoBu1324 Jul 06 '11 at 22:58
  • 1
    Sorry I can't accept your answer even though it would work, it just isn't the answer I was looking for. Perhaps what I was looking for can't be done; there are various cosmetic bandaids that can be used, though - including the one you listed. – JoBu1324 Jul 06 '11 at 23:00