Skip to content

Comments

Utilize cache infra#587

Open
maxg-square wants to merge 57 commits intomaxg/cache_2_envcachefrom
maxg/cache_3_caches
Open

Utilize cache infra#587
maxg-square wants to merge 57 commits intomaxg/cache_2_envcachefrom
maxg/cache_3_caches

Conversation

@maxg-square
Copy link
Contributor

3/3 for caching changes.
Design doc: https://docs.google.com/document/d/1CLhFbzZGbEKgvZTUwLuGbFY-rfZNJVTi6f3PkoZT9qI/edit?usp=sharing

Adds support for caching AttributedLabel string normalization results.
Adds support for skipping calls to setNeedsViewHierarchyUpdate when Environment and Element value changes are equivalent.
Adds support for caching MeasureableStorage measurements.

* maxg/cache_1_equivalency:
  include other TestKeys
  Fix testkey
* maxg/cache_2_envcache:
  include other TestKeys
  Fix testkey
* maxg/cache_2_envcache:
  include other TestKeys
  Fix testkey
* maxg/cache_2_envcache:
  include other TestKeys
  Fix testkey
* maxg/cache_2_envcache:
  More tests
  Tests and fixes
* main:
  Bump macOS, Xcode, Swift, and Tuist versions. (#580)
  chore: release 6.1.0
  Fix AccessibilityContainer behaviour when it contains a UICollectionView or UITableView
  Ignoring slight keyboard overlaps in ScrollView (#575)
* maxg/cache_2_envcache:
  Existentials for Xcode 15
* maxg/cache_2_envcache:
  Enable logging for test.
  Tweak internal env api.
  Log guard
* maxg/cache_2_envcache:
  Release 6.3.0
  Assert in debug mode when large content viewer is not placed inside an interaction container
  Expose largeContentViewerInteraction on LargeContentViewer backing view via protocol
  Stopped installing xcodes in GitHub Actions file
  chore: Release 6.2.0
  Support accessibility large content viewer
  Squash
Copy link
Collaborator

@watt watt left a comment

Choose a reason for hiding this comment

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

Can you rebase this on the maxg/cache_2_envcache branch? Looks like it's got some changes from the other 2 stacked PRs mixed in.

@maxg-square maxg-square changed the base branch from main to maxg/cache_2_envcache October 2, 2025 21:18
Copy link
Collaborator

@watt watt left a comment

Choose a reason for hiding this comment

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

Looking good overall, just still a few open questions/comments from the last review on this one.

Copy link
Contributor

@johnnewman-square johnnewman-square left a comment

Choose a reason for hiding this comment

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

Neat! I'd love to try this out in the Catalog app. Would it be possible to spin up a branch with the new layout settings enabled?

Copy link
Collaborator

@watt watt left a comment

Choose a reason for hiding this comment

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

Approved pending a couple small tweaks! 👍

Comment on lines +98 to +101
if let layoutMode, layoutMode.options.skipUnneededSetNeedsViewHierarchyUpdates, let crossLayoutCacheable = element as? CrossLayoutCacheable, crossLayoutCacheable.isCacheablyEquivalent(
to: oldValue as? CrossLayoutCacheable,
in: .all
) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

similar thing for layotuMode + a formatting suggestion to reduce line length

Suggested change
if let layoutMode, layoutMode.options.skipUnneededSetNeedsViewHierarchyUpdates, let crossLayoutCacheable = element as? CrossLayoutCacheable, crossLayoutCacheable.isCacheablyEquivalent(
to: oldValue as? CrossLayoutCacheable,
in: .all
) {
let layoutMode = self.layoutMode ?? RenderContext.current?.layoutMode ?? environment.layoutMode
if
layoutMode.options.skipUnneededSetNeedsViewHierarchyUpdates,
let crossLayoutCacheable = element as? CrossLayoutCacheable,
crossLayoutCacheable.isCacheablyEquivalent(
to: oldValue as? CrossLayoutCacheable,
in: .all
)
{
  • layoutMode (formatting optional)


self.element = element
self.environment = environment
self.environment.hostingViewContext = hostingViewContext
Copy link
Collaborator

Choose a reason for hiding this comment

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

resurrected from a resolved comment:

shouldn't need to set this here, it'll be applied during makeEnvironment. self.environment is the "base"

  • only set hostingViewContext in makeEnvironment

// Shortcut: If both environments were empty, nothing changed.
if oldValue.isEmpty && environment.isEmpty { return }
// Shortcut: If there are no changes to the environment, then, well, nothing changed.
if let layoutMode, layoutMode.options.skipUnneededSetNeedsViewHierarchyUpdates && oldValue.isCacheablyEquivalent(
Copy link
Collaborator

Choose a reason for hiding this comment

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

adapting a previous comment into a suggestion:

Suggested change
if let layoutMode, layoutMode.options.skipUnneededSetNeedsViewHierarchyUpdates && oldValue.isCacheablyEquivalent(
let layoutMode = self.layoutMode ?? RenderContext.current?.layoutMode ?? environment.layoutMode
if layoutMode.options.skipUnneededSetNeedsViewHierarchyUpdates && oldValue.isCacheablyEquivalent(
  • resolve layoutmode the way layout does

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.

3 participants