Repository navigation
Conversation
Snapshot change only; fails until GeneratePropsH emits the initializer.
convertRawProp default-constructs the prop type (T result;) and the generated fromRawValue ORs each listed value into wrapped.value, so the mask started from an indeterminate value and could keep stray bits, e.g. Modal supportedOrientations allowing orientations it does not list.
|
Hi @hsusul! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks! |
|
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
|
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
Summary:
Fixes #59561. The root cause and fix follow the diagnosis in that issue.
Array-of-enum (mask) props such as
Modal'ssupportedOrientationscan end up with bits the JS value never listed. On iOS that lets a landscape-only modal rotate to portrait.The generated
<Name>MaskWrappedstruct (fromGeneratePropsH.js) declares its only member without an initializer.convertRawPropinpropsConversions.hdefault-constructs the prop type (T result;), soresult.valuestarts indeterminate. The generatedfromRawValuethen ORs each listed value into it (wrapped.value |= ...), which keeps whatever bits were already in that memory. Thestd::optional<T>andstd::vector<T>overloads offromRawValuedefault-constructTthe same way.This change gives the generated member a value initializer (
value{}), so every default-constructed wrapper starts at an empty mask. The existing designated ({ .value = ... }) and braced ({static_cast<...>(...)}) initializers in the generatedProps.cppare unaffected. Fixing it in the generated type covers every site that default-constructs it, without changingconvertRawPropfor all other prop types.Changelog:
[GENERAL] [FIXED] - Codegen array-of-enum props (e.g.
ModalsupportedOrientations) no longer start parsing from an uninitialized maskTest Plan:
Updated the
GeneratePropsHsnapshots (unit and both e2e suites) to expectvalue{};. They fail before the generator change and pass after it:Runtime check of the generated code. I compiled the mask block that
GeneratePropsHemits for theARRAY_PROPSfixture (sizes: ['small', 'large']), with stubRawValueandPropsParserContexttypes and a copy ofconvertRawProp'sT result; fromRawValue(...)pattern. I usedclang++ -std=c++20 -O0 -ftrivial-auto-var-init=patternso the indeterminate start value shows up the same way on every run:Also ran:
yarn jest packages/react-native-codegen: 64 suites, 3130 tests, 1279 snapshots passedyarn flow-check: 0 errorsyarn eslint --max-warnings 0andprettier --checkonGeneratePropsH.js: cleanNot run: an iOS or Android app build. I did not reproduce the Modal orientation behavior on a device or simulator. I did not regenerate the
scripts/cxx-apisnapshots. Those snapshots drop member initializers (for examplebool visible{false}is recorded asbool visible), so I don't expect them to change.