-
Notifications
You must be signed in to change notification settings - Fork 759
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
Unable to change avatar due to NetworkOnMainThread
#4783
Conversation
- fixes some devices/OS's from attempting to run okhttp on the main thread
@@ -68,7 +68,7 @@ internal class DefaultProfileService @Inject constructor(private val taskExecuto | |||
} | |||
|
|||
override suspend fun updateAvatar(userId: String, newAvatarUri: Uri, fileName: String) { | |||
withContext(coroutineDispatchers.main) { | |||
withContext(coroutineDispatchers.io) { |
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.
this is the fix
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.
Its something we already had fixed, not sure why its back. But fileUploader should already dispatch on a background thread, its weird
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.
yeah it's very strange, I checked the okhttp thread pool/interceptors as well, couldn't find any cases where the main thread was being used, unless on some devices the internal okhttp thread uses the main thread/looper for some reason 🤔
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.
This is also something which has been fixed by some fork on their side FWIW.
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!
Fixes #4767 Unable to change avatar
We had a report of
NetworkOnMainThread
whilst changing avatar, I've been unable to reproduce the issue but did notice we have an unnecessary main thread dispatcher being used (looks like it was introduced as part of the suspend migration).main
dispatcher toio
, the user has also confirmed this fixed their issue