honestbleeps / Reddit-Enhancement-Suite

Reddit Enhancement Suite
http://redditenhancementsuite.com
GNU General Public License v3.0
4.13k stars 881 forks source link

Several-second delay after clicking on account in account switcher, before anything happens #4855

Open kuhnertdm opened 6 years ago

kuhnertdm commented 6 years ago

What's the problem?

After clicking on an account in the account switcher, there's a several-second delay before anything happens. The delay ranges from a full second to around ten when it decides to be a jerk. This has been going on for a few months.

Recording: https://www.youtube.com/watch?v=m1DLVnicdj0

Are there any related posts in https://github.com/honestbleeps/Reddit-Enhancement-Suite/issues or /r/RESissues?

Have not found any

What other browser extensions are installed?

Happens even when all other extensions are disabled

niralpokal commented 5 years ago

Does this happen to you in all of the browsers, or a specific one?

jewel-andraia commented 5 years ago

Are you using "new" Reddit? That's expected, since RES is verifying if you're logged in first, but I have several ideas for improving that:

niralpokal commented 5 years ago

@andytuba I can add a check against the cookies if you want to go down that route.

kuhnertdm commented 5 years ago

@niralpokal Just installed on Chrome to test, Chrome is currently switching after a ~1 second delay, while Firefox is currently switching after a ~1.5 second delay. Like I said in the OP, the delay time seems to vary.

@andytuba This is using the old site. See the linked recording.

larsjohnsen commented 5 years ago

Edit: This describes another issue. See below.

The reason it's somewhat slow is that it by default fetches user info for every account (karma, gold status, etc) before generating the widget. To have it appear instantaneously, disable option showUserDetails.

A fix for this could be to always show the widget instantaneously and append user info only when it's has been fetched. This is the code in question: https://github.com/honestbleeps/Reddit-Enhancement-Suite/blob/4f0ba4c0a54071a894cec10dbc85c4136a43fa27/lib/modules/accountSwitcher.js#L166-L196

kuhnertdm commented 5 years ago

@larsjohnsen The delay is between when I click a particular account and when the page reloads. The widget shows up just fine.

larsjohnsen commented 5 years ago

Okey, I misread. In that case it is probably just Reddit being occasionally slow to respond. RES executes two calls sequentially, log out and then log in, before displaying the "account switched" notice. https://github.com/honestbleeps/Reddit-Enhancement-Suite/blob/4f0ba4c0a54071a894cec10dbc85c4136a43fa27/lib/modules/accountSwitcher.js#L224-L254

kuhnertdm commented 5 years ago

TFW making a fix is "Difficulty-1_Easy" but reading the issue is slightly more difficult :^)

larsjohnsen commented 5 years ago

Hehe, yea—I read this issue a while back but apparently forget everything about it.