Skip to content

Conversation

mateoguzmana
Copy link
Collaborator

Summary:

Migrate com.facebook.react.uimanager.ReactClippingViewGroup to Kotlin

Changelog:

[INTERNAL] - Migrate com.facebook.react.uimanager.ReactClippingViewGroup to Kotlin

Test Plan:

yarn test-android
yarn android

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Feb 13, 2025
@mateoguzmana mateoguzmana marked this pull request as ready for review February 13, 2025 22:52
@facebook-github-bot facebook-github-bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label Feb 14, 2025
Comment on lines 50 to 52
@get:Deprecated("Use removeClippedSubviews property instead", ReplaceWith("removeClippedSubviews"))
@Suppress("INAPPLICABLE_JVM_NAME")
@get:JvmName("getRemoveClippedSubviews")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels wrong. Why do we need all of this? Specifically the ReplaceWith won't work as you're replacing with the same string

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I see it now. I was overlooking it, added these annotations for backwards compatibility based on other examples in the codebase when trying to fix some issues post-migration for ReactHorizontalScrollContainerLegacyView in old arch but just double checked and indeed are not needed. Thanks for pointing this out

Comment on lines +22 to +23
override var removeClippedSubviews: Boolean = false
set(value) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is probably an indicator of a breaking change. We should check how often ReactClippingViewGroup is implemented in OSS. If the number is relevant this will have to be marked as [BREAKING] rather than internal.

If there are no relevant usages on the other hand, we can make this class [INTERNAL]

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see some usages in OSS (ref), so it would be a breaking change indeed.

Now, my memory started getting back to why I added the backwards compatibility annotations: seems like we can prevent this from being a breaking change by adding the following (tested by reverting the changes in ReactHorizontalScrollContainerLegacyView):

@Suppress("INAPPLICABLE_JVM_NAME")
@set:JvmName("setRemoveClippedSubviews")
public var removeClippedSubviews: Boolean

But in the other hand, I don't see any other cases where we have done this in the codebase. Do we prefer to have it as a breaking change?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So we need to look only at Kotlin usages here

and here

I believe the latter as just forks, so we can consider this actually [INTERNAL]

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ohh, understood. Seems good then, thank you for double checking!

@facebook-github-bot
Copy link
Contributor

@cortinico has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@facebook-github-bot facebook-github-bot added the Merged This PR has been merged. label Feb 18, 2025
@facebook-github-bot
Copy link
Contributor

@cortinico merged this pull request in 7f1edbd.

@react-native-bot
Copy link
Collaborator

This pull request was successfully merged by @mateoguzmana in 7f1edbd

When will my fix make it into a release? | How to file a pick request?

@alanleedev
Copy link
Contributor

alanleedev commented Feb 20, 2025

@mateoguzmana @cortinico This change is being reverted since crash was found due to this change.
I haven't try to fix it since it was blocking a release.
But this conversion leaves sandwiched Java file which seem dangerous as it has caused issues before; Kotlin (interface) -> Java (child) -> Kotlin (grandchild)

We should generally avoid these kind of conversions and convert the top level interface/class last.
[update] issue was found and fixed in PR #49607

alanleedev added a commit to alanleedev/react-native that referenced this pull request Feb 21, 2025
Summary:
Reverting facebook#49413 as it was causing a crash with assertion failure in ReactViewGroup.addViewWithSubviewClippingEnabled()

Changelog:
[INTERNAL] revert Kotlin conversion due to crash

Reviewed By: sbuggay

Differential Revision: D69953848
facebook-github-bot pushed a commit that referenced this pull request Feb 21, 2025
Summary:
Pull Request resolved: #49586

Reverting #49413 as it was causing a crash with assertion failure in ReactViewGroup.addViewWithSubviewClippingEnabled()

Changelog:
[INTERNAL] revert Kotlin conversion due to crash

Reviewed By: sbuggay

Differential Revision: D69953848

