Skip to content

Add ViewRenderer and ViewCache API support - #848

Merged
Kyle-Ye merged 19 commits into
mainfrom
feature/view_updater
Mar 30, 2026
Merged

Add ViewRenderer and ViewCache API support#848
Kyle-Ye merged 19 commits into
mainfrom
feature/view_updater

Conversation

@Kyle-Ye

@Kyle-Ye Kyle-Ye commented Mar 30, 2026

Copy link
Copy Markdown
Member

No description provided.

@augmentcode

augmentcode Bot commented Mar 30, 2026

Copy link
Copy Markdown
🤖 Augment PR Summary

Summary: This PR expands OpenSwiftUI’s DisplayList rendering pipeline with initial support for SwiftUI 6.5.4’s ViewRenderer and view caching APIs.

Changes:

  • Introduces/updates DisplayList.ViewRenderer to select between default updating and rasterized rendering paths, with SwiftUI test-stub hooks gated on 6.5.4.
  • Adds a substantial DisplayList.ViewUpdater.ViewCache implementation to track cached platform views, reverse mappings, removals, and async CA-backed property updates.
  • Defines effect-animation protocols (AnyEffectAnimation/AnyEffectAnimator) and a basic structural matcher used by async update validation.
  • Extends graphics APIs to include GraphicsContext.drawLayer (stubbed) and enables a GraphicsFilter.shader case.
  • Expands platform integration helpers (layer access, drawing-view updates, child traversal) and adds CALayer SPI overlays for display-list IDs and animation suppression.
  • Moves EmptyViewRendererHost into ViewRendererHost.swift (no functional change intended).

Technical Notes: Async rendering paths rely on QuartzCore private SPI (CAPresentationModifier*, background CA transactions) and include cross-platform shims/stubs where frameworks aren’t available.

🤖 Was this summary useful? React with 👍 or 👎

@augmentcode augmentcode Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Review completed. 3 suggestions posted.

Fix All in Augment

Comment augment review to trigger a new review at any time.

// CoreGraphicsShims.swift
// OpenSwiftUICore

#if !canImport(CoreGraphics)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Sources/OpenSwiftUICore/Util/CoreGraphicsShims.swift:5 This shim defines CAPresentationModifier* types, but it’s conditionally compiled with !canImport(CoreGraphics) rather than !canImport(QuartzCore), so platforms that have CoreGraphics shims but no QuartzCore could still fail to build due to missing CAPresentationModifier symbols.

Severity: medium

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.

return true
case (.content, .content):
return true
case (.effect, .effect):

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Sources/OpenSwiftUICore/Render/DisplayList/DisplayList.swift:493 matchesTopLevelStructure(of:) treats any .effect pair as structurally identical, which can let ViewUpdater.updateAsync proceed even if the effect kind changed (potentially applying async updates against an incompatible structure).

Severity: medium

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.

// Flush modified presentation modifier groups
for groupID in modifiedGroups {
let group = unsafeBitCast(groupID, to: CAPresentationModifierGroup.self)
group.flushWithTransaction()

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Sources/OpenSwiftUICore/Render/DisplayList/DisplayListViewCache.swift:193 commitAsyncValues may run off the main thread (it calls CATransaction.activateBackground(true)), but it flushes modifier groups via flushWithTransaction(), which your SPI header documents as main-thread-only; this could lead to CA assertions/crashes in async rendering.

Severity: high

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.

@codecov

codecov Bot commented Mar 30, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 1.43770% with 617 lines in your changes missing coverage. Please review.
✅ Project coverage is 26.55%. Comparing base (cd9a5fc) to head (23432a7).
⚠️ Report is 5 commits behind head on main.

Files with missing lines Patch % Lines
...Core/Render/DisplayList/DisplayListViewCache.swift 0.00% 260 Missing ⚠️
...re/Render/DisplayList/DisplayListViewUpdater.swift 0.00% 163 Missing ⚠️
...e/Render/DisplayList/DisplayListViewRenderer.swift 7.96% 104 Missing ⚠️
...e/Render/DisplayList/DisplayListViewPlatform.swift 0.00% 26 Missing ⚠️
.../OpenSwiftUICore/View/Graph/ViewRendererHost.swift 0.00% 18 Missing ⚠️
...OpenSwiftUICore/Render/RendererConfiguration.swift 0.00% 17 Missing ⚠️
...enSwiftUICore/Render/DisplayList/DisplayList.swift 0.00% 13 Missing ⚠️
...Render/DisplayList/DisplayListPlatformEffect.swift 0.00% 12 Missing ⚠️
...rces/OpenSwiftUICore/Graphic/GraphicsContext.swift 0.00% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #848      +/-   ##
==========================================
- Coverage   26.85%   26.55%   -0.31%     
==========================================
  Files         671      671              
  Lines       43470    44009     +539     
==========================================
+ Hits        11675    11686      +11     
- Misses      31795    32323     +528     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

CAPresentationModifier and CAPresentationModifierGroup are QuartzCore
types, not CoreGraphics — fix the compile guard from !canImport(CoreGraphics)
to !canImport(QuartzCore) and rename the file accordingly.
@Kyle-Ye
Kyle-Ye merged commit 76c61a9 into main Mar 30, 2026
8 checks passed
@Kyle-Ye
Kyle-Ye deleted the feature/view_updater branch March 30, 2026 16:29
@Kyle-Ye Kyle-Ye added area: rendering DisplayList, render backends, renderer hosts, drawing, and effects. area: view View APIs, modifiers, AnyView, ForEach, DynamicView, and related behavior. type: feature New API, behavior, platform support, or user-facing capability. labels May 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: rendering DisplayList, render backends, renderer hosts, drawing, and effects. area: view View APIs, modifiers, AnyView, ForEach, DynamicView, and related behavior. type: feature New API, behavior, platform support, or user-facing capability.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant