tuskyapp / Tusky

An Android client for the microblogging server Mastodon
https://tusky.app
GNU General Public License v3.0
2.49k stars 391 forks source link

Hitting follow then back quickly can result in follow silently failing, esp under high server load #2741

Open mcclure opened 1 year ago

mcclure commented 1 year ago

On 2022-Oct-31 mastodon.social was under very heavy load due to the Twitter buyout, exposing some Tusky misbehaviors when the server is responding slowly.

Repro steps:

Expected behavior:
The user is followed.

Observed behavior (if the server is under heavy load):
The user is not followed, even after waiting. According to @connyduck on Matrix, the "Follow" button changes to "Unfollow" optimistically, but the follow request is abandoned when the user page is dismissed.

Analysis:

I think "Follow" changing to "Unfollow" is good behavior, but mastodon should do a better job of catching an unusual case where the follow fails or takes so long the user navigates away (hits "back", or even quits Tusky)

The biggest problem here IMO is that the user is not notified, IE, they think they followed and won't notice they didn't unless they think to double check.

Connie's suggested fix: "turn the button into a spinner while the request is in flight", the user would then one assumes wait for it to complete spinning before navigating away
My suggested fix: Eagerly switch to "unfollow", but if the user starts navigating up block them with a modal dialog until the follow request completes (Connie said this sounds harder than the spinner, and it might not catch the case where Tusky itself is dismissed).


connyduck commented 1 year ago

I bet Pete hit that bug https://mastodon.social/@PeteWM1@mas.to/109406278480222481

nikclayton commented 1 year ago

The user shouldn't be blocked by a modal dialog. I've fixed some of this for notifications in https://github.com/tuskyapp/Tusky/pull/3159, as a model for how to rewrite the other fragments to handle it.

If an error occurs during a network operation the user is shown the error, with an opportunity to retry it. If the UI opportunistically showed the operation as succeeding (e.g., try and bookmark a status in airplane mode with the previous code, it will show the bookmark as succeeding) the UI is reset to show the operation did not succeed.

It's only a partial solution, because the state is lost when the user navigates away.

The current problem is because the UI can only show the user one of two states.

Right now, in most places, the default is "This is your desired state of the world". Opportunistically showing "Follow" as succeeding, for example.

This leads to user confusion ("The UI tells me I bookmarked this post, why is it not showing up in my list of bookmarks?", etc).

Showing "This is the current state of the world" also has problems. Click "bookmark", nothing seems to happen, click it again, etc.

Part of the fix for this is for long running operations (roughly, anything that doesn't complete in 250ms) is to show a progress spinner, as @connyduck suggests. This communicates that something is happening to the user.

That works for the fragment/activity that the user is in, but that information is lost when they navigate away, and the network operation is lost when the coroutine is cancelled.

I haven't sketched out a complete solution for this yet, but at the moment it looks something like:

When the user interacts with an element (e.g., bookmark):

When the MastodonRepository receives a request:

When a fragment/activity wants to display something in the UI (e.g., a status):

Other stuff a fragment/activity does:

That last one covers the situation where:

This covers all the bases:

mcclure commented 1 year ago

Now that mastodon.social has generally fixed its scaling issues we should think about how to test a fix for this…