Skip to content

Build the coordinator HTTP client on the first request - #1815

Merged
aleksandar-apostolov merged 1 commit into
develop-v2from
andrerego/and-1501-compose-previews-fail-with-noclassdeffounderror-when-the-sdk
Sep 9, 2026
Merged

Build the coordinator HTTP client on the first request#1815
aleksandar-apostolov merged 1 commit into
develop-v2from
andrerego/and-1501-compose-previews-fail-with-noclassdeffounderror-when-the-sdk

Conversation

@andremion

@andremion andremion commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Goal

Compose previews in Android Studio fail with NoClassDefFoundError: com/android/org/conscrypt/TrustManagerImpl as soon as a preview calls StreamPreviewDataUtils.initializeStreamVideo. Layoutlib reports the VM as Dalvik, so OkHttp selects its Android platform, but layoutlib does not ship the conscrypt classes that platform needs. Previews never send a request, so the client should not be built while the SDK is constructed.

Linear: AND-1501

Implementation

CoordinatorConnectionModule.http is now by lazy, and Retrofit uses callFactory { http.newCall(it) } instead of client(http). The second change is needed because StreamVideoBuilder.build() reads the Retrofit API during construction, which would otherwise still build the client.

The other OkHttp clients (socket connections, latency probe) are created on connect or join and are not on the preview path.

This targets develop-v2 only. On develop the module also builds the coordinator socket connection eagerly with the same client, so this change alone would not fix previews there.

🎨 UI Changes

None.

Testing

  • Android Studio: the CallLobby previews render again (verified by the author).
  • :stream-video-android-core:compileDebugKotlin, apiCheck (internal class, no API change).
  • Core unit tests StreamVideoClientTest, StreamVideoClientCleanupTest, CallConnectivityMonitorTest: 38 tests green.
  • :stream-video-android-ui-compose:verifyPaparazziDebug: 165 tests green, goldens unchanged.

Summary by CodeRabbit

  • Bug Fixes
    • Android Studio layout previews can now render without initializing the networking client.
    • Network requests continue to use the configured interceptors, retry behavior, and timeout settings.

@andremion andremion added the pr:improvement Enhances an existing feature or code label Sep 8, 2026
@andremion

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@github-actions

github-actions Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

PR checklist ✅

All required conditions are satisfied:

  • Title length is OK (or ignored by label).
  • At least one pr: label exists.
  • Sections ### Goal, ### Implementation, and ### Testing are filled, or the PR is bot-authored.
  • An issue is linked (Linear ticket or GitHub issue), or the PR is bot-authored.

🎉 Great job! This PR is ready for review.

@coderabbitai

coderabbitai Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai

coderabbitai Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 60a6a0f2-f8a3-4a29-8aa9-09df5066ac6b

📥 Commits

Reviewing files that changed from the base of the PR and between e353773 and a69f1c1.

📒 Files selected for processing (1)
  • stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/internal/module/CoordinatorConnectionModule.kt

Included review availability: Your plan provides up to 2 included reviews per hour; 1 remains after this review.


Walkthrough

Retrofit now defers OkHttp client creation until the first request. Existing interceptors, retry behavior, logging, and timeout settings remain configured on the lazy client.

Changes

Connection initialization

Layer / File(s) Summary
Lazy HTTP call factory
stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/internal/module/CoordinatorConnectionModule.kt
Retrofit creates requests through a call factory backed by a lazy OkHttp client. Existing client configuration remains unchanged.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to a69f1

Coordinator HTTP client creation now occurs on the first request, allowing Compose previews to render without initializing the platform client while preserving configured request behavior. No current merge-blocking risk remains.

Suggested reviewers: aleksandar-apostolov

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
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 1…
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.
Title check ✅ Passed The title clearly and concisely describes the primary change: lazy creation of the coordinator HTTP client on the first request.
Description check ✅ Passed The description includes the goal, implementation details, scope, UI impact, testing results, and issue reference. The template checklists and GIF section are not completed, but the core technical inf…
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch andrerego/and-1501-compose-previews-fail-with-noclassdeffounderror-when-the-sdk

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

A rabbit reads each line,
The patch grows clear beneath the moon,
Small changes hop in place,
Tests guard the garden path,
Reviews bloom before the dawn.

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

@github-actions

github-actions Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

SDK Size Comparison 📏

SDK Before After Difference Status
stream-video-android-core 12.30 MB 12.45 MB 0.14 MB 🟢
stream-video-android-ui-xml 5.70 MB 5.75 MB 0.05 MB 🟢
stream-video-android-ui-compose 6.23 MB 5.82 MB -0.41 MB 🚀

@andremion
andremion marked this pull request as ready for review September 8, 2026 10:15
@andremion
andremion requested a review from a team as a code owner September 8, 2026 10:15
Compose previews in Android Studio failed with NoClassDefFoundError for
com/android/org/conscrypt/TrustManagerImpl as soon as the SDK was built.
Layoutlib identifies itself as Dalvik, so OkHttp picks its Android platform,
which needs conscrypt classes that layoutlib does not ship.

The coordinator module built the OkHttp client eagerly, and the builder reads
the Retrofit API during construction, so the client was created even though
previews never send a request. The client is now lazy and Retrofit gets a call
factory instead of the client instance.
@andremion
andremion force-pushed the andrerego/and-1501-compose-previews-fail-with-noclassdeffounderror-when-the-sdk branch from a69f1c1 to 713f908 Compare September 8, 2026 10:26
@sonarqubecloud

sonarqubecloud Bot commented Sep 8, 2026

Copy link
Copy Markdown

@aleksandar-apostolov aleksandar-apostolov left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@aleksandar-apostolov
aleksandar-apostolov merged commit 87561e4 into develop-v2 Sep 9, 2026
25 of 27 checks passed
@aleksandar-apostolov
aleksandar-apostolov deleted the andrerego/and-1501-compose-previews-fail-with-noclassdeffounderror-when-the-sdk branch September 9, 2026 09:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr:improvement Enhances an existing feature or code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants