Uploaded image for project: 'Titanium SDK/CLI'
  1. Titanium SDK/CLI
  2. TIMOB-24648

iOS: Network Activity Indicator does not work for Synchronous Requests

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Critical
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: Release 6.2.0
    • Component/s: iOS
    • Labels:
    • Environment:

      OSX 10.12.4
      Appcelerator Studio, build: 4.8.1
      Titanium SDK 6.0.4.GA
      Xcode 8.3.2

      Description

      Network activity indicator only works for the first network call. Subsequent network calls do not show the network activity indicator. I traced this through xcode and it looks like synchronous requests are calling TiApp stopNetwork twice.

      In TiNetworkHTTPClientProxy:
      in send

      [[TiApp app] startNetwork];
          if(async) {
              [httpRequest setTheQueue:operationQueue];
              [httpRequest send];
          } else {
              [httpRequest setSynchronous:YES];
              [httpRequest send];
              NSLog(@"Calling Stop Network from sync");
             [[TiApp app] stopNetwork];
              [self forgetSelf];
          }
      

      In request onLoad..

      -(void)request:(APSHTTPRequest *)request onLoad:(APSHTTPResponse *)response
      {
          NSLog(@"Calling Stop Network from request onLoad");
          [[TiApp app] stopNetwork];
          if([request cancelled]) {
              [self forgetSelf];
              return;
          }
          NSInteger responseCode = [response status];
          /**
           *    Per customer request, successful communications that resulted in an
           *    4xx or 5xx response is treated as an error instead of an onload.
           *    For backwards compatibility, if no error handler is provided, even
           *    an 4xx or 5xx response will fall back onto an onload.
           */
          if (hasOnerror && (responseCode >= 400) && (responseCode <= 599)) {
              NSMutableDictionary * event = [TiUtils dictionaryWithCode:responseCode message:@"HTTP error"];
              [event setObject:@"error" forKey:@"type"];
              [self fireCallback:@"onerror" withArg:event withSource:self withHandler:^(id result){
                  [self forgetSelf];
              }];
          } else if(hasOnload) {
              NSMutableDictionary * event = [TiUtils dictionaryWithCode:0 message:nil];
              [event setObject:@"load" forKey:@"type"];
              [self fireCallback:@"onload" withArg:event withSource:self withHandler:^(id result){
                  [self forgetSelf];
              }];
          } else {
              [self forgetSelf];
          }
      }
      

      My Log from a one synchronous request

      2017-05-01 16:19:16.658 My App[98152:872410] Start Network
      2017-05-01 16:19:16.867 My App[98152:872651] Calling Stop Network from request onLoad
      2017-05-01 16:19:16.868 My App[98152:872410] Stop Network
      2017-05-01 16:19:16.868 My App[98152:872651] Calling Stop Network from sync
      2017-05-01 16:19:16.868 My App[98152:872410] Stop Network
      

        Attachments

          Activity

            People

            • Assignee:
              hknoechel Hans Knöchel
              Reporter:
              nthurston8 Nicholas Thurston
              Reviewer:
              Vijay Singh
              Tester:
              Harry Bryant
            • Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Backbone Issue Sync

                • Titanium SDK/CLI <> Titanium Mobile
                  Synced with:
                  TIMOB-10649
                  Sync status:
                  ERROR
                  Last received:
                  Last sent:

                  Git Source Code