Repository navigation
Initialize glog from rninstance on Android - #59861
Open
kraenhansen wants to merge 1 commit into
Open
kraenhansen wants to merge 1 commit into
kraenhansen wants to merge 1 commit into
Conversation
reactnativejni, which initializes glog, is only loaded lazily on the New Architecture, so glog output during startup never reached logcat. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
kraenhansen
marked this pull request as ready for review
November 8, 2026 10:23
5 tasks
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:
Part of #59728. Context in #59729 (comment) (problem 1).
glog's logcat sink is installed in the
JNI_OnLoadofreactnativejni. Since #50437, the New Architecture loads that library lazily: on the first transform prop or network inspector use, and onmainalso on the first touch event. Until then, glog writes only to stderr, so warnings and fatal errors logged during startup never reach logcat. Since Android 7.0,liblogsets the tombstone's abort message from fatal log writes, so those fatal errors also crash with a bareSIGABRT.This calls
gloginit::initialize()fromrninstance'sJNI_OnLoad.ReactInstanceloadsrninstancebefore the runtime, Fabric and TurboModules are created.gloginit::initialize()runs once per process, so the call inreactnativejnistays for the legacy architecture.Changelog:
[ANDROID] [FIXED] - Send glog output during startup to logcat on the New Architecture
Test Plan:
Tested with rn-hermes-fatal-handler-repro, which triggers a Hermes fatal error with the reason
Max heap size was exceeded. I cherry-picked this commit onto 0.88.1, built./gradlew :packages:react-native:ReactAndroid:assembleRelease, swapped the arm64 libraries into the reproducer's stock-template APK, and ran it 3 times per build on an arm64 API 37 emulator. All runs were consistent.SIGSEGVSIGSEGVSIGABRTSIGABRTWith this PR and #59729:
Nothing was logged twice, including with a transform on the root view, where
reactnativejnialso loads. I didn't run this on API levels below 37.🤖 Generated with Claude Code