Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add fabric support for maintainVisibleContentPosition on iOS #36095

Closed

Conversation

janicduplessis
Copy link
Contributor

Summary

Reland of #35319 with a fix for custom pull to refresh components.

Custom pull to refresh component in fabric will need to conform to the RCTCustomPullToRefreshViewProtocol protocol, this way we know that the view is a pull to refresh and not the content view.

Changelog

Test Plan

This will need to be tested internally in the product the crash happened.

@facebook-github-bot facebook-github-bot added CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Contributor A React Native contributor. labels Feb 8, 2023
@analysis-bot
Copy link

analysis-bot commented Feb 8, 2023

Platform Engine Arch Size (bytes) Diff
android hermes arm64-v8a 8,479,401 -20,101
android hermes armeabi-v7a 7,801,773 -12,732
android hermes x86 8,956,970 -20,611
android hermes x86_64 8,813,928 -20,753
android jsc arm64-v8a 9,116,023 -14,455
android jsc armeabi-v7a 8,313,096 -7,079
android jsc x86 9,168,448 -14,990
android jsc x86_64 9,427,211 -15,092

Base commit: caf80d4
Branch: main

@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.

@janicduplessis
Copy link
Contributor Author

@cortinico Any updates on this?

@cortinico
Copy link
Contributor

@cortinico Any updates on this?

I've passed this over to @jacdebug for merging. Let me check where it got stuck

@jacdebug
Copy link
Contributor

@cortinico Any updates on this?

I've passed this over to @jacdebug for merging. Let me check where it got stuck

@janicduplessis I am getting it tested with internal app possibly land early next week.

@jacdebug
Copy link
Contributor

jacdebug commented Mar 1, 2023

@cortinico Any updates on this?

I've passed this over to @jacdebug for merging. Let me check where it got stuck

@janicduplessis I am getting it tested with internal app possibly land early next week.

While testing found that app (wilde) is still crashing in local build. I need help on this so passed to @cipolleschi to debug it.

@janicduplessis
Copy link
Contributor Author

Custom pull to refresh components will need to implement the RCTCustomPullToRefreshViewProtocol protocol, if that is the case already then it might be another issue.

@cipolleschi
Copy link
Contributor

Hi @janicduplessis, as @jacdebug was saying, I take ownership of the PR internally yesterday. I haven't had time to look into it specifically, I hope to be able to do it tomorrow!

Copy link
Contributor

@cipolleschi cipolleschi left a comment

Choose a reason for hiding this comment

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

Hi @janicduplessis, I took a look at the PR to see why it was crashing the internal infra.

I applied the changes highlighted in the review and now it's building and running fine internally.

Have a look at them and let me know if they make sense to you. For context, internally our Spinner View does not conform to the RCTCustomPullToRefreshViewComponent. I understand why you added that protocol and that check, but I'm not completely sure that it's a good approach, as it will require to mark with that protocol every view used for that purpose... which include all the views in the OSS and all the views in the other apps.

I'm curious to hear your thoughts about this.

janicduplessis and others added 2 commits March 2, 2023 16:52
…omponentView.mm

Co-authored-by: Riccardo Cipolleschi <riccardo.cipolleschi@gmail.com>
…omponentView.mm

Co-authored-by: Riccardo Cipolleschi <riccardo.cipolleschi@gmail.com>
@janicduplessis
Copy link
Contributor Author

I’m fine with removing the assert, if that makes landing this easier. It should work properly since pull to refresh view is added before the content view https://github.com/facebook/react-native/blob/main/Libraries/Components/ScrollView/ScrollView.js#L1828, although relying on that seems a little bit more brittle.

I would still recommend implementing the interface for custom pull to refresh for internal components you know of. I think outside facebook custom pull to refresh views might not really be used as it isn’t documented anywhere.

@cipolleschi
Copy link
Contributor

I think outside facebook custom pull to refresh views might not really be used as it isn’t documented anywhere.

Exactly because of that, wouldn't be better if we find a way that work for both Meta and the outside world?

I'm not super knowledgeable of how this component works, so I may be missing some details, but if Meta is not using the protocol and the rest of the world is not using the protocol as well, why do we actually need to introduce it?

@janicduplessis
Copy link
Contributor Author

I think the main reason is that fabric scrollview previously didn’t need any knowledge of it’s content view so the protocol wasn’t needed. I would assume that if facebook still has custom pull to refresh component for the old architecture it would implement the RCTCustomRefreshContolProtocol protocol, which is the equivalent of the protocol I added but for old arch.

@cipolleschi
Copy link
Contributor

Thanks for the pointer.. At this point, I have two questions:

  1. Why can't we reuse RCTCustomRefreshContolProtocol? I see that this protocol requires some methods, while the RCTCustomPullToRefreshViewComponent doesn't, so we could have RCTCustomRefreshContolProtocol (the old one) that conforms to RCTCustomPullToRefreshViewComponent and everything should work, WDYT?
  2. If we keep the two separated, shouldn't we check for both protocols in RCTScrollViewComponentView?

@janicduplessis
Copy link
Contributor Author

I did consider reusing it, but I didn’t see why it should have any methods as we don’t use them. For example the current fabric pull to refresh component view doesn’t conform to the old RCTCustomRefreshContolProtocol. I think fabric has the concept of ComponentViews, which wraps the actual view so that was another reason for using a different protocol, as the component view might not be the actual refresh control view.

I don’t think we need to check both as it is probably not possible to end up with a old arch view there. Even with the interop view if I remember correctly it is wrapped in a componentview still. Anyway if that case is possible without the assert it would work still.

@facebook-github-bot facebook-github-bot added the Merged This PR has been merged. label Mar 7, 2023
@facebook-github-bot
Copy link
Contributor

@cipolleschi merged this pull request in 59c4db8.

@janicduplessis janicduplessis deleted the @janic/mvcp-ios-fabric-v2 branch March 7, 2023 14:01
OlimpiaZurek pushed a commit to OlimpiaZurek/react-native that referenced this pull request May 22, 2023
…k#36095)

Summary:
Reland of facebook#35319 with a fix for custom pull to refresh components.

Custom pull to refresh component in fabric will need to conform to the `RCTCustomPullToRefreshViewProtocol` protocol, this way we know that the view is a pull to refresh and not the content view.

## Changelog

<!-- Help reviewers and the release process by writing your own changelog entry.

Pick one each for the category and type tags:

[IOS] [ADDED] - Add fabric support for maintainVisibleContentPosition on iOS

For more details, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
-->

Pull Request resolved: facebook#36095

Test Plan:
This will need to be tested internally in the product the crash happened.

Take a local build of Wilde open Marketplace.

Reviewed By: jacdebug

Differential Revision: D43128163

Pulled By: cipolleschi

fbshipit-source-id: 6cf8ddff92aeb446072a3d847434e21b9e38af61
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. Contributor A React Native contributor. Merged This PR has been merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants