Register the OkHttp network fetcher explicitly in the default image loader#6384
Register the OkHttp network fetcher explicitly in the default image loader#6384VelikovPetar merged 2 commits intodevelopfrom
Conversation
Coil 3 auto-registers OkHttpNetworkFetcherFactory via ServiceLoader, which R8 can strip in release builds, leaving HTTP image loading without a fetcher and rendering only placeholders. Adding it directly to the component registry removes the ServiceLoader dependency for the default SDK path.
|
@CodeRabbit review |
✅ Actions performedReview triggered.
|
PR checklist ✅All required conditions are satisfied:
🎉 Great job! This PR is ready for review. |
WalkthroughTwo files modified: Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~5 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In
`@stream-chat-android-ui-common/src/test/kotlin/io/getstream/chat/android/ui/common/images/StreamImageLoaderFactoryTest.kt`:
- Around line 107-115: The test newImageLoader registers network fetcher for
HTTP URLs is currently asserting only that any NetworkFetcher.Factory exists,
which can be satisfied by ServiceLoader-discovered implementations; update the
test to assert the explicit OkHttp implementation is present by checking for an
instance of OkHttpNetworkFetcherFactory (or its exact class name) within
imageLoader.components.fetcherFactories, or alternatively mock/override
ServiceLoader so you can verify StreamImageLoaderFactory.newImageLoader actually
calls add(OkHttpNetworkFetcherFactory()) rather than relying on a discovered
factory; reference the test method name,
StreamImageLoaderFactory.newImageLoader,
imageLoader.components.fetcherFactories, and OkHttpNetworkFetcherFactory in your
change.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: c48c1968-99ac-4566-98f2-98b3462f3234
📒 Files selected for processing (2)
stream-chat-android-ui-common/src/main/kotlin/io/getstream/chat/android/ui/common/images/StreamImageLoaderFactory.ktstream-chat-android-ui-common/src/test/kotlin/io/getstream/chat/android/ui/common/images/StreamImageLoaderFactoryTest.kt
SDK Size Comparison 📏
|
|
VelikovPetar
left a comment
There was a problem hiding this comment.
Should we also do the fix for V6?
Yes, we should. I'll cherry-pick this into a separate v6 PR. |



Goal
Since the Coil 2 → Coil 3 migration in 6.13.0, customers have reported blank/placeholder images in release builds (support ticket). Coil 3 registers
OkHttpNetworkFetcherFactoryviaServiceLoader, which R8 full-mode can strip, leaving theImageLoaderwithout a fetcher for HTTP URLs. Registering it explicitly removes theServiceLoaderdependency.Implementation
StreamImageLoaderFactory— addOkHttpNetworkFetcherFactory()to the components block. Integrators delegating toStreamImageLoaderFactory(ComposeStreamCoilImageLoaderFactory.defaultFactory()and the XMLStreamCoilsingleton) pick up the fix for free. No public API changes.Not included — consumer R8 keep rules for Coil 3
ServiceLoaderdescriptors. With the fetcher registered in code, those only matter for integrators building a fully customImageLoader, which is already covered by the docs.Testing
./gradlew :stream-chat-android-ui-common:testDebugUnitTest --tests "StreamImageLoaderFactoryTest"— includes a new assertion thatfetcherFactoriescontains aNetworkFetcher.Factory.stream-chat-android-compose-sampleon a device that previously reproduced the blank-image symptom, open a channel with image attachments, confirm images load without any integrator-side fetcher registration.No UI changes.
Summary by CodeRabbit