Skip to content

Wait for the SDK re-initialization before joining a call after re-login - #1793

Merged
andremion merged 1 commit into
developfrom
andrerego/and-1467-join-tap-races-the-sdk-re-initialization-after-a-fast-re
Aug 31, 2026
Merged

Wait for the SDK re-initialization before joining a call after re-login#1793
andremion merged 1 commit into
developfrom
andrerego/and-1467-join-tap-races-the-sdk-re-initialization-after-a-fast-re

Conversation

@andremion

@andremion andremion commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Goal

Stop the demo app from crashing when a call join is attempted while the SDK is still re-initializing after a fast logout and re-login. Found while verifying the AND-1466 fix on the develop-v2 merge PR #1790: the process crash also pollutes the following E2E tests, which then cannot find the sign-in screen.

Resolves AND-1467.

Implementation

After a logout and quick re-login, the join screen's ViewModel starts StreamVideoInitHelper.loadSdk() from its init block, and that takes seconds (mostly the token fetch). The join UI is fully interactive during that window, and joinCall called StreamVideo.instance(), which throws when the instance is not installed yet. The exception escaped through the flatMapLatest flow on the UI scope and killed the process.

Changes, all in CallJoinViewModel:

  • joinCall is now suspend and null-safe: when StreamVideo is not installed it triggers loadSdk and awaits StreamVideoInitHelper.initializedState reaching FINISHED or FAILED, then reads instanceOrNull(). The await matters because loadSdk returns early when another initialization is already in flight, without waiting for it.
  • The JoinCall branch of the uiState flow maps a null call (initialization failed) to GoBackToLogin instead of crashing.

The race is latent on develop today. It surfaces on the develop-v2 merge branch because the AND-1466 fix (#1792) makes logout and re-login fast enough to hit it, and it will reach develop-v2 through the next merge-down.

🎨 UI Changes

No visual changes. On an SDK initialization failure the join tap now navigates back to the login screen instead of crashing the app.

Testing

Summary by CodeRabbit

  • Bug Fixes
    • Improved call joining when the Video SDK has not finished loading.
    • Automatically completes SDK initialization before attempting to join a call.
    • Returns users to the login screen when call setup cannot be completed.

@andremion
andremion requested a review from a team as a code owner August 31, 2026 10:24
@andremion andremion added the pr:bug Fixes a bug label Aug 31, 2026
@coderabbitai

coderabbitai Bot commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 2e3b1b98-4265-459a-aa06-31962e6af1d6

📥 Commits

Reviewing files that changed from the base of the PR and between b530e34 and d644c65.

📒 Files selected for processing (1)
  • demo-app/src/main/kotlin/io/getstream/video/android/ui/join/CallJoinViewModel.kt

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


Walkthrough

CallJoinViewModel now loads the Stream Video SDK when required before joining a call. It waits for initialization completion, returns a nullable Call, and emits GoBackToLogin when no SDK instance is available.

Changes

Call join initialization

Layer / File(s) Summary
SDK initialization during call join
demo-app/src/main/kotlin/io/getstream/video/android/ui/join/CallJoinViewModel.kt
joinCall is now suspendable and nullable. It loads the SDK when needed, waits for FINISHED or FAILED, and uses instanceOrNull().
Unavailable instance state handling
demo-app/src/main/kotlin/io/getstream/video/android/ui/join/CallJoinViewModel.kt
The UI state emits GoBackToLogin when joinCall returns null.

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

Merge Risk: 🟡 Moderate · up to d644c

The change prevents a crash during rapid logout and re-login, but a delayed SDK initialization from the previous account could still be used for the next account’s call join. That could cause cross-account call behavior on a shared device, so the session ownership check or explicit security-owner acceptance is needed before merging.

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant CallJoinViewModel
  participant StreamVideoInitHelper
  participant StreamVideo
  User->>CallJoinViewModel: Tap to join call
  CallJoinViewModel->>StreamVideoInitHelper: loadSdk when SDK is not installed
  StreamVideoInitHelper-->>CallJoinViewModel: Initialization reaches FINISHED or FAILED
  CallJoinViewModel->>StreamVideo: Request instanceOrNull
  StreamVideo-->>CallJoinViewModel: Return Call or null
  CallJoinViewModel-->>User: Complete join or navigate to login
Loading

Suggested reviewers: aleksandar-apostolov

Poem

A rabbit taps join in the morning light
The SDK wakes and checks its state just right
A call appears when setup is done
Or login calls the rabbit back to run
Neat little flows now guide the way
Hop by hop, a safer join today

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 1 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: waiting for SDK re-initialization before joining a call after re-login.
Description check ✅ Passed The description includes the goal, implementation details, UI impact, testing results, and the resolved issue. It explains that no visual changes exist, so screenshots and videos are not needed. The r…
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.
Full details: Description check

Explanation

The description includes the goal, implementation details, UI impact, testing results, and the resolved issue. It explains that no visual changes exist, so screenshots and videos are not needed. The repository checklist is not reproduced, but the required technical information is substantially complete.

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 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-1467-join-tap-races-the-sdk-re-initialization-after-a-fast-re

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.

@andremion

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@github-actions

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 Aug 31, 2026

Copy link
Copy Markdown
Contributor
⚠️ Action not completed

Review rate limited.

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.

@github-actions

Copy link
Copy Markdown
Contributor

SDK Size Comparison 📏

SDK Before After Difference Status
stream-video-android-core 12.29 MB 12.29 MB 0.00 MB 🟢
stream-video-android-ui-xml 5.70 MB 5.70 MB 0.00 MB 🟢
stream-video-android-ui-compose 6.23 MB 6.23 MB 0.00 MB 🟢

@sonarqubecloud

Copy link
Copy Markdown

@andremion

Copy link
Copy Markdown
Contributor Author

@CodeRabbit rate limit

@coderabbitai

coderabbitai Bot commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Your plan includes PR reviews subject to rate limits. Reviews are available now.

@andremion

Copy link
Copy Markdown
Contributor Author

@CodeRabbit review

@coderabbitai

coderabbitai Bot commented Aug 31, 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.

@rahul-lohra rahul-lohra 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

@andremion
andremion merged commit c9acc94 into develop Aug 31, 2026
18 of 19 checks passed
@andremion
andremion deleted the andrerego/and-1467-join-tap-races-the-sdk-re-initialization-after-a-fast-re branch August 31, 2026 14:14
@stream-public-bot stream-public-bot added the released Included in a release label Sep 1, 2026
@stream-public-bot

Copy link
Copy Markdown
Collaborator

🚀 Available in v1.32.0

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

Labels

pr:bug Fixes a bug released Included in a release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants