presenter icon indicating copy to clipboard operation
presenter copied to clipboard

sliders on mobile phone are jittery/lag/lock-up

Open bhajneet opened this issue 5 years ago • 5 comments

performance on an ipad was okay, but dragging a slider around on samsung s9 was bad and would mess things up

bhajneet avatar Nov 08 '19 03:11 bhajneet

Adding any sort of denounce to onChange would probably resolve this

On 8 Nov 2019, at 03:40, Bhajneet S.K. [email protected] wrote:

performance on an ipad was okay, but dragging a slider around on samsung s9 was bad and would mess things up

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe.

Harjot1Singh avatar Nov 08 '19 04:11 Harjot1Singh

@Harjot1Singh do you mean something like this for server settings? https://medium.com/@anuhosad/debouncing-events-with-react-b8c405c33273

saihaj avatar May 24 '20 00:05 saihaj

Similar, we have a debounce thing somewhere in thecodebase already, find it by searching for debounce

Harjot1Singh avatar May 24 '20 13:05 Harjot1Singh

I think we can put this on hold until other work is completed. The other tasks in queue all have higher priority than this fix.

Can come back to this when those are done

bhajneet avatar May 28 '20 17:05 bhajneet

The real delay actually comes from using controlled components (so, the value prop). Every time the setting changes, it re-renders the setting component itself. This is inline with React practice, however, in the cases where it is causing a negative effect, or that the re-rendering is too heavy (often the case for components that fast update, like sliders), you have 3 options:

  1. Use defaultValue and flip the setting components over to uncontrolled components. This means that state changes do not reprender the component, and the value is actually just emitted, and not set. The downside is that any programmatic value changes or value changes sent via the network for this device (triggered by another user) will not be reflected in settings if settings is open at the same time (but the presenter should still update). There are a few ways around this, but this would be the tradeoff for now.

  2. Reducing the possible number of updates by discretising/setting a stepper.

  3. Reducing the number of updates sent via throttle. But now that I’ve thought through it, @bhajneet‘s experience makes sense, because the slider will appear to be less reactive, and since the slider is a controlled component, it’ll update with values at 100ms when you are dragging, which is not what we want.

The best solution is most likely throttled onChange + defaultValue (1 & 3)

Originally posted by @Harjot1Singh in https://github.com/ShabadOS/desktop/pull/557#issuecomment-634357374

Harjot1Singh avatar May 28 '20 21:05 Harjot1Singh