From 6cd6ced7ca2de1aa9d8686d59545457535236798 Mon Sep 17 00:00:00 2001 From: Nick Gerleman Date: Wed, 22 Jan 2020 19:17:14 -0800 Subject: [PATCH 1/2] Logging and Tracing OSS_RN Removal 1. Update NativeToJSBridge.h with a fix that was incorporated into Facebook master instead of our current fix. 2. Remove "ENABLE_NATIVE_SYSTRACE_TO_ETW". We don't check it in RNW or micosoft/react-native. 3. Remove conditional definition of ENABLE_ETW_TRACING for non-OSS React Native. We can build it just fine, since the patch we had was to fix an error exposed when "WITH_FBSYSTRACE" is defined. 4. Enable ENABLE_JS_SYSTRACE_TO_ETW in patched OSS RN 5. Consolidate preprocessor definitions tp React.cpp.props. WITH_FBSYSTRACE is checked in Facebook headers, meaning projects including Facebook headers that didn't copy the definitions may get mismatched headers. We should expose the definition to more projects to prevent this. 6. Remove conditional compilation of logMarker, since it builds in unpatched OSS RN and there are not any apparent divergences that would impact runtime behavior. Validated we build: - Universal Solution with OSS_RN, with and without patches - Desktop Solution with OSS_RN with patches, and not more broken without --- .../ReactCommon/cxxreact/NativeToJsBridge.h | 2 +- vnext/Desktop/React.Windows.Desktop.vcxproj | 3 --- .../JSI.Desktop.UnitTests.vcxproj | 3 --- .../Microsoft.ReactNative.vcxproj | 3 --- vnext/PropertySheets/React.Cpp.props | 14 +++++++--- vnext/ReactCommon/ReactCommon.vcxproj | 2 -- vnext/ReactUWP/ReactUWP.vcxproj | 3 --- .../ReactWindowsCore/ReactWindowsCore.vcxproj | 3 --- vnext/Shared/OInstance.cpp | 27 +++++++------------ .../UniversalTestRunner.cpp | 4 --- 10 files changed, 22 insertions(+), 42 deletions(-) diff --git a/vnext/DeforkingPatches/ReactCommon/cxxreact/NativeToJsBridge.h b/vnext/DeforkingPatches/ReactCommon/cxxreact/NativeToJsBridge.h index 4a883af143f..84a3135adc5 100644 --- a/vnext/DeforkingPatches/ReactCommon/cxxreact/NativeToJsBridge.h +++ b/vnext/DeforkingPatches/ReactCommon/cxxreact/NativeToJsBridge.h @@ -122,7 +122,7 @@ class NativeToJsBridge { bool m_applicationScriptHasFailure = false; #ifdef WITH_FBSYSTRACE - std::atomic_uint_least32_t m_systraceCookie{}; + std::atomic_uint_least32_t m_systraceCookie = ATOMIC_VAR_INIT(0); #endif }; diff --git a/vnext/Desktop/React.Windows.Desktop.vcxproj b/vnext/Desktop/React.Windows.Desktop.vcxproj index 0c1b31f54e3..d69e304b8f4 100644 --- a/vnext/Desktop/React.Windows.Desktop.vcxproj +++ b/vnext/Desktop/React.Windows.Desktop.vcxproj @@ -56,9 +56,6 @@ BOOST_ASIO_HAS_IOCP - Force unique layout/size for boost::asio::basic_stream_socket<> subtypes. --> BOOST_ASIO_HAS_IOCP;_WINSOCK_DEPRECATED_NO_WARNINGS;_WIN32_WINNT=_WIN32_WINNT_WIN7;WIN32;_WINDOWS;REACTNATIVEWIN32_EXPORTS;FOLLY_NO_CONFIG;NOMINMAX;GLOG_NO_ABBREVIATED_SEVERITIES;_HAS_AUTO_PTR_ETC;CHAKRACORE;RN_PLATFORM=win32;RN_EXPORT=;JSI_EXPORT=;%(PreprocessorDefinitions) - ENABLE_ETW_TRACING;%(PreprocessorDefinitions) - ENABLE_NATIVE_SYSTRACE_TO_ETW;WITH_FBSYSTRACE;%(PreprocessorDefinitions) - ENABLE_JS_SYSTRACE_TO_ETW;WITH_FBSYSTRACE;%(PreprocessorDefinitions) %(AdditionalOptions) /Zc:strictStrings /bigobj Use pch.h diff --git a/vnext/JSI.Desktop.UnitTests/JSI.Desktop.UnitTests.vcxproj b/vnext/JSI.Desktop.UnitTests/JSI.Desktop.UnitTests.vcxproj index 4aac851a337..e1128d1b4ff 100644 --- a/vnext/JSI.Desktop.UnitTests/JSI.Desktop.UnitTests.vcxproj +++ b/vnext/JSI.Desktop.UnitTests/JSI.Desktop.UnitTests.vcxproj @@ -49,9 +49,6 @@ string literals. It prevents code like wchar_t* str = L"hello"; from compiling. --> - ENABLE_ETW_TRACING;%(PreprocessorDefinitions) - ENABLE_NATIVE_SYSTRACE_TO_ETW;WITH_FBSYSTRACE;%(PreprocessorDefinitions) - ENABLE_JS_SYSTRACE_TO_ETW;WITH_FBSYSTRACE;%(PreprocessorDefinitions) %(AdditionalOptions) /Zc:strictStrings diff --git a/vnext/Microsoft.ReactNative/Microsoft.ReactNative.vcxproj b/vnext/Microsoft.ReactNative/Microsoft.ReactNative.vcxproj index 4a8b843d605..0c298040d44 100644 --- a/vnext/Microsoft.ReactNative/Microsoft.ReactNative.vcxproj +++ b/vnext/Microsoft.ReactNative/Microsoft.ReactNative.vcxproj @@ -104,9 +104,6 @@ USE_EDGEMODE_JSRT;%(PreprocessorDefinitions) USE_HERMES;%(PreprocessorDefinitions) USE_V8;%(PreprocessorDefinitions) - ENABLE_ETW_TRACING;%(PreprocessorDefinitions) - ENABLE_NATIVE_SYSTRACE_TO_ETW;WITH_FBSYSTRACE;%(PreprocessorDefinitions) - ENABLE_JS_SYSTRACE_TO_ETW;WITH_FBSYSTRACE;%(PreprocessorDefinitions) REACTWINDOWS_BUILD; RN_PLATFORM=windows; diff --git a/vnext/PropertySheets/React.Cpp.props b/vnext/PropertySheets/React.Cpp.props index d31de978ac8..7b8dc00e5de 100644 --- a/vnext/PropertySheets/React.Cpp.props +++ b/vnext/PropertySheets/React.Cpp.props @@ -29,14 +29,22 @@ true - - - true true + + + + ENABLE_ETW_TRACING;%(PreprocessorDefinitions) + ENABLE_JS_SYSTRACE_TO_ETW;WITH_FBSYSTRACE;%(PreprocessorDefinitions) + + + $(ReactNativeDir)\ReactCommon\jsi $(HERMES_Package)\installed\x64-windows\include\jsi_ref diff --git a/vnext/ReactCommon/ReactCommon.vcxproj b/vnext/ReactCommon/ReactCommon.vcxproj index 3bbc89e5bb1..aea06b1a260 100644 --- a/vnext/ReactCommon/ReactCommon.vcxproj +++ b/vnext/ReactCommon/ReactCommon.vcxproj @@ -69,8 +69,6 @@ false true $(ReactNativeDir)\ReactCommon;$(JSI_Source);$(ReactNativeDir)\ReactCommon\jscallinvoker;$(ReactNativeDir)\ReactCommon\jsiexecutor;$(FollyDir);$(ReactNativeWindowsDir)stubs;$(ReactNativeWindowsDir)\ReactWindowsCore\tracing;%(AdditionalIncludeDirectories) - ENABLE_NATIVE_SYSTRACE_TO_ETW;WITH_FBSYSTRACE;%(PreprocessorDefinitions) - ENABLE_JS_SYSTRACE_TO_ETW;WITH_FBSYSTRACE;%(PreprocessorDefinitions) _WIN32;_CRT_SECURE_NO_WARNINGS;FOLLY_NO_CONFIG;NOMINMAX;RN_EXPORT=;JSI_EXPORT=;WIN32;_WINDLL;%(PreprocessorDefinitions) 4715;4146;4251;4800;4804;4305;4722;%(DisableSpecificWarnings) diff --git a/vnext/ReactUWP/ReactUWP.vcxproj b/vnext/ReactUWP/ReactUWP.vcxproj index e11204667eb..3e7ba523136 100644 --- a/vnext/ReactUWP/ReactUWP.vcxproj +++ b/vnext/ReactUWP/ReactUWP.vcxproj @@ -85,9 +85,6 @@ USE_EDGEMODE_JSRT;%(PreprocessorDefinitions) USE_HERMES;%(PreprocessorDefinitions) USE_V8;%(PreprocessorDefinitions) - ENABLE_ETW_TRACING;%(PreprocessorDefinitions) - ENABLE_NATIVE_SYSTRACE_TO_ETW;WITH_FBSYSTRACE;%(PreprocessorDefinitions) - ENABLE_JS_SYSTRACE_TO_ETW;WITH_FBSYSTRACE;%(PreprocessorDefinitions) REACTWINDOWS_BUILD; RN_PLATFORM=windows; diff --git a/vnext/ReactWindowsCore/ReactWindowsCore.vcxproj b/vnext/ReactWindowsCore/ReactWindowsCore.vcxproj index 0c146bd5412..f5e76bd1886 100644 --- a/vnext/ReactWindowsCore/ReactWindowsCore.vcxproj +++ b/vnext/ReactWindowsCore/ReactWindowsCore.vcxproj @@ -78,9 +78,6 @@ REACTWINDOWS_BUILD;NOMINMAX;FOLLY_NO_CONFIG;WIN32=0;RN_EXPORT=;CHAKRACORE;%(PreprocessorDefinitions) USE_HERMES;%(PreprocessorDefinitions) USE_V8;%(PreprocessorDefinitions) - ENABLE_ETW_TRACING;%(PreprocessorDefinitions) - ENABLE_NATIVE_SYSTRACE_TO_ETW;WITH_FBSYSTRACE;%(PreprocessorDefinitions) - ENABLE_JS_SYSTRACE_TO_ETW;WITH_FBSYSTRACE;%(PreprocessorDefinitions) $(ReactNativeWindowsDir);$(ReactNativeWindowsDir)Common;$(ReactNativeWindowsDir)Shared;$(ReactNativeWindowsDir)include;$(ReactNativeWindowsDir)include\ReactWindowsCore;$(ReactNativeDir)\ReactCommon;$(JSI_Source);$(ReactNativeWindowsDir)stubs;$(FollyDir);$(ReactNativeWindowsDir)\ReactWindowsCore\tracing;$(ProjectDir);$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories) $(HERMES_Package)\installed\$(VcpkgTriplet)\include\;%(AdditionalIncludeDirectories) $(V8_Package)\installed\$(VcpkgTriplet)\include\;%(AdditionalIncludeDirectories) diff --git a/vnext/Shared/OInstance.cpp b/vnext/Shared/OInstance.cpp index bfdfa8f7d1d..a4f9ee4e60f 100644 --- a/vnext/Shared/OInstance.cpp +++ b/vnext/Shared/OInstance.cpp @@ -3,17 +3,20 @@ #include "pch.h" -#include #include #include #include #include #include #include +#include +#include +#include "OInstance.h" #include "Unicode.h" -#include "../Chakra/ChakraExecutor.h" -#include "../Chakra/ChakraUtils.h" +#include "Chakra/ChakraExecutor.h" +#include "Chakra/ChakraUtils.h" +#include "JSI/Shared/RuntimeHolder.h" #if (defined(_MSC_VER) && !defined(WINRT)) #include "Sandbox/SandboxJSExecutor.h" @@ -41,12 +44,7 @@ #include #include -#include - #ifdef PATCH_RN -#include -#include -#include #if defined(USE_HERMES) #include "HermesRuntimeHolder.h" #endif @@ -55,18 +53,13 @@ #include "V8JSIRuntimeHolder.h" #endif #include "ChakraRuntimeHolder.h" +#endif -// foreward declaration. -namespace facebook { -namespace react { -namespace tracing { +// forward declaration. +namespace facebook::react::tracing { void initializeETW(); void initializeJSHooks(facebook::jsi::Runtime &runtime); -} // namespace tracing -} // namespace react -} // namespace facebook - -#endif +} // namespace facebook::react::tracing namespace { diff --git a/vnext/Universal.IntegrationTests/UniversalTestRunner.cpp b/vnext/Universal.IntegrationTests/UniversalTestRunner.cpp index 7d6a408a7f2..edd5501e341 100644 --- a/vnext/Universal.IntegrationTests/UniversalTestRunner.cpp +++ b/vnext/Universal.IntegrationTests/UniversalTestRunner.cpp @@ -41,14 +41,12 @@ static double nativePerformanceNow() { return std::chrono::duration(std::chrono::steady_clock::now().time_since_epoch()).count(); } -#if !defined(OSS_RN) void logMarker(const ReactMarker::ReactMarkerId id, const char *tag) { std::cout << "Marker: " << id; if (tag) std::cout << " Tag: " << tag; std::cout << std::endl; } -#endif } // end anonymous namespace @@ -56,9 +54,7 @@ namespace Microsoft::React { void InitializeLogging(NativeLoggingHook &&hook) { g_nativeLogHook = std::move(hook); -#if !defined(OSS_RN) ReactMarker::logTaggedMarker = logMarker; -#endif } namespace Test { From 680b7a1f5986909b04d93e538f21ac22d95c268f Mon Sep 17 00:00:00 2001 From: Nick Gerleman Date: Wed, 22 Jan 2020 19:17:54 -0800 Subject: [PATCH 2/2] Change files --- .../react-native-windows-2020-01-22-19-17-54-master.json | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 change/react-native-windows-2020-01-22-19-17-54-master.json diff --git a/change/react-native-windows-2020-01-22-19-17-54-master.json b/change/react-native-windows-2020-01-22-19-17-54-master.json new file mode 100644 index 00000000000..085f2ada005 --- /dev/null +++ b/change/react-native-windows-2020-01-22-19-17-54-master.json @@ -0,0 +1,9 @@ +{ + "type": "prerelease", + "comment": "Logging and Tracing OSS_RN Removal", + "packageName": "react-native-windows", + "email": "nick@nickgerleman.com", + "commit": "6cd6ced7ca2de1aa9d8686d59545457535236798", + "dependentChangeType": "patch", + "date": "2020-01-23T03:17:54.079Z" +} \ No newline at end of file