From 5cf8f43ab182781ea82e88077df425c3efbfc21f Mon Sep 17 00:00:00 2001 From: Saad Najmi Date: Thu, 15 Jun 2023 02:32:51 -0700 Subject: [PATCH] Re-enable direct debugging with JSC on iOS 16.4+ (#37874) Summary: See: https://webkit.org/blog/13936/enabling-the-inspection-of-web-content-in-apps As of iOS 16.4 and above, JSContexts are no longer inspectable by default. Without this, we cannot attach Safari Web Inspector to the JSContext, AKA, we can no longer direct debug. This is a simple change to re-enable that. I decided to extend the `availability` check to macOS and tvOS as I'm certain both out of tree platform forks will want this fix as well. ## Changelog: [IOS] [FIXED] - Re-enable direct debugging with JSC on iOS 16.4+ Pull Request resolved: https://github.com/facebook/react-native/pull/37874 Test Plan: I launched RNTester in an iOS 15, and iOS 16.4 simulator. I then verified that we can attach Safari Web inspector to both simulators' JSContexts. Reviewed By: cortinico Differential Revision: D46719890 Pulled By: huntie fbshipit-source-id: 7fa5ae244577b7dbf3c9c16e65ad530cfc3e9cbd --- packages/react-native/ReactCommon/jsc/JSCRuntime.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/react-native/ReactCommon/jsc/JSCRuntime.cpp b/packages/react-native/ReactCommon/jsc/JSCRuntime.cpp index fea1d0bc2d33c7..93f20b828f0a93 100644 --- a/packages/react-native/ReactCommon/jsc/JSCRuntime.cpp +++ b/packages/react-native/ReactCommon/jsc/JSCRuntime.cpp @@ -398,6 +398,11 @@ JSCRuntime::JSCRuntime(JSGlobalContextRef ctx) stringCounter_(0) #endif { +#ifndef NDEBUG + if (__builtin_available(macOS 13.3, iOS 16.4, tvOS 16.4, *)) { + JSGlobalContextSetInspectable(ctx_, true); + } +#endif } JSCRuntime::~JSCRuntime() {