fbshipit-source-id: b438fb928a4849f3dbad6a9d59d0f48449035fd6
}
}

super.setRemoveClippedSubviews(removeClippedSubviews)
Copy link
Contributor

@alanleedev alanleedev Feb 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So I think this is why this Kotlin migration introduced a problem.
Previously, setRemoveClippedSubviews() was a function but was converted to Kotlin property var removeClippedSubViews in the top-level interface.
Java implementing this interface can use setter and getter functions, so can still use the same code.
But if a child of Java class is implemented in Kotlin and tries to use the Kotlin property in the interface that information seems to be lost due to parent being a Java class.

We should avoid going through multiple levels of type changes like Kotlin -> Java -> Kotlin as the original type could be lost and create in unexpected results.

[update] see comments in PR #49607

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should avoid going through multiple levels of type changes like Kotlin -> Java -> Kotlin as the original type could be lost and create in unexpected results.

Yeah this is bad :|

facebook-github-bot pushed a commit that referenced this pull request Feb 26, 2025
Summary:
Reland of #49413 which was reverted due to an internal crash. I've attempted to do a solution to keep backwards compatibility but doesn't seem to work – keeping the original solution for now, perhaps something else can be cleaned up to avoid the breakage.

## Changelog:

[INTERNAL] - Migrate com.facebook.react.uimanager.ReactClippingViewGroup to Kotlin

Pull Request resolved: #49607

Test Plan:
```bash
yarn test-android
yarn android
```

Verified that the update changes do not cause a crash.
Test flow:
- login to BizApp using Instagram account
- on home screen scroll down to Insights section
- it should show without crashing

Reviewed By: arushikesarwani94

Differential Revision: D70200000

Pulled By: alanleedev

fbshipit-source-id: 89bc948c1b91d9419d4b6e1885d949c4a3c20986
gabrieldonadel pushed a commit to gabrieldonadel/react-native that referenced this pull request Aug 12, 2025
Summary:
Migrate com.facebook.react.uimanager.ReactClippingViewGroup to Kotlin

## Changelog:

[INTERNAL] - Migrate com.facebook.react.uimanager.ReactClippingViewGroup to Kotlin

Pull Request resolved: facebook#49413

Test Plan:
```bash
yarn test-android
yarn android
```

Reviewed By: rshest

Differential Revision: D69750532

Pulled By: cortinico

fbshipit-source-id: 50ec87a71b3bd523e1a9518b8bd683a027a4b422
gabrieldonadel pushed a commit to gabrieldonadel/react-native that referenced this pull request Aug 12, 2025
Summary:
Pull Request resolved: facebook#49586

Reverting facebook#49413 as it was causing a crash with assertion failure in ReactViewGroup.addViewWithSubviewClippingEnabled()

Changelog:
[INTERNAL] revert Kotlin conversion due to crash

Reviewed By: sbuggay

Differential Revision: D69953848

fbshipit-source-id: b438fb928a4849f3dbad6a9d59d0f48449035fd6
gabrieldonadel pushed a commit to gabrieldonadel/react-native that referenced this pull request Aug 12, 2025
…acebook#49607)

Summary:
Reland of facebook#49413 which was reverted due to an internal crash. I've attempted to do a solution to keep backwards compatibility but doesn't seem to work – keeping the original solution for now, perhaps something else can be cleaned up to avoid the breakage.

## Changelog:

[INTERNAL] - Migrate com.facebook.react.uimanager.ReactClippingViewGroup to Kotlin

Pull Request resolved: facebook#49607

Test Plan:
```bash
yarn test-android
yarn android
```

Verified that the update changes do not cause a crash.
Test flow:
- login to BizApp using Instagram account
- on home screen scroll down to Insights section
- it should show without crashing

Reviewed By: arushikesarwani94

Differential Revision: D70200000

Pulled By: alanleedev

fbshipit-source-id: 89bc948c1b91d9419d4b6e1885d949c4a3c20986
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Merged This PR has been merged. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants