Repository navigation
Conversation
- ImageManager and IndicatorStatus get a stored ObservableObjectPublisher - the synthesized getter scans a global weak table on every send(), O(N) per image event
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to
|
|
The Unit Test failures are unrelated to this change: the only failing test is |
|
Just want to add a data point. We ran into the same thing while profiling a screen with a lot of WebImage instances alive at once (a few hundred as you scroll through). Almost everything on the main thread was objectWillChange.getter → ObservableObjectTable.collect(), which was a surprise until we realized these classes have no I tried this PR as is and it helped a lot: main thread CPU for the same scroll dropped by roughly 30%, and nothing else changed behaviour-wise. One thing I noticed afterwards: WebImageConfiguration in WebImage.swift is in the same situation (no Thanks for putting this up, hope it gets merged soon. |
- WebImageConfiguration has no @published either, so its synthesized objectWillChange also goes through the global ObservableObjectTable - add import Combine: ObservableObjectPublisher is not visible via SwiftUI
|
Thanks for the data point and for the extra class — added For the record, on our side (iPhone 11, Release, scroll of a home screen with fewer |
Problem
ImageManager,IndicatorStatusandWebImageConfigurationhave no@Publishedproperty and rely on the synthesized
objectWillChange.The synthesized getter resolves the publisher through a global lookup on every
access, so each
send()during image loading pays that cost. In a screen withmany
WebImageviews updating at once this shows up as main-thread timedominated by the publisher lookup.
Fix
Declare a stored
objectWillChange = ObservableObjectPublisher()in all threeclasses (
publicin the two public ones).WebImage.swiftgetsimport Combine,which
ObservableObjectPublisherneeds. Behaviour is unchanged: same publishertype, same send sites;
WebImageConfigurationnever sends.Impact
In our app (a scrolling list of
WebImageviews plus a sheet with artwork),main-thread time for the same interaction dropped from ~1110 ms to ~427 ms.
@topkim993 measured a screen with a few hundred
WebImageviews: main-thread CPUfor the same scroll dropped by ~30% with
ImageManagerandIndicatorStatus, andby just under 40% with
WebImageConfigurationadded(comment). On our smaller screens
the table lookup is already gone after the first two classes, so the third one is
neutral there — no regression either.
Independent of #364: that PR changes where
send()is called, this one onlychanges how the publisher is stored.
Summary by CodeRabbit