Fixed dev menu loop
This commit is contained in:
parent
f05494c96f
commit
205c22b915
|
@ -1144,18 +1144,11 @@ RCT_BRIDGE_WARN(_invokeAndProcessModule:(NSString *)module method:(NSString *)me
|
||||||
_latestJSExecutor = nil;
|
_latestJSExecutor = nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
void (^mainThreadInvalidate)(void) = ^{
|
||||||
* Main Thread deallocations
|
|
||||||
*/
|
|
||||||
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
|
||||||
[_mainDisplayLink invalidate];
|
|
||||||
|
|
||||||
[_javaScriptExecutor executeBlockOnJavaScriptQueue:^{
|
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
||||||
/**
|
[_mainDisplayLink invalidate];
|
||||||
* JS Thread deallocations
|
_mainDisplayLink = nil;
|
||||||
*/
|
|
||||||
[_javaScriptExecutor invalidate];
|
|
||||||
[_jsDisplayLink invalidate];
|
|
||||||
|
|
||||||
// Invalidate modules
|
// Invalidate modules
|
||||||
for (id target in _modulesByID.allObjects) {
|
for (id target in _modulesByID.allObjects) {
|
||||||
|
@ -1165,11 +1158,35 @@ RCT_BRIDGE_WARN(_invokeAndProcessModule:(NSString *)module method:(NSString *)me
|
||||||
}
|
}
|
||||||
|
|
||||||
// Release modules (breaks retain cycle if module has strong bridge reference)
|
// Release modules (breaks retain cycle if module has strong bridge reference)
|
||||||
_javaScriptExecutor = nil;
|
|
||||||
_frameUpdateObservers = nil;
|
_frameUpdateObservers = nil;
|
||||||
_modulesByID = nil;
|
_modulesByID = nil;
|
||||||
_queuesByID = nil;
|
_queuesByID = nil;
|
||||||
_modulesByName = nil;
|
_modulesByName = nil;
|
||||||
|
};
|
||||||
|
|
||||||
|
if (!_javaScriptExecutor) {
|
||||||
|
|
||||||
|
// No JS thread running
|
||||||
|
mainThreadInvalidate();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
[_javaScriptExecutor executeBlockOnJavaScriptQueue:^{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* JS Thread deallocations
|
||||||
|
*/
|
||||||
|
[_javaScriptExecutor invalidate];
|
||||||
|
_javaScriptExecutor = nil;
|
||||||
|
|
||||||
|
[_jsDisplayLink invalidate];
|
||||||
|
_jsDisplayLink = nil;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Main Thread deallocations
|
||||||
|
*/
|
||||||
|
mainThreadInvalidate();
|
||||||
|
|
||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -73,9 +73,6 @@ RCT_EXPORT_MODULE()
|
||||||
{
|
{
|
||||||
if ((self = [super init])) {
|
if ((self = [super init])) {
|
||||||
|
|
||||||
_defaults = [NSUserDefaults standardUserDefaults];
|
|
||||||
[self updateSettings];
|
|
||||||
|
|
||||||
NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
|
NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
|
||||||
|
|
||||||
[notificationCenter addObserver:self
|
[notificationCenter addObserver:self
|
||||||
|
@ -93,19 +90,27 @@ RCT_EXPORT_MODULE()
|
||||||
name:RCTJavaScriptDidLoadNotification
|
name:RCTJavaScriptDidLoadNotification
|
||||||
object:nil];
|
object:nil];
|
||||||
|
|
||||||
|
_defaults = [NSUserDefaults standardUserDefaults];
|
||||||
|
_settings = [[NSMutableDictionary alloc] init];
|
||||||
|
|
||||||
|
// Delay setup until after Bridge init
|
||||||
|
__weak RCTDevMenu *weakSelf = self;
|
||||||
|
dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
|
[weakSelf updateSettings];
|
||||||
|
});
|
||||||
|
|
||||||
#if TARGET_IPHONE_SIMULATOR
|
#if TARGET_IPHONE_SIMULATOR
|
||||||
|
|
||||||
__weak RCTDevMenu *weakSelf = self;
|
|
||||||
RCTKeyCommands *commands = [RCTKeyCommands sharedInstance];
|
RCTKeyCommands *commands = [RCTKeyCommands sharedInstance];
|
||||||
|
|
||||||
// toggle debug menu
|
// Toggle debug menu
|
||||||
[commands registerKeyCommandWithInput:@"d"
|
[commands registerKeyCommandWithInput:@"d"
|
||||||
modifierFlags:UIKeyModifierCommand
|
modifierFlags:UIKeyModifierCommand
|
||||||
action:^(UIKeyCommand *command) {
|
action:^(UIKeyCommand *command) {
|
||||||
[weakSelf toggle];
|
[weakSelf toggle];
|
||||||
}];
|
}];
|
||||||
|
|
||||||
// reload in normal mode
|
// Reload in normal mode
|
||||||
[commands registerKeyCommandWithInput:@"n"
|
[commands registerKeyCommandWithInput:@"n"
|
||||||
modifierFlags:UIKeyModifierCommand
|
modifierFlags:UIKeyModifierCommand
|
||||||
action:^(UIKeyCommand *command) {
|
action:^(UIKeyCommand *command) {
|
||||||
|
@ -117,22 +122,23 @@ RCT_EXPORT_MODULE()
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (dispatch_queue_t)methodQueue
|
||||||
|
{
|
||||||
|
return dispatch_get_main_queue();
|
||||||
|
}
|
||||||
|
|
||||||
- (void)updateSettings
|
- (void)updateSettings
|
||||||
{
|
{
|
||||||
__weak RCTDevMenu *weakSelf = self;
|
NSDictionary *settings = [_defaults objectForKey:RCTDevMenuSettingsKey];
|
||||||
dispatch_async(dispatch_get_main_queue(), ^{
|
if ([settings isEqualToDictionary:_settings]) {
|
||||||
RCTDevMenu *strongSelf = weakSelf;
|
return;
|
||||||
if (!strongSelf) {
|
}
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
strongSelf->_settings = [NSMutableDictionary dictionaryWithDictionary:[strongSelf->_defaults objectForKey:RCTDevMenuSettingsKey]];
|
[_settings setDictionary:settings];
|
||||||
|
self.shakeToShow = [_settings[@"shakeToShow"] ?: @YES boolValue];
|
||||||
strongSelf.shakeToShow = [strongSelf->_settings[@"shakeToShow"] ?: @YES boolValue];
|
self.profilingEnabled = [_settings[@"profilingEnabled"] ?: @NO boolValue];
|
||||||
strongSelf.profilingEnabled = [strongSelf->_settings[@"profilingEnabled"] ?: @NO boolValue];
|
self.liveReloadEnabled = [_settings[@"liveReloadEnabled"] ?: @NO boolValue];
|
||||||
strongSelf.liveReloadEnabled = [strongSelf->_settings[@"liveReloadEnabled"] ?: @NO boolValue];
|
self.executorClass = NSClassFromString(_settings[@"executorClass"]);
|
||||||
strongSelf.executorClass = NSClassFromString(strongSelf->_settings[@"executorClass"]);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)jsLoaded
|
- (void)jsLoaded
|
||||||
|
@ -161,6 +167,11 @@ RCT_EXPORT_MODULE()
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (BOOL)isValid
|
||||||
|
{
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
- (void)dealloc
|
- (void)dealloc
|
||||||
{
|
{
|
||||||
[_updateTask cancel];
|
[_updateTask cancel];
|
||||||
|
@ -170,6 +181,10 @@ RCT_EXPORT_MODULE()
|
||||||
|
|
||||||
- (void)updateSetting:(NSString *)name value:(id)value
|
- (void)updateSetting:(NSString *)name value:(id)value
|
||||||
{
|
{
|
||||||
|
id currentValue = _settings[name];
|
||||||
|
if (currentValue == value || [currentValue isEqual:value]) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (value) {
|
if (value) {
|
||||||
_settings[name] = value;
|
_settings[name] = value;
|
||||||
} else {
|
} else {
|
||||||
|
@ -239,6 +254,9 @@ RCT_EXPORT_METHOD(reload)
|
||||||
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
|
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
|
||||||
{
|
{
|
||||||
_actionSheet = nil;
|
_actionSheet = nil;
|
||||||
|
if (buttonIndex == actionSheet.cancelButtonIndex) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
switch (buttonIndex) {
|
switch (buttonIndex) {
|
||||||
case 0: {
|
case 0: {
|
||||||
|
|
|
@ -76,10 +76,27 @@
|
||||||
reloadButton.frame = CGRectMake(buttonWidth, self.bounds.size.height - buttonHeight, buttonWidth, buttonHeight);
|
reloadButton.frame = CGRectMake(buttonWidth, self.bounds.size.height - buttonHeight, buttonWidth, buttonHeight);
|
||||||
[_rootView addSubview:dismissButton];
|
[_rootView addSubview:dismissButton];
|
||||||
[_rootView addSubview:reloadButton];
|
[_rootView addSubview:reloadButton];
|
||||||
|
|
||||||
|
NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
|
||||||
|
|
||||||
|
[notificationCenter addObserver:self
|
||||||
|
selector:@selector(dismiss)
|
||||||
|
name:RCTReloadNotification
|
||||||
|
object:nil];
|
||||||
|
|
||||||
|
[notificationCenter addObserver:self
|
||||||
|
selector:@selector(dismiss)
|
||||||
|
name:RCTJavaScriptDidLoadNotification
|
||||||
|
object:nil];
|
||||||
}
|
}
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)dealloc
|
||||||
|
{
|
||||||
|
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
||||||
|
}
|
||||||
|
|
||||||
- (void)openStackFrameInEditor:(NSDictionary *)stackFrame
|
- (void)openStackFrameInEditor:(NSDictionary *)stackFrame
|
||||||
{
|
{
|
||||||
NSData *stackFrameJSON = [RCTJSONStringify(stackFrame, nil) dataUsingEncoding:NSUTF8StringEncoding];
|
NSData *stackFrameJSON = [RCTJSONStringify(stackFrame, nil) dataUsingEncoding:NSUTF8StringEncoding];
|
||||||
|
@ -125,7 +142,6 @@
|
||||||
- (void)reload
|
- (void)reload
|
||||||
{
|
{
|
||||||
[[NSNotificationCenter defaultCenter] postNotificationName:RCTReloadNotification object:nil userInfo:nil];
|
[[NSNotificationCenter defaultCenter] postNotificationName:RCTReloadNotification object:nil userInfo:nil];
|
||||||
[self dismiss];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma mark - TableView
|
#pragma mark - TableView
|
||||||
|
|
Loading…
Reference in New Issue