Skip to content

Commit 0673ac2

Browse files
bnhamfacebook-github-bot
authored andcommittedDec 18, 2017
improve detection of inspectable JS contexts
Reviewed By: Hypuk Differential Revision: D6578735 fbshipit-source-id: ac6a3a8bae9aef7fd3b4a036c3f154b3f6b7d80c
1 parent 15cd98b commit 0673ac2

File tree

3 files changed

+11
-16
lines changed

3 files changed

+11
-16
lines changed
 

‎React/DevSupport/RCTInspectorDevServerHelper.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@
1010

1111
@interface RCTInspectorDevServerHelper : NSObject
1212

13-
+ (void)connectForContext:(JSGlobalContextRef)context
14-
withBundleURL:(NSURL *)bundleURL;
13+
+ (void)connectWithBundleURL:(NSURL *)bundleURL;
1514
+ (void)disableDebugger;
1615
+ (void)attachDebugger:(NSString *)owner
1716
withBundleURL:(NSURL *)bundleURL

‎React/DevSupport/RCTInspectorDevServerHelper.mm

+1-6
Original file line numberDiff line numberDiff line change
@@ -104,13 +104,8 @@ + (void)disableDebugger
104104
sendEventToAllConnections(kDebuggerMsgDisable);
105105
}
106106

107-
+ (void)connectForContext:(JSGlobalContextRef)context
108-
withBundleURL:(NSURL *)bundleURL
107+
+ (void)connectWithBundleURL:(NSURL *)bundleURL
109108
{
110-
if (!isCustomJSCPtr(context)) {
111-
return;
112-
}
113-
114109
NSURL *inspectorURL = getInspectorDeviceUrl(bundleURL);
115110

116111
// Note, using a static dictionary isn't really the greatest design, but

‎React/Modules/RCTDevSettings.mm

+9-8
Original file line numberDiff line numberDiff line change
@@ -195,12 +195,13 @@ - (void)setBridge:(RCTBridge *)bridge
195195
// finished with its initialisation. But it does finish by the time it
196196
// relinquishes control of the main thread, so only queue on the JS thread
197197
// after the current main thread operation is done.
198-
dispatch_async(dispatch_get_main_queue(), ^{
199-
[bridge dispatchBlock:^{
200-
[RCTInspectorDevServerHelper connectForContext:bridge.jsContextRef
201-
withBundleURL:bridge.bundleURL];
202-
} queue:RCTJSThread];
203-
});
198+
if (self.isNuclideDebuggingAvailable) {
199+
dispatch_async(dispatch_get_main_queue(), ^{
200+
[bridge dispatchBlock:^{
201+
[RCTInspectorDevServerHelper connectWithBundleURL:bridge.bundleURL];
202+
} queue:RCTJSThread];
203+
});
204+
}
204205
#endif
205206
}
206207

@@ -256,10 +257,10 @@ - (id)settingForKey:(NSString *)key
256257
- (BOOL)isNuclideDebuggingAvailable
257258
{
258259
#if RCT_ENABLE_INSPECTOR
259-
return facebook::react::isCustomJSCPtr(_bridge.jsContextRef);
260+
return _bridge.isInspectable;
260261
#else
261262
return false;
262-
#endif //RCT_ENABLE_INSPECTOR
263+
#endif // RCT_ENABLE_INSPECTOR
263264
}
264265

265266
- (BOOL)isRemoteDebuggingAvailable

0 commit comments

Comments
 (0)
Please sign in to comment.