Repository navigation
Re-copy the prefab headers when a header changes - #59127
Closed
YevheniiKotyrlo wants to merge 2 commits into
Closed
YevheniiKotyrlo wants to merge 2 commits into
YevheniiKotyrlo wants to merge 2 commits into
Conversation
PreparePrefabHeadersTask declared only the directory paths it copies from, so Gradle found it up to date after a header under them changed and the prefab package every app and library compiles against kept the old header. The headers it copies are now its input files, read through the same file trees the copy uses, and each library's folder is rebuilt from scratch so a removed header leaves no copy behind.
YevheniiKotyrlo
marked this pull request as ready for review
October 16, 2026 07:41
|
@cortinico has imported this pull request. If you are a Meta employee, you can view this in D125650684. |
|
@cortinico merged this pull request in bf4fac3. |
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:
PreparePrefabHeadersTaskcopies ReactAndroid's public headers intobuild/prefab-headers, the prefab package an app'sappmodulesand every library's C++ compile against, whilelibreactnative.socompiles againstReactCommondirectly. The task's only input is the list of directory paths:so after a header under those directories changes, Gradle finds the task up to date and the prefab package keeps the old header. Everything built against the prefab package then disagrees with
libreactnative.soabout that header: a struct that gained a field is allocated at its old size by a library and used at its new size by React Native.A header changes in place whenever React Native is built from source and patched with
patch-package, or whileReactCommonis edited during development. In an app built from source, a patch that added two fields to Yoga'sCachedMeasurementleftprefab-headers/reactnative/yoga/node/CachedMeasurement.h,LayoutResults.h,Node.handstyle/Style.hat their old content across two builds, and the app crashed at launch withSIGSEGVunderYogaLayoutableShadowNode::replaceChild←cloneChildInPlace←configureYogaTree.The task now declares the headers it copies as
@InputFiles, read through the same filtered file trees the copy uses, so the declared inputs and the copied headers cannot disagree. Each library's folder is deleted before it is copied into, so a header removed fromReactCommonleaves no copy behind once the task runs again.Changelog:
[ANDROID] [FIXED] - Re-copy the prefab headers when a header under ReactCommon changes
Test Plan:
PreparePrefabHeadersTaskTestgainspreparePrefabHeadersTask_declaresTheHeadersItCopiesAsInputs(the task's input files are exactly the copied header, not the.cppbeside it) andpreparePrefabHeadersTask_withARemovedHeader_removesItsCopy. Onmainboth fail: the input files are[], andremoved.his still in the output after the second run. With the change, all 10 cases pass../gradlew build -PenableWarningsAsErrors=trueinpackages/gradle-plugin, inreactnativecommunity/react-native-android:latest: 238 tests, 0 failures.ktfmt0.59.0 (--dry-run --set-exit-if-changed) is clean on both files.@react-native/gradle-plugin: the next build ranpreparePrefabinstead of finding it up to date, every Yoga header inprefab-headersand in the debug prefab package matchedReactCommon, every library recompiled against them, and the app launched without the crash.