Wait for the SDK re-initialization before joining a call after re-login - #1793
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
Included review availability: Your plan provides up to 2 included reviews per hour; 0 remain after this review. Walkthrough
ChangesCall join initialization
Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: 🟡 Moderate · up to 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
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Description checkExplanation 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.
✨ Finishing Touches 💡 1📝 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 |
|
@coderabbitai review |
PR checklist ✅All required conditions are satisfied:
🎉 Great job! This PR is ready for review. |
|
SDK Size Comparison 📏
|
|
|
@CodeRabbit rate limit |
|
Your plan includes PR reviews subject to rate limits. Reviews are available now. |
|
@CodeRabbit review |
✅ Action performedReview finished.
|
|
🚀 Available in v1.32.0 |



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, andjoinCallcalledStreamVideo.instance(), which throws when the instance is not installed yet. The exception escaped through theflatMapLatestflow on the UI scope and killed the process.Changes, all in
CallJoinViewModel:joinCallis now suspend and null-safe: whenStreamVideois not installed it triggersloadSdkand awaitsStreamVideoInitHelper.initializedStatereaching FINISHED or FAILED, then readsinstanceOrNull(). The await matters becauseloadSdkreturns early when another initialization is already in flight, without waiting for it.JoinCallbranch of theuiStateflow maps a null call (initialization failed) toGoBackToLogininstead 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
CallLifecycleTests#testUserReentersTheCallAsAnotherUser(crashed before this change) andtestUserReentersTheCallAsTheSameUserAfterLoggingOutboth pass.:demo-app:spotlessCheckand the E2E-flavor compilation pass on this branch.Summary by CodeRabbit