Repository navigation
Conversation
In OSS Android builds TraceSection compiles to a no-op unless WITH_PERFETTO or WITH_FBSYSTRACE is defined, which nothing in the build sets. Route it to the NDK ATrace API instead (resolved with dlsym, gated on ATrace_isEnabled) so that the existing C++ sections show up in Perfetto and systrace captures. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary:
TraceSection(ReactCommon/cxxreact/TraceSection.h) is the C++ tracing primitive used throughout the renderer:ShadowTree::commit,UIManager::createNode, the Yoga measure callbacks,FabricMountingManager::executeMountand others. On Android it only does something when built withWITH_PERFETTOorWITH_FBSYSTRACE, and the OSS build sets neither, so it compiles toDummyTraceSection.Current behavior. Perfetto and systrace captures of OSS Android apps show only the Java/Kotlin sections. The C++ half of the renderer (commit, layout, text measurement, building mount instructions) is invisible.
With this change. A new Android branch calls the NDK's
ATrace_beginSectionandATrace_endSection:dlsym, so no target gains a link dependency onlibandroid.ATrace_isEnabled()first, so when nobody is tracing it costs one call.WITH_PERFETTOandWITH_FBSYSTRACEkeep precedence.Why. Without this, profiling React Native on Android with standard tools can't show where commit and layout time goes. In a capture of RNTester mounting a 100-post feed, this branch shows 7084
UIManager::createNodesections and 1632 Yoga measure-callback sections, among others; onmainnone of them appear.Changelog:
[ANDROID] [ADDED] - C++
TraceSectionmarkers now appear in Perfetto and systrace capturesTest Plan:
assembleDebugandassembleRelease(-PreactNativeArchitectures=arm64-v8a) andyarn format-check-cpppass.atrace_apps: "com.facebook.react.uiapp") of the same RNTester scenario onmainand on this branch. The C++ sections appear only on this branch.mainvs. this branch, 6 runs, medians:Update phases were within emulator noise, with mixed signs.
🤖 Generated with Claude Code