-
Notifications
You must be signed in to change notification settings - Fork 170
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(coroutine) : make sure to switch coroutine context #4146
Conversation
… not safe to use on main thread.
📱 Scan the QR code below to install the build (arm64 only) for this PR. |
Quality Gate passedIssues Measures |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## develop #4146 +/- ##
========================================
Coverage 83.26% 83.26%
========================================
Files 1885 1885
Lines 49127 49127
Branches 5774 5774
========================================
Hits 40907 40907
Misses 6144 6144
Partials 2076 2076 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
} | ||
}, | ||
) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no change here, just to confirm.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope, the method is not suspending
override suspend fun canUserInvite(userId: UserId): Result<Boolean> { | ||
return runCatching { | ||
override suspend fun canUserInvite(userId: UserId): Result<Boolean> = withContext(roomDispatcher) { | ||
runCatching { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe introduce an extension like
suspend fun <T> CoroutineContext.invokeInner(block: suspend () -> T): Result<T> = withContext(this) {
runCatching {
block()
}
}
(with a better name...)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe later, but I'm not convinced this is necessary...
Content
Make sure to switch coroutine context as rust sdk is not safe to use on main thread.
Motivation and context
Fix ANRs and make sure code is safe to use from main thread under any circumstance.
Replaces #4133
Tests
Tested devices
Checklist