Skip to content

Commit 66334b3

Browse files
committed
Implement SwiftUI's layout system (worse behaviour, but better performance)
Some of the bad behaviour from SwiftUI's layout system can probably be mitigated, but other undesirable behaviour is probably the best we can do, cause some things are impossible to compute nicely without laying out child views more than once (a no go for performant layout)
1 parent b8534f3 commit 66334b3

File tree

104 files changed

+1363
-8292
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

104 files changed

+1363
-8292
lines changed

Benchmarks/LayoutPerformanceBenchmark/LayoutPerformanceBenchmark.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ struct Benchmarks {
3434
}
3535

3636
@MainActor
37-
func updateNode<V: View>(_ node: ViewGraphNode<V, DummyBackend>, _ size: SIMD2<Int>) {
37+
func updateNode<V: View>(_ node: ViewGraphNode<V, DummyBackend>, _ size: ProposedViewSize) {
3838
_ = node.computeLayout(proposedSize: size, environment: environment)
3939
_ = node.commit()
4040
}
@@ -44,7 +44,7 @@ struct Benchmarks {
4444
#endif
4545

4646
@MainActor
47-
func benchmarkLayout<V: TestCaseView>(of viewType: V.Type, _ size: SIMD2<Int>, _ label: String) {
47+
func benchmarkLayout<V: TestCaseView>(of viewType: V.Type, _ size: ProposedViewSize, _ label: String) {
4848
#if BENCHMARK_VIZ
4949
benchmarkVisualizations.append((
5050
label,
@@ -62,8 +62,8 @@ struct Benchmarks {
6262
}
6363

6464
// Register benchmarks
65-
benchmarkLayout(of: GridView.self, SIMD2(800, 800), "grid")
66-
benchmarkLayout(of: ScrollableMessageListView.self, SIMD2(800, 800), "message list")
65+
benchmarkLayout(of: GridView.self, ProposedViewSize(800, 800), "grid")
66+
benchmarkLayout(of: ScrollableMessageListView.self, ProposedViewSize(800, 800), "message list")
6767

6868
#if BENCHMARK_VIZ
6969
let names = benchmarkVisualizations.map(\.name).joined(separator: " | ")

Sources/AppKitBackend/AppKitBackend.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,7 @@ public final class AppKitBackend: AppBackend {
530530
) -> SIMD2<Int> {
531531
if let proposedFrame, proposedFrame.x == 0 {
532532
// We want the text to have the same height as it would have if it were
533-
// one pixel wide so that the layout doesn't suddely jump when the text
533+
// one pixel wide so that the layout doesn't suddenly jump when the text
534534
// reaches zero width.
535535
let size = size(
536536
of: text,

0 commit comments

Comments
 (0)