Skip to content

Declare explicit objectWillChange publishers in ImageManager and IndicatorStatus - #366

Open
sboko83 wants to merge 1 commit into
SDWebImage:masterfrom
sboko83:fix/explicit-objectwillchange
Open

sboko83 wants to merge 1 commit into
SDWebImage:masterfrom
sboko83:fix/explicit-objectwillchange

Conversation

@sboko83

@sboko83 sboko83 commented Oct 9, 2026 •

Copy link
Copy Markdown

Problem

ImageManager and IndicatorStatus 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 with
many WebImage views updating at once this shows up as main-thread time
dominated by the publisher lookup.

Fix

Declare a stored public let objectWillChange = ObservableObjectPublisher() in
both classes. Behaviour is unchanged: same publisher type, same send sites.

Impact

In our app (a scrolling list of WebImage views plus a sheet with artwork),
main-thread time for the same interaction dropped from ~1110 ms to ~427 ms.

Independent of #364: that PR changes where send() is called, this one only
changes how the publisher is stored.

Summary by CodeRabbit

  • Bug Fixes
    • Improved change notifications for image loading and indicator status, helping SwiftUI views stay in sync with updates.

- ImageManager and IndicatorStatus get a stored ObservableObjectPublisher
- the synthesized getter scans a global weak table on every send(), O(N) per image event
@coderabbitai

coderabbitai Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: ae790d59-7ff7-4fe0-af41-6004a059676d

📥 Commits

Reviewing files that changed from the base of the PR and between d1f7b2b and d7fbe2f.


📒 Files selected for processing (2)
  • SDWebImageSwiftUI/Classes/ImageManager.swift
  • SDWebImageSwiftUI/Classes/Indicator/Indicator.swift

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.



📝 Walkthrough

Walkthrough

ImageManager and IndicatorStatus now declare explicit ObservableObjectPublisher properties named objectWillChange.

Changes

ObservableObject Publishers

Layer / File(s) Summary
Explicit publisher declarations
SDWebImageSwiftUI/Classes/ImageManager.swift, SDWebImageSwiftUI/Classes/Indicator/Indicator.swift
ImageManager and IndicatorStatus now declare an explicit objectWillChange publisher.

Priority: ➖ Normal

Estimated code review effort: 1 (Trivial) | ~5 minutes

Change: Refactor


Merge Risk: ⚪ Minimal · up to d7fbe

The change gives both observable objects stable publishers for their manual notifications; no merge-blocking regression is supported.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: adding explicit objectWillChange publishers to ImageManager and IndicatorStatus.
Docstring Coverage Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 2…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.


✨ Finishing Touches 💡 1
🧪 Generate unit tests (beta)
  • Create a new PR


🛠️ Fix failing CI checks 💡
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@sboko83

sboko83 commented Oct 9, 2026

Copy link
Copy Markdown
Author

The Unit Test failures are unrelated to this change: the only failing test is WebImageTests.testWebImageWithAnimatedURL on all three platforms, because apng.onevcat.com no longer resolves (NSURLErrorDomain -1003). All other tests, Build Library, Cocoapods Lint and Run Demo pass. #367 replaces the dead URL; once it is merged I will rebase this branch to get a green run.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant