Skip to content

Commit

Permalink
Log module lifecycle info to 'local' only to prevent it from crashing…
Browse files Browse the repository at this point in the history
… when JS context is down
  • Loading branch information
kmagiera committed Sep 14, 2017
1 parent 4bd0b76 commit 46b3a32
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions ios/RNGestureHandlerManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
#import "RNGestureHandlerState.h"
#import "RNGestureHandler.h"

// We use the method below instead of RCTLog because we log out messages after the bridge gets
// turned down in some cases. Which normally with RCTLog would cause a crash in DEBUG mode
#define RCTLifecycleLog(...) RCTDefaultLogFunction(RCTLogLevelInfo, RCTLogSourceNative, @(__FILE__), @(__LINE__), [NSString stringWithFormat:__VA_ARGS__])

@interface RNGestureHandlerManager () <RNGestureHandlerEventEmitter, RNRootViewGestureRecognizerDelegate>

@end
Expand Down Expand Up @@ -115,7 +119,7 @@ - (void)registerRootViewIfNeeded:(UIView*)childView
RCTRootView *rootView = (RCTRootView *)parent;
UIView *rootContentView = rootView.contentView;
if (rootContentView != nil && ![_rootViews containsObject:rootContentView]) {
RCTLogInfo(@"[GESTURE HANDLER] Initialize gesture handler for root view %@", rootContentView);
RCTLifecycleLog(@"[GESTURE HANDLER] Initialize gesture handler for root view %@", rootContentView);
[_rootViews addObject:rootContentView];
RNRootViewGestureRecognizer *recognizer = [RNRootViewGestureRecognizer new];
recognizer.delegate = self;
Expand Down Expand Up @@ -145,7 +149,7 @@ - (void)gestureHandlerDidActivateInRootView:(UIView*)rootView
- (void)dealloc
{
if ([_rootViews count] > 0) {
RCTLogInfo(@"[GESTURE HANDLER] Tearing down gesture handler registered for views %@", _rootViews);
RCTLifecycleLog(@"[GESTURE HANDLER] Tearing down gesture handler registered for views %@", _rootViews);
}
}

Expand Down

0 comments on commit 46b3a32

Please sign in to comment.