Brion VIBBER has submitted this change and it was merged.

Change subject: Fix for crashes when nav items tapped while views are 
transitioning.
......................................................................


Fix for crashes when nav items tapped while views are transitioning.

There had been code to debounce the "W" menu, but another crash was
discovered: Tap edit pencil, then tap "X" icon and "W" menu icon in
quick succession. CRASH! This patch is a generic solution which
handles both of these crashes and should prevent any similar crashes
elsewhere.

Change-Id: I838f101878fe5d1337d21a64f974a3a03c595609
---
M Wikipedia-iOS/View Controllers/TopNav/NavController.m
1 file changed, 24 insertions(+), 9 deletions(-)

Approvals:
  Brion VIBBER: Verified; Looks good to me, approved



diff --git a/Wikipedia-iOS/View Controllers/TopNav/NavController.m 
b/Wikipedia-iOS/View Controllers/TopNav/NavController.m
index 350f6ce..26731ff 100644
--- a/Wikipedia-iOS/View Controllers/TopNav/NavController.m
+++ b/Wikipedia-iOS/View Controllers/TopNav/NavController.m
@@ -42,6 +42,8 @@
 @property (strong, nonatomic) NSDictionary *navBarSubViews;
 @property (strong, nonatomic) NSDictionary *navBarSubViewMetrics;
 
+@property (nonatomic) BOOL isTransitioningBetweenViewControllers;
+
 @end
 
 @implementation NavController
@@ -77,6 +79,8 @@
     self.navBarSubViews = [self getNavBarSubViews];
     
     self.navBarSubViewMetrics = [self getNavBarSubViewMetrics];
+    
+    self.isTransitioningBetweenViewControllers = NO;
 }
 
 #pragma mark Constraints
@@ -112,8 +116,28 @@
 
 - (void)navigationController:(UINavigationController *)navigationController 
willShowViewController:(UIViewController *)viewController 
animated:(BOOL)animated
 {
+    self.isTransitioningBetweenViewControllers = YES;
+
     [self showAlert:@""];
     [self showHTMLAlert:@"" bannerImage:nil bannerColor:nil];
+}
+
+- (void)navigationController:(UINavigationController *)navigationController 
didShowViewController:(UIViewController *)viewController animated:(BOOL)animated
+{
+    self.isTransitioningBetweenViewControllers = NO;
+}
+
+-(void)setIsTransitioningBetweenViewControllers:(BOOL)isTransitioningBetweenViewControllers
+{
+    _isTransitioningBetweenViewControllers = 
isTransitioningBetweenViewControllers;
+    
+    // Disabling userInteractionEnabled when nav stack views are being 
pushed/popped prevents
+    // "nested push animation can result in corrupted navigation bar" and 
"unbalanced calls
+    // to begin/end appearance transitions" errors. If this line is commented 
out, you can
+    // trigger the error by rapidly tapping on the main menu toggle (the "W" 
icon presently).
+    // You can also trigger another error by tapping the edit pencil, then tap 
the "X" icon
+    // then very quickly tap the "W" icon.
+    self.view.userInteractionEnabled = !isTransitioningBetweenViewControllers;
 }
 
 -(void)constrainNavBarContainer
@@ -443,15 +467,6 @@
 
 -(void)mainMenuToggle
 {
-    static CFTimeInterval lastToggleTime = 0;
-    CFTimeInterval elapsedTime = CACurrentMediaTime() - lastToggleTime;
-    if (elapsedTime > 0.7) {
-        lastToggleTime = CACurrentMediaTime();
-    }else{
-        // Don't allow toggle before previous toggle animation has finished.
-        return;
-    }
-
     UIViewController *topVC = self.topViewController;
 
     [topVC hideKeyboard];

-- 
To view, visit https://gerrit.wikimedia.org/r/118773
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I838f101878fe5d1337d21a64f974a3a03c595609
Gerrit-PatchSet: 1
Gerrit-Project: apps/ios/wikipedia
Gerrit-Branch: master
Gerrit-Owner: Mhurd <mh...@wikimedia.org>
Gerrit-Reviewer: Brion VIBBER <br...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to