Skip to content

Rotated view hierarchy is incorrect in OpenSwiftUI View Renderer #878

@Kyle-Ye

Description

@Kyle-Ye

Summary

rotationEffect can build an incorrect UIKit hierarchy when using the OpenSwiftUI View Renderer.

The DisplayList output contains the expected rotated content, but the rendered UIKit hierarchy differs from the SwiftUI-renderer path. The rotated graphics view is nested under an inherited wrapper and receives an unexpected frame, which causes visual mismatch.

Reproduction

Use a minimal stacked view with a rotated lower layer:

struct ContentView: View {
    var body: some View {
        VStack {
            Rectangle()
                .fill(Color.yellow)
                .frame(width: 100, height: 100)
                .zIndex(1)

            Rectangle()
                .fill(Color.red)
                .frame(width: 100, height: 100)
                .rotationEffect(.degrees(45))
        }
    }
}

Run the example with the OpenSwiftUI View Renderer enabled.

Expected Behavior

The rotated red rectangle should render in the same position and hierarchy shape as the SwiftUI-renderer path.

The rotated graphics view should be placed directly under the hosting view with the expanded transformed frame and transform applied to that graphics view.

Actual Behavior

The DisplayList has the expected entries for both rectangles, but the OpenSwiftUI renderer hierarchy wraps the rotated graphics view in _UIInheritedView.

The nested _UIGraphicsView also receives the absolute frame, so the view hierarchy no longer matches the SwiftUI-renderer path.

Notes

The issue appears to be in OpenSwiftUI renderer hierarchy construction for transformed graphics content, not in DisplayList generation.

Log

OpenSwiftUI ViewRenderer

<_UIHostingView ... frame = (0 0; 402 874)>
   | <OpenSwiftUI._UIInheritedView: ... frame = (151 455; 100 100)>
   |    | <OpenSwiftUI._UIGraphicsView: ... frame = (151 455; 100 100); backgroundColor = red>
   | <OpenSwiftUI._UIGraphicsView: ... frame = (151 347; 100 100); backgroundColor = yellow>

SwiftUI View Renderer

<_UIHostingView ... frame = (0 0; 402 874)>
   | <OpenSwiftUI._UIGraphicsView: ... frame = (130.289 434.289; 141.421 141.421); transform = [0.707106..., 0.707106..., -0.707106..., 0.707106..., 0, 0]; backgroundColor = red>
   | <OpenSwiftUI._UIGraphicsView: ... frame = (151 347; 100 100); backgroundColor = yellow>

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: compatibilityCompatibility, availability, legacy support, and cross-version behavior.area: hosting-bridgeSwiftUI bridge, UIHosting/NSHosting, representables, and platform host views.area: renderingDisplayList, render backends, renderer hosts, drawing, and effects.impact: visual-diffVisual mismatch, screenshot diff, or rendering fidelity issue.platform: iOSiOS-specific behavior or support.type: bugSomething is not working correctly.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions