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>
tomekzaw
marked this pull request as ready for review
October 15, 2026 14:46
|
@Abbondanzo has imported this pull request. If you are a Meta employee, you can view this in D125730780. |
Abbondanzo
reviewed
Oct 16, 2026
Abbondanzo
left a comment
Contributor
There was a problem hiding this comment.
<android/trace.h> should have these
Include the NDK header and call ATrace_isEnabled/beginSection/endSection directly instead of resolving them with dlsym. libreactnative already links libandroid, and hermestooling links it through libreactnative. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
Author
|
Thanks! Applied all three suggestions in 5c5202e. A note on linking: |
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:<android/trace.h>and calls the NDK functions directly. They exist from API 23, and React Native'sminSdkis 24.libreactnativealready linkslibandroid, andlibhermestoolinggets it throughlibreactnative, so no build changes are needed.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.libreactnative.soimports the threeATrace_*functions fromlibandroid.so, and a Perfetto capture of an RNTester release launch on a physical device shows the C++ sections (UIManager::createNode,ShadowTree::commit,FabricMountingManager::executeMount, ...).dlsym; direct calls do the same work minus the null checks). Emulator (Pixel 10 Pro AVD, API 37), release builds, currentmainvs. this branch, 6 runs, medians:Update phases were within emulator noise, with mixed signs.
🤖 Generated with Claude Code