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

fix(iOS): header snapshots not working #2393

Merged
merged 13 commits into from
Oct 15, 2024
Merged

Conversation

alduzy
Copy link
Member

@alduzy alduzy commented Oct 7, 2024

Description

The updateViewControllerIfNeeded call introduced by #2230 forces the view controller to rebuild the subviews with the recent config.
When the screen is being unmounted it replaces the subviews with nil values as the reactSubviews are removed from the config one by one. Snapshots made earlier get discarded in the process.

This PR adds a condition that prevents updating the view controller when the screen is being changed + stops unnecessary snapshots when the screen is not changed.

Changes

  • updated Test556.tsx repro
  • added isGoingToBeRemoved property to RNSScreenView
  • making snapshots / updating the view controller conditionally

Test code and steps to reproduce

  • Use Test556.tsx repro

Checklist

  • Included code example that can be used to test this change
  • Ensured that CI passes

Copy link
Member

@kkafar kkafar left a comment

Choose a reason for hiding this comment

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

Hey, I need you to confirm that this PR does not introduce regression on #2230.
You can test specifically on @tboba's reproduction: #2230 (comment)

If we don't have a regression I need you to explain what other change fixed the issue mentioned in #2230. Otherwise I'm a bit reluctant, cause it might be working only by accident.

@alduzy
Copy link
Member Author

alduzy commented Oct 8, 2024

@kkafar Ok, I see. Thanks to @tboba's reproduction I was able to test it and it does in fact introduce regression. I'm going to keep working on it

@alduzy alduzy marked this pull request as draft October 8, 2024 13:06
@alduzy alduzy marked this pull request as ready for review October 14, 2024 07:42
@alduzy alduzy requested a review from kkafar October 14, 2024 14:21
Copy link
Member

@kkafar kkafar left a comment

Choose a reason for hiding this comment

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

Few remarks. The logic looks good, I would only want you to change the naming.

ios/RNSScreen.h Outdated
@@ -100,6 +100,7 @@ namespace react = facebook::react;
@property (nonatomic) react::LayoutMetrics newLayoutMetrics;
@property (weak, nonatomic) RNSScreenStackHeaderConfig *config;
@property (nonatomic, readonly) BOOL hasHeaderConfig;
@property (nonatomic) BOOL isGoingToBeRemoved;
Copy link
Member

Choose a reason for hiding this comment

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

We don't need this in public API of Screen component

Suggested change
@property (nonatomic) BOOL isGoingToBeRemoved;

ios/RNSScreen.h Outdated Show resolved Hide resolved
ios/RNSScreen.mm Outdated Show resolved Hide resolved
alduzy and others added 3 commits October 15, 2024 10:16
Co-authored-by: Kacper Kafara <kacper.kafara@swmansion.com>
@kkafar kkafar merged commit e4333a1 into main Oct 15, 2024
5 checks passed
@kkafar kkafar deleted the @alduzy/ios-header-snapshots-fix branch October 15, 2024 09:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants