Cal Stephens

4.4K posts

Cal Stephens banner
Cal Stephens

Cal Stephens

@calstephens98

iOS Engineer @Airbnb

San Francisco, CA Katılım Ocak 2011
990 Takip Edilen2.1K Takipçiler
Cal Stephens
Cal Stephens@calstephens98·
@Martma12 @v_pradeilles Helpful improvement but unrelated! The behavior you’re talking about is for Equatable properties on @Observable classes. The blog post discusses stored properties directly on a SwiftUI view itself. No changes there.
English
0
0
1
40
Cal Stephens
Cal Stephens@calstephens98·
@DonnyWals Does this sample code have a retain cycle? Can’t spot one
English
1
0
0
74
Donny Wals 👾
Donny Wals 👾@DonnyWals·
Tasks in Swift allow you to access self without using self explicitly. You don't need to capture self, it's just there. This means that it's quite easy to create retain cycles without the compiler stopping you... I talk about this and much more in Practical Swift Concurrency. Now available with 30% off, link the replies
Donny Wals 👾 tweet media
English
3
0
7
1.9K
Ivan 🍉
Ivan 🍉@ivanopcode·
@calstephens98 @AetherAurelia @AirbnbEng But anyway, I am fully into making strict rules about views being explicitly equitable (kudos for macro based solution, consider sharing its implementation!) **and** using independent view structs instead of helper funcs. Those are great and must have SwiftUI patterns.
English
1
0
1
40
aether
aether@AetherAurelia·
lil RenderMeThis demo Observable gives fine‑grained updates: only the views that depend on a property recompute. ObservedObject is coarse: any change makes all dependent views recompute
English
4
7
126
11.2K
Cal Stephens
Cal Stephens@calstephens98·
@ivanopcode @AetherAurelia @AirbnbEng We agree on this point — decreasing view body evaluations can improve performance. I also agree that many screens are simple enough that view body evaluations aren’t an issue and reducing them aren’t going to move the needle. Different story for really complicated screens though!
English
1
0
1
28
Ivan 🍉
Ivan 🍉@ivanopcode·
@calstephens98 @AetherAurelia @AirbnbEng Obv is you decrease evaluation of body you improve performance but oftentimes there are hidden computations there which are real cause of inefficient rendering. I.e. fighting body recalculations is wrong path imo. (…)
English
2
0
2
49
Cal Stephens
Cal Stephens@calstephens98·
@ivanopcode @AetherAurelia @AirbnbEng Haha, definitely don’t agree 😛 if you’re evaluating the view body of a root view with many descendants, that is definitely not “free”. If every view body in the tree had to be evaluated every time any state changed, then the feature would definitely not perform well.
English
1
0
0
18
Ivan 🍉
Ivan 🍉@ivanopcode·
@calstephens98 @AetherAurelia @AirbnbEng Evaluating view body is close to being free if within evaluation path there is no complexity e.g. sort array passed to ForEach, or access element from collection in vm plus some accidental quadratic there. (…)
English
2
0
1
51
Cal Stephens
Cal Stephens@calstephens98·
@ivanopcode @AetherAurelia @AirbnbEng We found experimentally that reducing redundant view body evaluations improves real world performance for users 🤷🏼‍♂️ evaluating the view body is not free, seems obvious that reducing redundant work should result in some sort of performance improvement…
English
1
0
2
43
Ivan 🍉
Ivan 🍉@ivanopcode·
@AetherAurelia This confuses 99% of SwiftUI devs, including very senior ones. Welcome to the 1% club. Here’s @AirbnbEng’s article on SwiftUI performance, where they fall into the exact same trap: hooking a random color to body recalcs and using it as proof of rerendering. (fyi: @calstephens98)
English
2
0
2
75
Cal Stephens retweetledi
Vincent Pradeilles
Vincent Pradeilles@v_pradeilles·
You're having performance issues with SwiftUI and you're struggling to solve them? 😫 So did Airbnb and they've just published the method that solved them! Let me walk you through it 😌
English
0
6
67
3.9K
Daniel Lurie 丹尼爾·羅偉
Daniel Lurie 丹尼爾·羅偉@DanielLurie·
San Francisco just got a proposal for the tallest tower on the West Coast. And this is not just about one building. This plan would transform a vacant city block into a dynamic mix of housing, office space, retail, and public space by developing the former PG&E and Matson headquarters. This shows what's possible when people believe in our city's future. Let's go, San Francisco.
San Francisco Chronicle@sfchronicle

BREAKING: Proposed S.F. tower would be 15 stories taller than Salesforce and forever change the city skyline. sfchronicle.com/sf/article/new…

English
178
99
2.1K
262.3K
Cal Stephens
Cal Stephens@calstephens98·
@rxmustdie A view that is re-evaluated might not be re-rendered, but a view that isn’t re-evaluated at all will _definitely_ not be re-rendered 😀
English
0
0
0
58
Cal Stephens
Cal Stephens@calstephens98·
@rxmustdie We demonstrated with production performance data that reducing redundant view body re-evaluations improves performance for end users. You’re right that a re-evaluation doesn’t necessarily imply that the view will be re-rendered, but the evaluation still has a cost!
English
1
0
0
66
Cal Stephens
Cal Stephens@calstephens98·
@rxmustdie EquatableView is supposed to guarantee that == will always be called even if the view is POD. I don’t think that matters much because (1) POD views are pretty uncommon (2) a custom Equatable implementation should only be an optimization, not required for functional correctness
English
0
0
0
53
Cal Stephens
Cal Stephens@calstephens98·
@rxmustdie SwiftUI won’t call == by default if the view is POD (plain ol data, so no classes. Strings aren’t POD). In that case it instead performs a more efficient bitwise comparison on the properties. In this example where the view has an Int instead of a String, == is never called
Cal Stephens tweet media
English
1
0
0
72
Cal Stephens
Cal Stephens@calstephens98·
@squeakytoy Thanks! I watched the talk (good stuff in there) and am looking forward to trying out the new instrument.
English
0
0
1
108
Cal Stephens
Cal Stephens@calstephens98·
@tiborbodecs SwiftFormat has many, many more rules and options than swift-format 😉
English
0
0
1
88
Tibor Bödecs
Tibor Bödecs@tiborbodecs·
🤔 Which option do you think is better and why (comment below):
English
4
0
1
929
Guillaume
Guillaume@g_sabran·
Xcode 26's new AI assistant is a step forward, but still pretty basic. No agents, just chat. In this post I show a creative workaround to bring state of the art AI to Xcode, though honestly we shouldn't need hacks for decent AI tooling in 2025 🤷‍♂️ @guillaumesabran/whats-finally-shipping-in-swift-assist-and-how-to-bring-it-to-modern-days-ai-with-claude-code-fbe874634c0e" target="_blank" rel="nofollow noopener">medium.com/@guillaumesabr
English
1
1
6
1.5K
Cal Stephens
Cal Stephens@calstephens98·
@eneko Makes sense that the task is retaining the view, but how is the view retaining the task?
English
1
0
0
38
Eneko
Eneko@eneko·
Really wish Xcode displayed escaping closures differently than non-escaping ones. Different Swift syntax would be great, imo, something like {} for non-escaping, and ^{} for escaping. Meanwhile, the following causes a retain cycle (ocf) class myView: UIView { func a () { Task { await b() } } @MainActor func b() async { ... } }
English
1
0
7
404
United Airlines
United Airlines@united·
It may be April 1, but this isn’t a joke. New routes incoming. Tomorrow. 8 a.m. ET. Drop your guesses below. ⬇
English
234
70
720
86.1K