objective c - iOS 9 - Network reachability change causes the view to freeze - Not a crash -
after upgrading ios 9. app having strange problem.
problem : whenever network reachability changes, app's view freezes. not responding touch events. has not crashed either . checked logs. change network reachability.
more information:
1) if quit app , open again internet online, it's working fine.
2) if open app internet offline, view freezes. doesn't happen in ios 8.4.
i'm using reachability tony million library checking online/offline status.
has faced same issue after upgrading ios 9?
code reference:
self.appisonline = yes; _reachability = [reachability reachabilitywithhostname:@"www.google.com"]; __weak __typeof(self)weakself = self; [_reachability setreachableblock: ^(reachability * reachability) { nslog(@"online"); if (!weakself.appisonline) { weakself.appisonline = yes; weakself.willshowalertview = yes; dispatch_async(dispatch_get_main_queue(), ^{ customalertview *alertview = [[customalertview alloc] initwithtitle:@"warning" andmessage:@"the internet connection appears online. app switch online mode now" delegate:weakself withbuttons:@[@"ok"]]; alertview.shouldtapoutsidetoclose = yes; [alertview showinview:main_window]; }); } }]; [_reachability setunreachableblock:^(reachability * reachability) { nslog(@"offline"); if (weakself.appisonline) { [[nsnotificationcenter defaultcenter] postnotificationname:offline_state_notification object:nil]; weakself.appisonline = no; dispatch_async(dispatch_get_main_queue(), ^{ [[apputilities sharedutilities] displayalertviewwithtitle:@"warning" andmessage:@"the internet connection appears offline. app switch offline mode now"]; }); } }]; [_reachability startnotifier];
looks main ui thread being blocked , trigger turning off wi-fi. thread trace below.
thread 1queue : com.apple.main-thread (serial) #0 0x38739130 in mach_msg_trap () #1 0x38738f30 in mach_msg () #2 0x265624ec in __cfrunloopservicemachport () #3 0x26560872 in __cfrunlooprun () #4 0x264b31e8 in cfrunlooprunspecific () #5 0x264b2fdc in cfrunloopruninmode () #6 0x2f757af8 in gseventrunmodal () #7 0x2a71818c in uiapplicationmain () #8 0x00117f20 in main thread 3queue : com.apple.libdispatch-manager (serial) #0 0x3874e3c0 in kevent_qos () #1 0x0067d5f6 in _dispatch_mgr_invoke () #2 0x0066ea76 in _dispatch_mgr_thread () com.apple.nsurlconnectionloader (11) #0 0x38739130 in mach_msg_trap () #1 0x38738f30 in mach_msg () #2 0x265624ec in __cfrunloopservicemachport () #3 0x26560872 in __cfrunlooprun () #4 0x264b31e8 in cfrunlooprunspecific () #5 0x264b2fdc in cfrunloopruninmode () #6 0x25e240ae in +[nsurlconnection(loader) _resourceloadloop:] () #7 0x273747fc in __nsthread__start__ () #8 0x387ebc92 in _pthread_body () #9 0x387ebc06 in _pthread_start () #10 0x387e9a24 in thread_start () afnetworking (12)#0 0x38739130 in mach_msg_trap () #1 0x38738f30 in mach_msg () #2 0x265624ec in __cfrunloopservicemachport () #3 0x26560872 in __cfrunlooprun () #4 0x264b31e8 in cfrunlooprunspecific () #5 0x264b2fdc in cfrunloopruninmode () #6 0x272a3d7c in -[nsrunloop(nsrunloop) runmode:beforedate:] () #7 0x272f28ec in -[nsrunloop(nsrunloop) run] () #8 0x00122a2e in +[afurlconnectionoperation networkrequestthreadentrypoint:] @ /pods/afnetworking/afnetworking/afurlconnectionoperation.m:168 #9 0x273747fc in __nsthread__start__ () #10 0x387ebc92 in _pthread_body () #11 0x387ebc06 in _pthread_start () #12 0x387e9a24 in thread_start () com.apple.cfsocket.private (13)#0 0x3874cfb4 in __select () #1 0x26567990 in __cfsocketmanager () #2 0x387ebc92 in _pthread_body () #3 0x387ebc06 in _pthread_start () #4 0x387e9a24 in thread_start ()
i able find real issue. not reachability class. due customalertview. whenever reachability changes, app pops alert saying offline/online. presenting alert view directly on main window
[alertview showinview:main_window];
where
#define main_window [uiapplication sharedapplication].keywindow
in ios 9 not allowed. when tries show, ui thread paused. solved doing instead
[alertview showinview:main_window.rootviewcontroller.view];
Comments
Post a Comment