4

I encountered this strange bug: sometimes when I push a view controller(VC1 -> VC2), the app gets frozen(It doesn't crash, just freeze). There is no blocking main thread. And when I check the View Hierarchy, the VC2 is actually under a "UIParallaxDimmingView". Also, the viewDidLoad, viewDidAppear are called.

How I present VC2:

VC *vc2 = [[VC alloc]initWithStyle:UITableViewStyleGrouped];
[self.navigationController pushViewController:vc2 animated:YES];

So the problem is the VC2 is loaded but does not appear on screen. Here is the screen shot of the view hierarchy, the highlighted blue view is the UIParallaxDimmingView, and it's blocking all my VC2 contents, and the VC1 is actually under VC2...

enter image description here

and here is my stack trace

0x10016b8dc <+0>:   sub    sp, sp, #0x40             ; =0x40 
0x10016b8e0 <+4>:   stp    x29, x30, [sp, #0x30]
0x10016b8e4 <+8>:   add    x29, sp, #0x30            ; =0x30 
0x10016b8e8 <+12>:  stur   wzr, [x29, #-0x4]
0x10016b8ec <+16>:  stur   w0, [x29, #-0x8]
0x10016b8f0 <+20>:  stur   x1, [x29, #-0x10]
0x10016b8f4 <+24>:  bl     0x1004105a4               ; symbol stub for: objc_autoreleasePoolPush
0x10016b8f8 <+28>:  adrp   x1, 1044
0x10016b8fc <+32>:  add    x1, x1, #0x888            ; =0x888 
0x10016b900 <+36>:  adrp   x30, 1057
0x10016b904 <+40>:  add    x30, x30, #0xd70          ; =0xd70 
0x10016b908 <+44>:  ldur   w8, [x29, #-0x8]
0x10016b90c <+48>:  ldur   x9, [x29, #-0x10]
0x10016b910 <+52>:  ldr    x30, [x30]
0x10016b914 <+56>:  ldr    x1, [x1]
0x10016b918 <+60>:  str    x0, [sp, #0x18]
0x10016b91c <+64>:  mov    x0, x30
0x10016b920 <+68>:  str    w8, [sp, #0x14]
0x10016b924 <+72>:  str    x9, [sp, #0x8]
0x10016b928 <+76>:  bl     0x1004106c4               ; symbol stub for: objc_msgSend
0x10016b92c <+80>:  bl     0x10040fc20               ; symbol stub for: NSStringFromClass
0x10016b930 <+84>:  mov    x29, x29
0x10016b934 <+88>:  bl     0x100410718               ; symbol stub for: objc_retainAutoreleasedReturnValue
0x10016b938 <+92>:  mov    x9, #0x0
0x10016b93c <+96>:  ldr    w8, [sp, #0x14]
0x10016b940 <+100>: str    x0, [sp]
0x10016b944 <+104>: mov    x0, x8
0x10016b948 <+108>: ldr    x1, [sp, #0x8]
0x10016b94c <+112>: mov    x2, x9
0x10016b950 <+116>: ldr    x3, [sp]
0x10016b954 <+120>: bl     0x10040fd28               ; symbol stub for: UIApplicationMain
0x10016b958 <+124>: stur   w0, [x29, #-0x4]
0x10016b95c <+128>: ldr    x1, [sp]
0x10016b960 <+132>: mov    x0, x1
0x10016b964 <+136>: bl     0x1004106e8               ; symbol stub for: objc_release
0x10016b968 <+140>: ldr    x0, [sp, #0x18]
0x10016b96c <+144>: bl     0x100410598               ; symbol stub for: objc_autoreleasePoolPop
0x10016b970 <+148>: ldur   w0, [x29, #-0x4]
0x10016b974 <+152>: ldp    x29, x30, [sp, #0x30]
0x10016b978 <+156>: add    sp, sp, #0x40             ; =0x40 
0x10016b97c <+160>: ret`
Dovahkiin
  • 1,239
  • 11
  • 23
  • how do you load the VC2? code snippet? – Hashmat Khalil Jul 03 '17 at 10:12
  • have you checked the CPU? – Tony Thomas Jul 03 '17 at 10:54
  • @HashmatKhalil please see my updated question, just the normal way, nothing fancy – Dovahkiin Jul 03 '17 at 17:56
  • You may need to share VC2's init method, plus `-viewDidLoad`, `-viewWillAppear:` and `-viewDidAppear:`. If you're not doing anything interesting or unusual there, this sounds like an OS bug, but it seems like rather an unlikely one. – Seamus Campbell Jul 03 '17 at 18:00
  • @SeamusCampbell I didn't do anything that may affect the UI, I think it is an iOS bug, coz the interesting thing is: when it freezes, and I press home button returning to home screen, then go back to the app, the VC2 just appears like normal. So there's definitely nothing blocking the main thread. So strange. – Dovahkiin Jul 03 '17 at 18:12
  • the issue sounds like as if the presentation of the VC happens in a background thread. can you check if that is not the case? – Hashmat Khalil Jul 04 '17 at 08:00

2 Answers2

2

I managed to find a solution here

So my interactivePopGestureRecognizer is enabled even when the current visible view controller is the only VC on the navigation stack. Simply disable that will solve the bug.

Dovahkiin
  • 1,239
  • 11
  • 23
0

SWIFT 3

func navigationController(_ navigationController: UINavigationController, didShow viewController: UIViewController, animated: Bool) {


    if (navigationController.viewControllers.count > 1)
    {
         self.navigationController?.interactivePopGestureRecognizer?.delegate = self
        navigationController.interactivePopGestureRecognizer?.isEnabled = true;
    }
    else
    {
         self.navigationController?.interactivePopGestureRecognizer?.delegate = nil
        navigationController.interactivePopGestureRecognizer?.isEnabled = false;
    }
}
Marlhex
  • 1,870
  • 19
  • 27