Skip to content

MyViewThatFitsByLayout animation example issue after a few phase #349

Open
@Kyle-Ye

Description

@Kyle-Ye
struct ContentView: View {
    @State private var showRed = false
    var body: some View {
        MyViewThatFitsByLayout {
            Color.red.frame(width: 100, height: 200)
            Color.blue.frame(width: 200, height: 100)
        }
        .frame(width: 100, height: showRed ? 200 : 100)
        .onAppear {
            DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
                showRed.toggle()
            }
        }
        .id(showRed)
    }
}

It behave normal at first. But at the third animation, the effect is wrong.

Simulator.Screen.Recording.-.iPhone.13.Pro.-.2025-06-23.at.03.07.08.mp4

cc @fatbobman in case you are also interested at this. (Of course, this is a bug on OpenSwiftUI not your MyViewThatFitsByLayout code)

OpenSwiftUI

(display-list
  (item #:identity 1 #:version 1
    (frame (100000.0 100000.0; 100.0 200.0))
    (content-seed 3)
    (color #FF3B30FF))
  (item #:identity 2 #:version 2
    (frame (95.0 400.66666666666663; 200.0 100.0))
    (content-seed 5)
    (color #007AFFFF)))
View 0x0000000125404800 at Time(seconds: inf):
(display-list
  (item #:identity 1 #:version 6
    (frame (145.0 350.66666666666663; 100.0 200.0))
    (content-seed 3)
    (color #FF3B30FF))
  (item #:identity 2 #:version 7
    (frame (100000.0 100000.0; 200.0 100.0))
    (content-seed 5)
    (color #007AFFFF)))
View 0x0000000125404800 at Time(seconds: inf):
(display-list
  (item #:identity 1 #:version 10
    (frame (100000.0 100000.0; 100.0 200.0))
    (content-seed 3)
    (color #FF3B30FF))
  (item #:identity 2 #:version 11
    (frame (95.0 400.66666666666663; 200.0 100.0))
    (content-seed 5)
    (color #007AFFFF)))
View 0x0000000125404800 at Time(seconds: inf):
(display-list
  (item #:identity 1 #:version 10
    (frame (100000.0 100000.0; 100.0 200.0))
    (content-seed 3)
    (color #FF3B30FF))
  (item #:identity 2 #:version 14
    (frame (145.0 350.66666666666663; 200.0 100.0))
    (content-seed 5)
    (color #007AFFFF)))
View 0x0000000125404800 at Time(seconds: inf):
(display-list
  (item #:identity 1 #:version 10
    (frame (100000.0 100000.0; 100.0 200.0))
    (content-seed 3)
    (color #FF3B30FF))
  (item #:identity 2 #:version 17
    (frame (95.0 400.66666666666663; 200.0 100.0))
    (content-seed 5)
    (color #007AFFFF)))
View 0x0000000125404800 at Time(seconds: inf):
(display-list
  (item #:identity 1 #:version 10
    (frame (100000.0 100000.0; 100.0 200.0))
    (content-seed 3)
    (color #FF3B30FF))
  (item #:identity 2 #:version 20
    (frame (145.0 350.66666666666663; 200.0 100.0))
    (content-seed 5)
    (color #007AFFFF)))
View 0x0000000125404800 at Time(seconds: inf):
(display-list
  (item #:identity 1 #:version 10
    (frame (100000.0 100000.0; 100.0 200.0))
    (content-seed 3)
    (color #FF3B30FF))
  (item #:identity 2 #:version 23
    (frame (95.0 400.66666666666663; 200.0 100.0))
    (content-seed 5)
    (color #007AFFFF)))

SwiftUI

View 0x0000000129004b50 at Time(seconds: 1.0000003385357559e-06):
(display-list
  (item #:identity 3 #:version 3
    (frame (145.0 400.66666666666663; 100.0 100.0))
    (effect
      (item #:identity 1 #:version 1
        (frame (99855.0 99599.33333333333; 100.0 200.0))
        (content-seed 3)
        (color #FF3B30FF))
      (item #:identity 2 #:version 2
        (frame (-50.0 0.0; 200.0 100.0))
        (content-seed 5)
        (color #007AFFFF)))))
View 0x0000000129004b50 at Time(seconds: 1.0512055833387421):
(display-list
  (item #:identity 6 #:version 10
    (frame (145.0 350.66666666666663; 100.0 200.0))
    (effect
      (item #:identity 4 #:version 8
        (frame (0.0 0.0; 100.0 200.0))
        (content-seed 17)
        (color #FF3B30FF))
      (item #:identity 5 #:version 9
        (frame (99855.0 99649.33333333333; 200.0 100.0))
        (content-seed 19)
        (color #007AFFFF)))))

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Low prioritybugSomething isn't workinghelp wantedPR contribution is appreciated

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions