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

Improve SwiftUIWrapperView performance #322

Merged
merged 1 commit into from
Nov 14, 2024

Conversation

bryankeller
Copy link
Contributor

Details

This is a follow-up to #320.

I made the mistake of only testing with a simple view during my performance investigation, which led me to believe that setting the hosting controller's rootView to an Any(EmptyView()) when it went off screen was the best way to get appearance callbacks to work. Although that approach was faster than removing the hosting controller's view from the hierarchy for a very simple view, it gets slower the more complicated the view is. Even a simple Text with a background shape is 10% slower if we set the rootView to an Any(EmptyView()) vs. just removing the hosting controller's view from the hierarchy.

I'm assuming this is the case because it's more expensive to tear down and set up a complicated view from scratch vs. whatever price we pay for removing and adding subviews dynamically.

Related Issue

N/A

Motivation and Context

Performance improvements

How Has This Been Tested

Example app, Airbnb app

@bryankeller bryankeller added the bug Something isn't working label Nov 14, 2024
@bryankeller bryankeller merged commit 8c36887 into master Nov 14, 2024
2 checks passed
@bryankeller bryankeller deleted the bk/SwiftUIWrapperView-perf-improvements branch November 14, 2024 17:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants